I am new to ANTLR4. Currently, I am working on a small translator project for C language. My aim is to translate a simple and small C program into other programming languages. I am able to parse the C grammar file using ANTLR4. Using Visitor I am able to print each and every part of input C file. Now, I need to create a Symbol table. For example : - If my input C file is : -
int main() {
int a=1;
if(a==1)
printf(" a = %d",a);
return 0;
}
Using Visitor, I am able to print on screen like typespecifier -> int, Identifier -> a, Constant -> 1, etc.
Now, I want to create a symbol table to store all these symbols with information like their scope, type, value etc.
Can anyone suggest me some examples. Or at least guide me how to create a Symbol table in ANTLR4 using Visitor.
Any help will be really appreciated.
Thanks in Advance.