[antlr-interest] pushed antlr build with tree rewriting and composite grammars (java)

Terence Parr parrt at cs.usfca.edu
Sat Jan 12 17:25:51 PST 2008


Oh, not lexer fragments...parser fragments...hmm..should work. can u  
trace for me a bit further?
Ter
On Jan 12, 2008, at 5:25 PM, Terence Parr wrote:

>> It seems that ANTLR is less happy about me trying to parse  
>> 'fragments'
>> now.
>>
>> i.e. if I set up the input "test", and then invoke
>>
>> MyParser.identifier()
>>
>> the generated parser now says
>>
>> NoViableAltException(-1!=[()* loopback of ..blah..]
>>
>> whereas this seemed to work with the earlier ANTLR releases, at least
>> for some rules.
>>
>>
>> Is this sort of usage just not intended to work?
>>
>> In the cases where I had problems in the past, I'd just append some
>> other token to the language fragment I was attempting to parse.
>>
>> Is there a 'correct' way to fix this?  e.g. putting EOF all over the
>> place?
>
> fragment rules are meant to be called only from other lexer rules;  
> any other usage is "off label" ;)
>
> Ter



More information about the antlr-interest mailing list