[antlr-interest] [v3] not including text in token. Still possible?
Terence Parr
parrt at cs.usfca.edu
Mon Feb 6 15:20:42 PST 2006
On Feb 6, 2006, at 3:11 PM, Kay Roepke wrote:
> Suppose I have the following lexer rule:
>
> FOO : '"'! ID '"'! ;
>
> with ID being some canonical ID-rule.
>
> I'm seeing the ast_suffix.type==ANTLRParser.BANG in the rule 'atom'
> of codegen.g. But I also need to add code to the FOO lexer rule to
> set up
> the local string buffer to collect the chars from the ID subrule.
> Simply adding code to the charRef ST (or rather using the new
> charRefBang) after
> the match won't do it.
yeah some setup is needed.
> Now if I'd written "FOO! : ... " I'd be all set, but if the bang
> occurs in of the atoms inside the rule I have to look inside first
> and instantiate
> the appropriate ST for this. The one with the string buffer setup
> code.
Hmm...well i used to just record the start index before every element
(token or rule) and then if not a bang, add chars from saved index to
current index into buffer. If a bang, then don't add. Would that work?
Ter
More information about the antlr-interest
mailing list