Skip to content

mikhirurg/SPLCompiler

Repository files navigation

SPLCompiler

Project description

This is a study project created for the "Compiler Construction" course at Radboud University Nijmegen. The project includes the complete compiler of the "Simple Programming Language" code to the "Simple Stack Machine" assembly.

The compiler has the code processing stages, including:

Installation guide

The project requires Java version 25.

There are a few different ways a user can obtain the jar file to execute the project:

  • The latest stable version of the project is available in the Releases section of the repository
  • The user can build the executable jar from sources by using gradlew

After obtaining the executable jar, the user can just run the following command:

java -jar build/libs/SPLCompiler-1.0-SNAPSHOT.jar

How to use the project

To run the project, the user needs to specify the path to the SPL source file as a first argument and the output path for the SSM assembly as the second argument:

java -jar build/libs/SPLCompiler-1.0-SNAPSHOT.jar test_programs/demos/game_of_life.spl out.ssm

There exist multiple compiler options:

Option Description

--arc

This option enables the Automatic Reference Counting garbage collection assembly injections.

--verb

This option runs the compiler in verbatim mode and shows the code transformations during the intermediate compilation stages.

One can execute the generated assembly using the Simple Stack Machine interpreter:

java -jar ssm.jar --file out.ssm --cli

Examples

$ java -jar build/libs/SPLCompiler-1.0-SNAPSHOT.jar test_programs/demos/game_of_life.spl out.ssm
$ java -jar ssm.jar --file out.ssm --cli
+-----+
|.*...|
|..*..|
|***..|
|.....|
|.....|
+-----+
01234
+-----+
|.....|
|*.*..|
|.**..|
|.*...|
|.....|
+-----+
01234
+-----+
|.....|
|..*..|
|*.*..|
|.**..|
|.....|
+-----+
01234

About

Simple Programming Language (SPL) compiler to the Simple Stack Machine (SSM)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors