antlr - Ignoring leading and tailing quotes in a string literal match -
i want match 'foo' foo, not 'foo'.
i have following lexer rule:
string_literal : '\'' ( ~'\'' | '\'\'' )* '\'' ; but seems match quotes.
my visitor looks this:
public override ifilterexpression visitliteral_value(magichubfilterparser.literal_valuecontext context) { return makeexpression(context.gettext()); } i know can trim @ point, suspect quicker , cleaner handle on lexer level, if possible.
what's best way this?
as @corona suggests, might more canonical in visitor. however, did figure out how parsing rule:
stringbody : ( ~'\'' | '\'\'' )*; stringliteral : '\'' body=stringbody '\'' ;
Comments
Post a Comment