[antlr-interest] Questions on conversion to ANTLR

deepsky99 deepsky99 at gmail.com
Tue Apr 3 06:59:05 PDT 2007


I have been playing wiht ANTLR 3, and have the beta version of Terrence's
book, which is really good by the way.

I am thinking of converting some old YACC/FLEX stuff over, and have a
question on start states.  We have a package that converts COBOL copybook
definitions into a XML structure for importing into java code, and it makes
heavy use of start states.  We use this to basically turn LEXER rules on and
off.  I see no start states in ANTLR, but I'm sure there is a way to
accomplish the same thing.  Can anyone point me in the right direction?

Is there a way to have a lexer rule return a different token type based upon
its context?

The main reason is some keywords are only keywords at certain times.  I cant
seem to get the grammar to distinguish between it being an ID and a
Keyword.  in certain places in the data anything I want any token to be an
ID, no matter what it is.  Exclusive start states in lex allowed that.
There was an entry in the Wiki that showed an example :

http://www.antlr.org/wiki/pages/viewpage.action?pageId=1741

I didn't have much success at that
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070403/1b7bfa71/attachment.html 


More information about the antlr-interest mailing list