[antlr-interest] about parse key words
Renee Luo
reneel at imexsystems.com
Fri Nov 6 08:10:19 PST 2009
Hi there,
I have a problem with parse key words. Like in PL/SQL "EXIT" is key word. But some variable names also include this key word.
DECLARE
CURSOR my_cursor IS
........
BEGIN
OPEN my_cursor;
LOOP
......
exit WHEN my_cursor%NOTFOUND;
.......
END LOOP;
CLOSE my_cursor;
:GLOBAL.exit := 'Y'; --------- (if this statement is :GLOBAL.exit123:= 'Y', no problem)
EXECUTE_TRIGGER('WHEN-WINDOW-CLOSED');
If my g file is set "exit" as keyword, when the g file analyses the variable name , always go to "statement" rule to match keyword then throw exception. How can let the parser knows the second "exit" is variable( go to varName rule) not key word ( don't go to "statement" rule)?
statement
:
.......
|
"EXIT"^ (expression)? (WHEN! (expression))? SEMI!
|
...........
;
......
varName :
(COLON)? IDENT^ (DOLLAR IDENT)? ( DOT IDENT )? ( DOT (IDENT | COMMIT) )? ( DOT (IDENT) )? {#varName.setType(VARIABLE_NAME); }
;
Someone can help me to solve this problem? Thanks in advance.
Renee
________________________________
This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of ImexSystems Inc.
If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone.
Please contact the sender if you believe you have received this email in error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091106/93439767/attachment.html
More information about the antlr-interest
mailing list