[antlr-interest] String concatenation expression rule
franck102
franck102 at yahoo.com
Fri Nov 18 03:39:52 PST 2011
I am writing a grammar for a fairly complex expression language, and in
particular I need to support string concatenation which is performed simply
by separating string literals with a space; and which automatically converts
other expressions to a string if needed to concatenate:
"a" "b" -> "ab"
2+3 "mm" -> "5mm"
I suspect I could use predicates to write a rule like this:
concatExpression
: ( expression | STRING_LITERAL )+ { apply only if at least
one of the elements is a string literal }?
Is there a way to achieve this? The alternative formulations I can think of
are pretty messy...
Thanks!
--
View this message in context: http://antlr.1301665.n2.nabble.com/String-concatenation-expression-rule-tp7007921p7007921.html
Sent from the ANTLR mailing list archive at Nabble.com.
More information about the antlr-interest
mailing list