Hi Qiao,
If you feel the GETTEXT() is costly, the easiest way is to write a
parser rule, which receives this as a token and rewrites and returns the
desired. Instead of matching the lexer token in elsewhere in your parser
grammar, try to match the new parser rule.
For example:
Lexer Grammar:
SINGLE_QUOTED_STRING : SQUOTE (~SQUOTE)* SQUOTE ;
Parser Grammar:
single_quoted_string[std::string& result] : SINGLE_QUOTED_STRING
{
pANTLR3_COMMON_TOKEN token = $SINGLE_QUOTED_STRING;
ANTLR3_MARKER start = token->getStartIndex(token);
ANTLR3_MARKER end = token->getStopIndex(token);
result.assign( (char*) start, stop-start+1 ); //create it with your
requirements.
};
Thanks,
Gokul.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.