Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 1.73 KB

File metadata and controls

76 lines (57 loc) · 1.73 KB

NCCompiler_CompilersCourse

This is compiler for toy language NCC.

routine main() is
  var a is [1, 2, 3]
  print(a)
end

How to run

  1. Clone repository
git clone https://github.com/IlnurHA/NCCompiler_CompilersCourse.git

1.5 Installing ILASM

cd NCCompiler_CompilersCourse
dotnet add package ILAsm --version 4.700.2
cd ..
  1. Installing GPPG

Clonning GPPG repository: https://github.com/k-john-gough/gppg

git clone https://github.com/k-john-gough/gppg.git

Building using dotnet: https://dotnet.microsoft.com/en-us/)https://dotnet.microsoft.com/en-us/

cd gppg
dotnet build --output .\GPPG_build
cp .\GPPG_build\Gppg.exe ..\NCCompiler_CompilersCourse
  1. Generating code from GPPG

Execute command inside root folder of NCCompiler project

.\Gppg.exe /nolines /conflicts ./Parser/Parser.y > ./Parser/ParserGenerated.cs
  1. Building Compiler and compiling program Inside root folder of NCCompiler project
dotnet build --output .\compiler_build
cd compiler_build
.\NCCompiler_CompilersCourse.exe

You will execute Compiler. Next you need to specify path to the program. Then it will generate compiledProgram.il in the current directory.

  1. Transform to exe file using ilasm
ilasm \exe .\compiledProgram.il

Then you can execute program using binary compiledProgram.exe

P.S. You can usually find ilasm using the following path (in Windows):

C:\Users<user_name>.nuget\packages\microsoft.netcore.ilasm<dotnet_version>\runtimes\native
or C:\Users<user_name>.nuget\packages\ilasm\4.700.2\bin\Win.x64 (or Win.x32)

So, the command above could be:

C:\Users\<user_name>\.nuget\packages\ilasm\4.700.2\bin\Win.x64\ilasm.exe /exe .\compiledProgram.il