Can ANTLR check for valid variable declarations?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sun_set
Posted On:   Thursday, January 31, 2002 10:05 PM


For example, in java context:



			
int m = 0;
m = i; // error, since i is not declared yet



can ANTLR check for such invalid assignments?

Re: Can ANTLR check for valid variable declarations?

Posted By:   Terence_Parr  
Posted On:   Saturday, February 2, 2002 09:55 AM

ANTLR is tool that generates parser from a grammatical description of your input language. You can give it a grammar to read in that input, but you will have to add actions to check for valid declarations etc... For example, you will add "m" to your symbol table when you see it in "int m=0;" and then check symbol table when you see "m = i;" Oh, actually in your case, you're looking for trouble with 'i'. It would not be found in the table so it would be an error.
About | Sitemap | Contact