[antlr-interest] Re: A simple prepocessor with a lexer?

Pete Forman pete.forman at westerngeco.com
Wed Oct 8 01:54:34 PDT 2003


At 2003-10-08 00:36 +0000, maaxxxcal wrote:
>One of the effect of my pragma is to define what the statement
>separator is going to be for the next portion of code.

ANTLR is not well suited to dynamic grammars.  However you might try
an approach like this rough effort in the lexer.

PUNCTUATION
   : '@'|'%'
     {if ($getText().equals(currentSeparator)) {$setType(SEPARATOR);};

PRAGMA_SEPARATOR
   : "-- PRAGMA separator=" ('@'|'%')
     {currentSeparator = lastChar($getText());};

-- 
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
pete.forman at westerngeco.com    -./\.-   opinion of Schlumberger, Baker
http://petef.port5.com           -./\.-   Hughes or their divisions.


 

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




More information about the antlr-interest mailing list