[antlr-interest] SQL string literals
Pete Forman
pete.forman at westerngeco.com
Fri May 31 01:11:19 PDT 2002
How might I handle the SQL style of quoting in string literals?
This allows the delimiter (' or ") to stand for itself in the string
if it is doubled. Examples of a simplification of this are
"foo" => foo
"using ""quotes""" => using "quotes"
"""" => "
"" => [empty string]
My naive solution is this:
class SqlLexer extends Lexer;
STRING
: '"'! (~('"')|'"''"'!)* '"'!
;
Which results in:
ANTLR Parser Generator Version 2.7.2a2 (20020112-1) 1989-2002 jGuru.com
sql.g:4: warning: lexical nondeterminism upon
sql.g:4: k==1:'"'
sql.g:4: between alt 2 and exit branch of block
How might I get that to work?
My best workaround at the moment is to get the parser to concatenate
adjacent STRINGs inserting a quote. For correctness the lexer should
be emitting whitespace tokens but that will clutter all the grammar.
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pete.forman at westerngeco.com -./\.- opinion of Schlumberger, Baker
http://petef.port5.com -./\.- Hughes or their divisions.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list