[antlr-interest] Problems with STRING Literals

Ney, Richard Richard.Ney at Aspect.com
Fri May 6 18:26:24 PDT 2005


I have a parser/lexer combination that parsers SQL. I have a rule for my
lexer for STRING_LITERAL with the goal of leaving the string surrounded
with single quotes.

 

STRING_LITERAL

      : '\'' (~('"'|'\''|'\\'))* '\''

      | '\"'! { $append("'"); } (~('"'|'\\'))* '\"'! { $append("'"); }

      ;

 

Now I can parser a statement with a string like this

 

select t1.cur_state_name from K_US_CORE_AGT_STAT t1 where  (
t1.cur_state_name in ("AVAIL"))

 

but I can't parser this one

 

select t1.cur_state_name from K_US_CORE_AGT_STAT t1 where  (
t1.cur_state_name in ('AVAIL'))

 

I get a lexer error 

exception: line 1:93: expecting ''', found ')'

 

Since the rule appears to read past the last ' character. What am I
doing wrong with this rule?

 

Richard Ney                                                         

Principal Software Engineer

Aspect Communications

1310 Ridder Park Drive

San Jose, CA 95131-2313

 

916.797.9602          Home Office

408.325.2464       SJ Office

www.aspect.com

 

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


More information about the antlr-interest mailing list