This project utilizes scala to lex and parse the WHILE language and then compiling the language into Java Byte Code using the Jasmin compiler.
This project will require to have ammonite installed on your machine. You can find the installation instructions here.
You will need to have the following installed on your machine:
- Scala 2.13.7 (NOT scala 3)
- Ammonite 2.4.0
- Jasmin Jar File (included in the repo)
- some WHILE programs (included in the repo, can write your own following the syntax :))
- Depending on your OS, you may need to change
beginning
prelude variable fromldc 10
for Linux/MacOS toldc 13
for Windows (this has been commented in the code incompiler.sc
)
To run the project directly from the command line, you can run the following commands:
amm compiler.sc run "WHILE_FILE_NAME.while"
To compile the WHILE program into a .j file, you can run the following commands:
amm compiler.sc main "WHILE_FILE_NAME.while"
You can then run the .j file using the Jasmin compiler:
java -jar jasmin.jar "WHILE_FILE_NAME.j"
To parse a WHILE program at command line, you can run the following commands:
amm parser.sc "WHILE_FILE_NAME.while"
To lex a WHILE program at command line, you can run the following commands:
amm lexer.sc "WHILE_FILE_NAME.while"