This project implements a custom React compiler built using ANTLR v4, designed to recognize React and JavaScript code. It outputs an Abstract Syntax Tree (AST) and a Symbol Table, which includes all declared variables and functions from the provided code.
- AST Generation: Converts the input code into a structured Abstract Syntax Tree (AST).
- Symbol Table: Extracts and lists all variables and functions defined in the code.
The project is divided into the following stages:
- Lexical Grammar Definition: Tokenizes the parsed input based on defined lexical rules.
- Parser Definition: Specifies the parsing rules for JavaScript, JSX, and React-specific syntax.
- Visitor Implementation: Generates an Abstract Syntax Tree (AST) from the parsed input.
- Symbol Table Generation: Collects and outputs a symbol table containing all declared variables and functions.
- Generate ANTLR Recognizer for "LexerGram.g4" and "ParserGram.g4".
- Write your React and JavaScript code in the
Files/test.txtfile within the project directory. - Run the
Main.javafile to parse the code and generate the output (AST + Symbol Table).