[antlr-interest] SQL grammar, keywords that can be
identifiers
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Jul 23 02:39:25 PDT 2004
On 7/23/04 12:23 PM, "Pete Forman" <pete.forman at westerngeco.com> wrote:
> At 2004-07-22 22:33 +0300, Ruslan Zasukhin wrote:
>> join_type
>> : ("left" | "right" | "full" ) ( "outer"! )?
>>
>>
>> But SQL grammar still must accept the next query
>>
>> WHERE left(fld,5) = "Peter"
>> ^^^^^
>
> So the problem is that a token may be a keyword or not depending on the
> context.
>
> This might be soluble in the lexer using either lexer states or lexer
> switching. However that is moving rather a lot of the logic from the parser
> to the lexer and does not look to be a promising approach.
>
Exactly.
> I would have the lexer aggressively return tokens whenever a keyword might be
> valid.
>
> The parser would then accept keywords in places where identifiers are expected
> and call setType to make them into identifiers.
> join_type
> : (LEFT | RIGHT | FULL) (OUTER!)?;
>
> where_clause
> : WHERE identifier LPAREN ...
>
> identifier
> : IDENTIFIER
> | (LEFT | RIGHT | FULL | OUTER) {##.setType(IDENTIFIER);};
>
> My syntax is not checked but hopefully you'll get the idea.
So lexer returns ID,
But we add one more rule to Parser
identifier : ..............
Which try do something more smart...
Okay we will try to think in this direction.
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list