Hi John, I tried out your example and it worked just as expected. The problem I was having was with the JavaScript target. For some reason, the statement $type = TEXTNODE, kept reporting the error, TEXTNODE is not defined. I changed this to use the actual type value(2 in this case) and it worked!. I am now confused as to why this is. I know the JavaScript target is new to ANTLR, but this is something which I guess should be standard across all platforms. I am not sure if there is any other way to set the type of the token in the lexer. Thanks
On Mon, Apr 26, 2010 at 7:20 PM, John B. Brodie <[email protected]> wrote: > 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. > > > > > -- Kunal Sawlani List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
