[antlr-interest] Problems with the ANTLRworks interpreter.

Peter C. Chapin pcc482719 at gmail.com
Thu Jul 31 03:58:29 PDT 2008


rkevinburton at charter.net wrote:

> I don't know if this will help but I have found that the output changes based on the line ending selected (Unix(LF) or MS(CR LF).
>   

I tried playing with that setting but it didn't seem to make any difference.

Today I tried interpreting just 'A' (a bare identifier) as a 
'primary_expression' instead of as an expression. In that case I get a  
FailedPredicateException instead of a NoViableAltException. So that does 
make it sound like the issue is related to backtracking (keep in mind 
that these failures only seem to occur in the ANTLRworks interpreter).

Thanks for your suggestion!

Peter

>> Hello!
>>
>> I'm using ANTLRworks 1.1.7 and I'm building a grammar for a C-like 
>> language. I've created some unit tests for my grammar... specifically a 
>> collection of files containing text that is intended to be syntactically 
>> correct. My test program loops over these files, instantiates a parser 
>> for each (one at a time), and tries to parse them all. I use various 
>> start symbols to exercise parts of the grammar incrementally in these 
>> tests (helps to isolate errors).
>>
>> So, given a file containing just
>>
>> A = B
>>
>> my test program successfully parses this using a start symbol of 
>> 'expresion.' This is fine. However, when I use the ANTLRworks 
>> interpreter and enter the text 'A = B' I get a 'NoViableAltException.' I 
>> noticed that the interpreter is ignoring my WHITSPACE rule so I removed 
>> the white space from the text (using 'A=B') but that didn't help. In 
>> fact, the interpreter produces a NoViableAltException even when I just 
>> use 'A' as input text. However, a bare identifier is a valid expression 
>> in my target language (and it parses fine when using the test program I 
>> described above).
>>
>> I'm think I am missing something fundamental about how the interpreter 
>> is supposed to work. I'm hoping someone can set my feet upon the path of 
>> enlightenment! I did check the on-line ANTLRworks user's guide, but the 
>> section on the interpreter doesn't shed much light on my question.
>>
>> P.S. I do have backtracking mode turned on right now in my grammar's 
>> option. Could that have something to do with it?
>>
>> Peter
>>     


More information about the antlr-interest mailing list