[antlr-interest] Lexical states

marcschellens m_schellens at hotmail.com
Thu Nov 20 00:29:39 PST 2003


I read the manual about lexical states, but:

I have a parser for a format string. Parts of that format
string are simple strings. ("...")
But if a simple string starts with '%' (%"...") its content is
a c-style format string (CSStr) which has to be processed differently
ie. then the string contains further format information.
But both formats could be handled in the same parser.
I could break this CSStr into parts and parse them in the parser,
but the lexer complaints that the lexical rules are ambiguous then.
(eg. a CSStr ends with '"', that's how a normal string starts...)

As I understood the lexical states, I could embed the parsing rules
for the CSStr into protected rules, but then the parser can't see them.
Or is there a way to send a token stream to the parser
form within protected rules?

Any other suggestion?

Thanks,
marc



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list