[antlr-interest] Replacing characters in a token during lexical phase
Ney, Richard
richard.ney at aspect.com
Fri Jun 6 14:48:06 PDT 2003
I am trying to figure out how to get hold of the token on a string literal
so I can change the enclosing double quotes into single quotes. The rule
looks like this"
// string literals
STRING_LITERAL
: '\'' (~('"'|'\\'))* '\''
| '\"' sl:(~('"'|'\\'))* '\"'
{
//_token = makeToken(_ttype);
//_token.setText(
}
;
Which is the basic string literal rule, any idea how to get hold of the
character without running into the WS rule
// White Space
WS : (' '
| '\t'
| '\n'
| '\r')
{ _ttype = Token.SKIP; }
;
Since if I pull the inner piece of the string literal rule into a separate
token it conflicts with WS.
-Richard
----------------------------------------------------------------------------
------------------------
Richard Ney Aspect
Communications
Principal Software Engineer
< <http://www.aspect.com/> http://www.aspect.com>
Main: 408.325.2200
< <mailto:richard.ney at aspect.com> mailto:richard.ney at aspect.com>
SJ Office: 408.325.2464
Home Office: 916.797.9602
----------------------------------------------------------------------------
------------------------
The Three Laws of Infernal Dynamics:
1. An object in motion will always be headed in the wrong direction.
2. An object at rest will always be in the wrong place.
3. The energy required to change either of these states will always be more
than you wish to expend, but never so much as to make the task appear
prospectively impossible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20030606/846db5d9/attachment.html
More information about the antlr-interest
mailing list