This repository contains a simple compiler project consisting of lexical analysis, syntax analysis, and semantic analysis components. The project is implemented in JavaScript.
-
input.txt
- Input file for the custom language used in the compiler.
-
output.txt
- Output file of the lexical analyzer, containing a set of tokens generated from the input.
-
main.js
- JavaScript file containing the implementation of the lexical analyzer and syntax analyzer.
- The syntax analyzer has a hard-coded CFG (Context-Free Grammar) that is customizable according to your specific language requirements.
- to use your own cfg , update the Const grammer = { } according to your CFG .
-
semantic.js
- JavaScript file containing the implementation of the semantic analyzer.
- Handles semantic analysis tasks, including scope checking, type checking, and error reporting.
-
index.html
- HTML file for displaying the results of the semantic analysis.
- Utilizes JavaScript to interact with the semantic analyzer and showcase analysis results.
To run the compiler and perform lexical and syntax analysis, execute the following command in your terminal:
node main.js