[antlr-interest] Sample scannerless parser with AST construction in unmodified ANTLR

Terence Parr parrt at cs.usfca.edu
Sun Apr 17 09:36:12 PDT 2011


On Apr 17, 2011, at 8:56 AM, Jason Doege wrote:
> On a related note, it looks to me that when you have something like:
> 
> kreturn : 'return' ws?;
> 
> that the lexer is automatically created with a lexical element 'return' 
> whereas my initial expectation is that 'return' would only be tested for 
> existence at that particular point in the parsing process. I think 
> limiting the parser to only considering the rule at hand is crucial to 
> obtaining the flexibility implied by a scanner-less parser generator.

That's correct. when you see a reference to kreturn it goes off to parse it. The only tricky part comes in when you need to distinguish between keywords and identifiers.

Ter


More information about the antlr-interest mailing list