[antlr-interest] Support for non-java special characters (\a)

Bryan Ewbank ewbank at gmail.com
Sun Apr 17 03:57:04 PDT 2005


This is an interesting problem in light of the current
"Language-Neutral Actions" discussion :-)

You might try using setText() function directly instead of the
$setText() directive.  Another option is to use the corresponding hex
escape sequence (\01, I think), since that is supported in C# as well:


    A regular string literal consists of zero or more characters enclosed
    in double quotes, as in "hello", and may include both simple escape
    sequences (such as \t for the tab character) and hexadecimal and
    Unicode escape sequences.

On 4/17/05, Doug Holton <doug.holton at comcast.net> wrote:
> I get an error trying to $setText("\a") using the C# antlr runtime.
> "\a" is a special character for a console beep.
> The error is "unexpected character: a".
> 
> Is there any way I can work around this in my grammar, or is this
> something that could be added to the C# antlr version, so that
> perhaps it could allow: $setText("\\a") and convert it to "\a".
> 
> I can manually change \\a to \a in the generated lexer source and the
> beep works.
> 
> Here's a list of all the special characters possible in C#, some of
> which are not supported in java:
> \' \" \\ \0 \a \b \f \n \r \t \v
> 
> I imagine this would be an issue for the python antlr runtime, too.  You
> can print "\a" in python as well.
>


More information about the antlr-interest mailing list