[antlr-interest] Parsing (string_quote ")

Sam Harwell sharwell at pixelminegames.com
Mon Sep 8 15:29:11 PDT 2008


I have to do something similar - I need the single quote character
available for a couple different things, so I parse a single quoted
string in the parser instead of the lexer using the following rules:

 

name

        :       namevalue

                -> ^({new CommonToken(AST_NAME,$namevalue.text)})

        ;

 

namevalue

        :       '\''

                (       (~'\'') =>

                        (       ('\\') => '\\' .

                        |       .

                        )

                )*

                '\''

        ;

 

Sam

 

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of
titech at metaorb.com
Sent: Monday, September 08, 2008 1:58 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Parsing (string_quote ")

 

 

How would you parse this:

 

(string_quote ")

 

The file contains both single- and double-quoted strings as well.

 

Thanks,

--Mike

 

Mike Allbright

DLP Products

Texas Instruments, Inc.

 

List: http://www.antlr.org/mailman/listinfo/antlr-interest

Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080908/c5032a9f/attachment.html 


More information about the antlr-interest mailing list