antlr4 - how to transform recursive expressions? -


in anltr4 java grammar(https://github.com/antlr/grammars-v4/blob/master/java/java.g4) know when have complete expression. in example trying make transformation similar following:

from: string foo = bar + ", " + baz + "; true"; to:   string foo = string.format("{0}, {1}; true", bar, baz); 

the trouble begins in declaration grammar:

expression ('+'|'-') expression"  

which child of expression well. given example above, callbacks following:

0: exp0:bar, exp1:"," 1: exp0:bar ",", exp1:baz 2: exp0:bar "," baz, exp1:"; true" 

i targeting line using #alias btw. awkwardly saying - how use listener able grab entire expression when rule expressed recursively in order transform entire expression? or there way haven't seen yet?


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -