[antlr-interest] Another parsing question

Carter Cheng carter_cheng at yahoo.com
Mon Aug 4 13:45:11 PDT 2008


Thanks everyone for the help thus far. This is likely another beginners question concerning the behavior of the lexer/parser interactions in ANTLRv3. The question I have is are the tokens requested by the parser context dependent? i.e. is a different (N)DFA constructed depending on which tokens the parser expects to see in the stream or is there only 1 N(DFA) with a series of stop states.

I ask this question because of the following ambiguity that arises from a grammar I am working on which attempts to be compatible with an existing language.

(a[1]); // lookup the index 1 in the variable array a

([ 1 : 2 ]); // construct a mapping value with key : value in this case 1 : 2

The question I have is how can ANTLRv3 know whether ]) is a single token or two tokens?

Thanks in advance,

Carter.


      


More information about the antlr-interest mailing list