[antlr-interest] lexer: embedded quotes assistance
Edwards, Waverly
Waverly.Edwards at genesys.com
Thu Aug 23 12:46:12 PDT 2007
I *think* I understand. I will have to try it out, run it through the
debugger to ensure I understand how it works. Its much more elegant
than my solution, which strangely enough doesn't even work.
W.
-----Original Message-----
From: Diehl, Matthew J [mailto:matthew.j.diehl at intel.com]
Sent: Thursday, August 23, 2007 12:33 PM
To: Edwards, Waverly; antlr
Subject: RE: [antlr-interest] lexer: embedded quotes assistance
> History...
> I am replicating an existing language that uses embedded quotes to
> indicate a quote character.
I'll show you something I wrote that worked...but there's probably some other simpler ways using '.'
My quoted text can only use graphic characters (a-z 0-9 SpaceCharacters, and other graphic characters (\u00a1 - \u00ff).
StringLiteral
:Quote GraphicCharacter* Quote
;
fragment
GraphicCharacter
: UpperCaseLetter | LowerCaseLetter | Digit | SpecialCharacter | SpaceCharacter | (Quote Quote)
;
But since it matches double quotes, it will continue when it sees one
> In addition to embedded quotes
> the quoted material may span multiple lines by using the ¬ character
> followed by a CR. Now a rule for treating ¬CR as whitespace is not an
> issue as I just create a rule
I'm sure if you include the CR rule above, it would work as well
Ok,
Matt
More information about the antlr-interest
mailing list