antlr - How to strip quotes from a string -


i wrote simple rule match string in antlr grammar:

string    :   '"' (esc | ~["\\])* '"'    ; 

actually need content of string , not quotes, required match string.

i found solution antlr 3, which published in antlr wiki. know if there solution achive same without custom code.

this should work:

string    :   '"' (esc | ~["\\])* '"'    {settext(gettext().substring(1, gettext().length()-1));}    ; 

it simple removes first , last character string.

taken https://theantlrguy.atlassian.net/wiki/spaces/antlr3/pages/2687006/how+do+i+strip+quotes


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -