Hi Min,

I'm a little puzzled at your example, but I'll take a crack at it.

1. "we have a statement CREATE USER, where USER is not a keyword,"

... except that you have made a separate USER token. So likely the error 
results from this: where the parser is looking for an Identifier in rule 
userItem, instead the next token returned by the lexer is a USER token.

There are solutions to the problem of keyword-as-identifier here:

http://www.antlr.org/wiki/pages/viewpage.action?pageId=1741

2. That said, I'm not clear on how uppercase 'USER' is matching your input 
which includes lower case 'user'.  Perhaps you are using some case-insensitive 
strategy here (not shown)?

-- Graham 


At 9/27/2009 01:14 PM, Min Zhou wrote: 
Hi all, 
I am a newbie, using antlr to parse sql language.  we have a statement CREATE 
USER, where USER is not a keyword, so that 
CREATE TABLE TBL(USER int) is acceptable. But my parser came across a problem:
mydb> create table tbl(user int);
FAILED: Parse Error: line 1:17 mismatched input 'user' expecting Identifier in 
column specification

here is grammar snippets

createUserStatement
@init { msgs.push("create user statement"); }
@after { msgs.pop(); }
    : KW_CREATE USER userItem (COMMA userItem)*
    -> ^(TOK_CREATEUSER userItem+)
    ;

userItem
@init { msgs.push("user item"); }
@after { msgs.pop(); }
    : (Identifier (KW_IDENTIFIED KW_BY StringLiteral)?) 
    -> ^(TOK_USER Identifier StringLiteral?)
    ;


USER: 'USER'

Identifier
    :
    (Letter | Digit) (Letter | Digit | '_')*
    | '`' RegexComponent+ '`'
    ;  

anyone help me on this?
Thanks in advance!


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to