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

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -