[antlr-interest] lexer issue - \ has double meaning in our rules‏

Jason Hocker jkh at datatel.com
Thu May 14 17:19:32 PDT 2009


An end of statement in our language is the end of the line.  Strings can be surrounded by double quotes, single quotes, or backslash.  The backslash can also have another meeting as a different symbol.  So I want a STRINGLITERAL when there are two backslashes on the same line, with everything in between as part of the string, or I want a separate token just for the backslash.  In my lexer, its starting down the stringliteral path, and then throwing an error that it cant match the last token.
Any suggestions?

BACKSLASH : '\\';

STRINGLITERAL : ('"' (~('"' | '\n' | '\r'))* '"')
 | ('\'' (~('\'' | '\n' | '\r'))* '\'')
 | ('\\' (~('\\' | '\n' | '\r'))* '\\')

 ;

________________________________
Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. In addition, if you have received this message in error, please advise the sender by reply e-mail and delete the message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090514/07221ea6/attachment.html 


More information about the antlr-interest mailing list