I am trying to compile programs using ANTLR, and I use the Java programming language as the goal, and the core of the problem is to develop a Regentizer Intent to fix bugs and improve the source code if the source code is not in grammar. on textbooks and books on ANTLR. I see how to compile simple code with the assumption that the lexer and parser I did, and the source code:
int main(){ int a,b; c=20; }
how can a program detect errors that the previously unknown variable 'C' did not declare?
I tried to apply it by following the compilation instructions using ANTLR, but the code for the ANTLR generator is considered valid because it complies with the rules of the grammar of the expression. but in fact the variable c is unknown.
or how to make a grammar that can implement object-oriented concepts in it? I tried using ANTLR grammar, but the result still does not explain the concept of OOP.
public class Hello { } public class HelloTwo { Hello hl = new HelloWrong(); }
If I compile the code, the result will be valid, because according to Grammar.but, look that the HelloWrong class really is not. This also involves writing the previous variable in my first tasks.
Sorry, my English. Hope you can help me. thanks to you
source share