[antlr-interest] Allowing and maintaining space characters in string literals

Janet.Hurwitz at usc-bt.com Janet.Hurwitz at usc-bt.com
Thu Sep 8 12:23:34 PDT 2011


@Kevin - thanks for the reply:
>Why can't ' ' be a part of either OTHERCHARS or STRCHAR?  Then you don't
need the syntactic predicate in your STRING_LITERAL rule....
I don't see your rule for handling the " characters.
If you are worried about strings containing NLs or TABs (which would be
errors), then you might want your STRING_LITERAL rule to check for them
(in a semantic predicate instead and explicitly disallow them) instead
of trying to allow blanks.

** I tried making the blank part of OTHERCHARS or STRCHAR; that didn't work for me, either. Perhaps I'm running into the interpreter problems John mentioned.

> Ouch, your not going to try and parse:

"identifier =two words"

as if it was

identifier ="two parts" are you??

** No, I'm not! There are actually 2 different cases. More fully:

..., keywordOne="id1=uservalue" | "id2= two words", keywordTwo=" a bunch of words here. maybe spaces maybe not"

This is just part of a more complicated grammar, with nested structures separated by curly brackets, lists separated by vertical bars, and more. I didn't include the whole grammar showing the handling of the quotation marks.


More information about the antlr-interest mailing list