I'm trying to make a compilation of programs using ANTLR and I use the Java programming language as the target and the core of the issue is developing the Intent Regornizer to correct errors and improve the source code if the source code is not in accordance with the Grammar. on tutorials and books on ANTLR I see how to compile a simple code with the assumption that the lexer and parser I've made and the source code like this:
int main(){
int a,b;
c=20;
}
how a program can detect errors that the variable ' C ' is not known to have declared before?
I've tried to apply it by following the instructions on how to compile using ANTLR but code for ANTLR generator is considered valid because it is according to the grammar rules of expression. but in fact the variable c is not known.
or how to make a grammar that can implement object-oriented concepts in it? I've tried using the ANTLR grammar but the result still doesn't explain the concept of OOP.
public class Hello {
}
public class HelloTwo {
Hello hl = new HelloWrong();
}
If I compile the code, the result is valid because in accordance with the Grammar.but look that class HelloWrong is really no. It is also associated with the writing of the previous variable on my first probelms.
Sorry with my English. I hope you can help my problems. thanks to you