[antlr-interest] lexer: embedded quotes assistance
Diehl, Matthew J
matthew.j.diehl at intel.com
Thu Aug 23 09:33:27 PDT 2007
> 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