[antlr-interest] Re: Checking for expression end in Javascript parser

Tech tech at swingkid.fsnet.co.uk
Wed Oct 26 13:38:00 PDT 2005


Hi Terence,

I wanted to say 'if the next character is on the same line it has to be 
a semi colon, otherwise the semi colon is optional.' I'm not sure if I 
need the 'semi colon is optional' bit, because we could always treat it 
as a separate (empty) statement, but am I right in thinking I have to 
put something as an alternative for the semantic predicate to make sense?

Mark

Terence Parr wrote:

>
> On Oct 26, 2005, at 1:33 AM, Tech wrote:
>
>> I have overriden consume() in my parser to store the line number of  
>> the last token consumed:
>>
>>    int currentLine = 0;
>>
>>    public override void consume()
>>        {
>>            currentLine = LA(1);
>>            base.consume();
>>        }
>>
>> I have then defined semi:
>>
>>    semi
>>        :    {currentLine == LT(1).getLine()}? SEMI
>>        |    (SEMI)?
>>        ;
>>
>> This seems to work, but gives me lots of disambiguation warnings.  
>> What do you think?
>
>
> Hi Mark,
>
> remove the (...)? around the SEMI as semi is optional...probably not  
> waht you want.
> Ter
>
>
>



More information about the antlr-interest mailing list