[antlr-interest] how to quote things?

Jim Idle jimi at temporal-wave.com
Tue Feb 26 16:47:56 PST 2008


C# requires two quotes per embedded quote and you probably need to 
escape them from ANTLR, which gives:

["\"\"\"\""]

Or something like that (in case of typos I can't see for looking),

Jim


> -----Original Message-----
> From: Benjamin Shropshire [mailto:shro8822 at vandals.uidaho.edu]
> Sent: Tuesday, February 26, 2008 4:13 PM
> To: Antlr Interest
> Subject: [antlr-interest] how to quote things?
> 
> I have this in a tree grammer:
> 
>      document : ^(DOCUMENT concept["\"\""]+)
>               ;
> 
> what I'm trying to do is, when I parse a document try to parse a 
string
> of concepts and pass down the string "" (that is in C notation 
"\"\"").
> This value then gets used further down to generate some stuff. The
> problem is that I can;t find anything to stuff into the [...]'s that
> gets passed through as something that C# things of as "\"\"".
> 
> Antlr keeps adding commas and spaces and whatnot.
> 
> example outputs
>     concept(", \", \", ");
>     concept(', \", \", ');
> 
>  The manual has references to using \uXXXX for uni-code but that also
> doesn't work.
> 
>     concept(\u, 0022+, \u, 0022);
>     concept("\u, 0022+, \u, 0022");
> 
> Question 1:  How do I pass the needed string literal to the concept
> rule?
> Question 2: (might be irrelevant depending on 1) Is what I'm doing the
> "correct way" to do things?
> Question 3: What was antlr doing there?




More information about the antlr-interest mailing list