[antlr-interest] lexer: embedded quotes assistance

Edwards, Waverly Waverly.Edwards at genesys.com
Wed Aug 22 14:29:48 PDT 2007


This is probably pretty simple but I'm not getting it.
Would mind assisting me with a way to create a lex rule that
turns my original quoted string into the two versions below?

History...
I am replicating an existing language that uses embedded quotes
to indicate a quote character.  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

CONTINUATION:
     :     '¬'CR
     ;

because I need it for the language anyway but inside of a quote
is another matter.


original text: "I said, ""Hello."""

quote rule 1: "I said, "Hello.""

quote rule 2: I said, "Hello."

------------

My second problem is that the character ¬ followed immediately 
by a CR is used for line continuation

myString = "line ¬
""continuation."""

print myString

result is: line "continuation"

How would I create a rule that would return the resulting string?



Suggestions are not just welcome they are highly sought after.


Thank you,


W.




More information about the antlr-interest mailing list