Mavka language parser written in ANTLR4 and C++.
Clone the repository:
git clone https://github.com/mavka-ukr/parser
Using:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.26)
project(mavka)
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(parser)
add_executable(mavka main.cpp)
target_link_libraries(mavka mavka_parser)
target_compile_options(mavka PRIVATE -fexceptions)
set_target_properties(mavka PROPERTIES OUTPUT_NAME "мавка")
// main.cpp
#include <iostream>
#include "parser/parser.h"
int main() {
const auto code = "друк(2 + 2)";
const auto parser_result = mavka::parser::parse(code, "тест.м");
if (parser_result.errors) {
std::cout << "Error: " << parser_result.errors[0]->message << std::endl;
return 1;
}
std::cout << "Success!" << std::endl;
return 0;
}
Note that ANTLR4 can throw exceptions
mkdir build
cd build
cmake ..
make
./мавка
Requirements:
- Clang
- CMake
- Make
- Java 8+
Installation:
git clone https://github.com/mavka-ukr/parser
cd parser
Generating ANTLR4 files:
bash generate.sh
Building:
mkdir build
cd build
cmake ..
make