Simple C++ like compiler using Bison/Flex
We use C++ 17, Bison >= 3.0 because we use it to generate C++ files and use C++ variants instead of %union
- C++ like syntax
- Used modern C++ features
- Support functions, if conditions, loops, etc.
- Support multiple operators as
+
,-
,*
,/
,++
,--
,** (exp)
,and
,or
,not
,&&
,||
,!
,==
,!=
,<
,>
,<=
,>=
,<<
,>>
- Expressive Warnings, and Errors
- Warning on not used variables, functions, etc.
- Warning on not initialized variables.
- Simple GUI Text Editor
You can find precompiled binaries (CLI, GUI) for Linux and Windows in the releases
- Cmake >= 3.0
- C++ compiler
- Bison >= 3.0
- Flex
-
Ubuntu:
sudo apt-get update sudo apt-get install build-essential bison flex cmake gcc g++
-
Windows:
- CMake
- C++ Compiler: You can use Visual Studio or mingw-w64
- You can get new version of bison from here, extract the zip, and add the directory to the
PATH
environment variable - if your are using chocolatey package manager, install bison/flex using
choco install winflexbison3
- Ubuntu:
mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release --clean-first
You will find executable called CppCompiler
inside build
directory
Generated C++ grammar files inside build/src/grammar/
directory
- Windows:
-
Using Visual Studio:
mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 cmake --build . --config Release --clean-first
Visual Studio it is the default generator for windows, (i.e you can remove
-G "Visual Studio 17 2022"
and cmake will choose the installed version) but you can select a specific version:- "Visual Studio 11 2012"
- "Visual Studio 14 2015"
- "Visual Studio 15 2017"
- "Visual Studio 16 2019"
- "Visual Studio 17 2022"
You will find executable called
CppCompiler.exe
insidebuild/Release/
directoryGenerated C++ grammar files inside
build/src/grammar/
directory -
Using Mingw-w64:
mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -G "Mingw-w64 GCC 8" cmake --build . --config Release --clean-first
You will find executable called
CppCompiler.exe
insidebuild
directoryGenerated C++ grammar files inside
build/src/grammar/
directory
-
The program takes one argument of the file to compile
If no arguments are given, the program reads from standard input, saves output to out.txt
and saves symbol table to symbols.txt
Example:
- Ubuntu
CppCompiler test.txt out.txt symbols.txt
- Windows
CppCompiler.exe test.txt out.txt symbols.txt