Simple programming language's compiler for .NET Core platform which uses Lex, Yacc and Roslyn
The main project is MyCompiler
, it is a project of my language's compiler. Roslyn
is the submodule which contains modified Microsoft.CodeAnalysis.CSharp
project.
Long-time option (because of too many commits in submodule's history)
$ git clone https://github.com/nikitaodnorob/pl-compiler.git --recursive
Fast option (doesn't load all history)
$ git clone https://github.com/nikitaodnorob/pl-compiler.git --depth 1
$ cd pl-compiler
$ git submodule update --init --depth 1 Roslyn
- Open solution
Roslyn/Compilers.sln
and build projectMicrosoft.CodeAnalysis.CSharp
- If you need, change file
MyCompiler/config/lex.lex
(it is lexer's file) orMyCompiler/config/yacc.y
(it is Yacc's file with language's grammar) - Run
MyCompiler/config/generate.bat
for generating code of lexer and parser - It will generate files
Lexer.cs
andParser.cs
in folderMyCompiler/GeneratedParser/
. These files have to be recompiled after any change of fileslex.lex
oryacc.y
- Generated files has already been added to project
MyCompiler
. The project is ready for build! - Build project
MyCompiler
The MyCompiler.exe
is located in MyCompiler/bin/Debug/netcoreapp3.1
Some language examples are located in MyCompiler/examples
$ cd MyCompiler/bin/Debug/netcoreapp3.1/
$ MyCompiler.exe ../../../examples/tuples.mylang tuples.exe
$ dotnet tuples.exe
1
2
3
4
Unpacking array to variables
50
100
150
200
- OS Windows (for
gppg
launching; later the compiled parser will be uploaded to repository) - Installed .NET Core version 3.1 or above