Reserved word
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Xiaopeng_Cao
Posted On:   Tuesday, June 5, 2001 06:38 PM

Hi!
I would first thank ANTLR for help me making a COBOL parser. I am studying IBM PL/I now, a language without reserved word, that means a keyword is only recognized as keyword in proper syntax context.
eg.
DECLARE IF; /*a variable named IF*/
IF I = 1 THEN /*an IF statement*/
How can I have the lexer generate the proper token?

Re: Re: Reserved word

Posted By:   Xiaopeng_Cao  
Posted On:   Thursday, June 7, 2001 09:22 PM

Thank you very much!

Re: Reserved word

Posted By:   Monty_Zukowski  
Posted On:   Thursday, June 7, 2001 06:40 AM

The lexer can't generate the proper token because, as you say, you need the proper syntax context. It will be the parser which will have to decide what the token should be.


When I did this in the R/BASIC parser, I returned IF and all the other keywords as keywords, then had a special rule keywordId which could be used where you would normally have used ID. Syntactic predicates were needed around the places I would use keywordId so that the ambiguities would be resolved properly.

About | Sitemap | Contact