No description
  • C++ 59.9%
  • Java 38.9%
  • ANTLR 1.1%
Find a file
2025-02-23 09:38:20 +01:00
.antlr wip 2024-12-06 14:18:52 +01:00
.vscode improved parsing performance for apex 2025-01-14 07:31:56 +01:00
antlr4-runtime Fixed parsing issue with json_serialize 2025-02-23 09:38:20 +01:00
cmake changed anltr runtime repo to fork with fixes 2024-11-25 20:35:53 +01:00
gen wip 2024-12-06 14:18:52 +01:00
java/plsql-antlr-parser wip 2024-12-06 14:18:52 +01:00
libs Fixed parsing issue with json_serialize 2025-02-23 09:38:20 +01:00
tools init 2023-11-02 01:59:19 +01:00
.gitattributes init 2023-11-02 01:59:19 +01:00
.gitignore wip 2024-11-30 16:51:54 +01:00
antlr.cpp improved parsing performance for apex 2025-01-14 07:31:56 +01:00
c_bindings.cpp added oracle 23ai features domain (wip) and basic mle (wip) 2025-02-08 23:24:56 +01:00
c_bindings.h native get identifiers 2024-12-20 01:00:21 +01:00
CMakeLists.txt cmakelist cleanup 2024-12-22 14:44:59 +01:00
example.sql wip 2024-11-30 16:51:54 +01:00
LICENSE.md init 2023-11-02 01:59:19 +01:00
md5.cpp wip 2024-11-24 15:36:47 +01:00
md5.h wip 2024-11-24 15:36:47 +01:00
PlSqlLexer.g4 Fixed parsing issue with json_serialize 2025-02-23 09:38:20 +01:00
PlSqlLexer.interp wip 2024-11-30 16:51:54 +01:00
PlSqlLexerMinimal.g4 wip 2024-12-04 14:38:03 +01:00
PlSqlParser.g4 Fixed parsing issue with json_serialize 2025-02-23 09:38:20 +01:00
PlSqlParserMinimal.g4 wip 2024-12-04 14:38:03 +01:00
README.md init 2023-11-02 01:59:19 +01:00

Getting started with ANTLR in C++

ANTLR is a great tool to quickly create parsers and help you in working with a known language or create your DSL. While the tool itself is written in Java it can also be used to generate parsers in several other languages, for instance Python, C#, Javascript, C++, etc.

This example shows how to parse a data format file with ANTLR in C++.

The project can run on Windows, Linux and Mac. To build it you need CMake installed on your system. On Windows you need a version of Visual Studio that include support for C++.

To solve many common issues with C++ building on different platforms this project is now based on the CMake script from the official ANTLR4 Cpp Runtime. This should deal with many typical issues in building a C++ projects on different setups and platforms. However, be warned that this will download the ANTLR C++ runtime from the official git repository and will build it. Therefore build time for the first build will be long.

# create a build directory to keep the main one clean
mkdir build
cd build
# to run CMake
cmake ../
# to build on Linux and Mac
make
# run the executable
./antlr4-tutorial
# to build and run on Windows
# open the "Antlr-cpp-tutorial.sln" file with Visual Studio generate by CMake inside the build directory
# build and run the project antlr-tutorial (do not select the auto-generated ALL_BUILD)

The CMake build script will also generate the ANTLR parser automatically. However, you may want to generate the parser manually during development with this command:

# generate the ANTLR components (you have to setup ANTLR in your system, before performing this step)
antlr4 -Dlanguage=Cpp -no-listener -visitor -o libs Scene.g4

You can read an article on the example on Getting started with ANTLR in C++