[antlr-interest] Matching Substring In Lexer

John B. Brodie jbb at acm.org
Mon Apr 26 16:20:55 PDT 2010


Greetings!

On Mon, 2010-04-26 at 19:02 -0400, Kunal Sawlani wrote:
> Hi, 
> Thanks to both of you, I have something which works now. However, I am
> running into a slight issue, where the parser complaints that ANYTHING
> is not defined, in case of the grammar Jim suggested, and for John's
> grammar, it complaints that TEXTNODE is not defined. I tried defining
> these using Fragment, but to no avail. Also, I am using a combined
> grammar, and will splitting it into a lexer and parser be necessary?


In the complete and tested example that I posted there are 2 tokens:
ANYTHING and TEXTINPUT. TEXTINPUT is defined in a tokens {} option block
near the top of the file.

As an aside, why did you expect a TEXTNODE token?

In any case, you should be able to run my example through the
org.antlr.Tool, compile the resultant .java files, execute the parser,
and then observe the results.






More information about the antlr-interest mailing list