Skip to content

🔧 My studies on context-free grammar, using ANTLR4 (C++) to generate the parser files. Some basics are developed, such as token processing, recursion, variable definition, array processing, Abstract Syntax Tree (AST) manipulation, UNICODE support, and error handling.

License

melchisedech333/antlr4-experiments

Repository files navigation




Language: PT-BR

Here are my studies and experiments using ANTLR4 (for language analysis). The target code in this case is in C++, and for this a base project is used, which can be found here:

Just download the project and leave it in the same directory with the experiments.

Note: the base project directory name must be project, so that the test build scripts can work properly.

If my code has helped you, please consider sponsoring me 💙


📑 Table of Contents



🛠️ Instructions

To run a test, just run the script clean-and-build.sh or re-compile.sh followed by the name of the test directory, as in the example below.

./clean-and-build.sh "1 - processing tokens (through visitor)"
./re-compile.sh "1 - processing tokens (through visitor)"

After compiling, parsing is immediately executed, where the syntax file existing in the respective directory is passed as a parameter.

Thus, it is possible to change the test Lexer, Parser and Syntax files, as well as the main.cpp file in their respective directories.

Brief description of the scripts:

  • clean.sh - Cleans files from previous builds from the base project. Note: this script does not need parameters.
  • clean-and-build.sh - Recompiles 100% of the base project.
  • re-compile.sh - Compile the base project without having to compile 100% of the project.

Note: the file compiled by the base project is located inside the project directory, with the name parsing.


😃 Author

Sponsor: melchisedech333
Twitter: Melchisedech333
LinkedIn: Melchisedech Rex
Blog: melchisedech333.github.io


📜 License

BSD-3-Clause license



Remember to give me
a beautiful little star 🤩