DM565 - Formal Languages and Data Processing
 
Fall 2023
Kim Skak Larsen

Home Innovation

SCIL
SCIL is an acronym for "A Simple Compiler in a Learning Environment".

The goal is to illustrate important compiler techniques in a simple setting and to enable students to make minor adjustments and extensions. The source language is a simple imperative language with integers being the only type, but including expressions, assignments, control structures, and function definitions and calls, including recursion and static nested scope. The target language is 64 bit X86 Assembly/GAS Syntax. The compiler is written in python3, developed using Python 3.6.7, but latest checked with Python 3.10.6, along with the ply package version 3.11 and singleton-decorator package version 1.0.0. The packages can be installed via pip3. Attempts were made to follow the PEP 8 style guide for python code.

Newest Release

Version 1.2.3[2023-06-30]:scil_v_1.2.3.zip

Overview of updates

Credits

The compiler was developed by Kim Skak Larsen. Credits below are for helpful discussions and bug fixes or discoveries.

2023-06-30: The code has been updated to reflect changes in Python versions and in the Python community since the first development in 2018. This includes using dataclass and singleton decorators and replacing longer elif-sequences by match-case constructions for readability.

2023-06-01: Until now, the semantics of integer values treated as Booleans has been undefined, but now the (relative) standard interpretation of treating non-zero as true has been adopted.

2023-04-05: Kian Banke Larsen - noticing an illogical order of function epilogue and callee-save restore; it didn't cause any problem because the number of callee-save registers are set to zero.

2023-03-03: Jonas Stisen - suggesting a more elegant way to handle the 16 byte alignment problem when calling C's printf. The interpreter was updated to reflect the use of more instructions.

2022-01-26: Lasse Usbeck Andresen, Frederik Gram Kortegaard - discovering one line of dead code, which lead to the discovery of a few more things that could be cleaned up. The update does not imply any observable change in the compiler execution.

2021-10-08: Mathias Winther Romerlund Rasmussen - offered to very quickly test a collection of emit files to see which of the mac-changes discussed below were acceptable on WSL2 - just to be absolutely certain, given that I don't own a windows computer myself.

2021-10-01: Valentino Picotti - finding the issues, preventing the generated assembly from running on macOS, which included minor syntactical issues, differences wrt. position-independent code, and the 16 byte alignment problem. I couldn't very easily find these myself, given that I don't own a mac.

2020-10-20: Robert Reine Rasmussen - detecting obsolete code which was removed and grammatical constructions using sequences of all sorts are now referred to as lists for consistency; also noticed that the prettyprinter had not been finished completely - now prettyprinted code should compile to exactly the same executable code as the original.

2020-10-02: Tobias Thornfeldt Nissen - detecting obsolete code related to the initialization of the current scope symbol table; harmless, but nice to get rid of it.

2020-09-23: A more careful investigation revealed that also integer division was missing from the interpreter. It has been extended; again no changes to the compiler.

2020-09-21: Mikkel Pilegaard - bug discovery: Not in the compiler, but the interpreter failed on some programs. Fixed: some opcodes for conditional jumps were missing in the interpreter. Additionally, crashes on real assembler was experienced on Windows using WSL 1. I think the conclusion is simply that one cannot rely on WSL 1 at the machine code level. Use the interpreter if you're experiencing this and not runnning either linux or WSL 2.

2020-03-06: Alexander Køllund Nissen, Frederik Vogt Bolding, Jacob Vesti Moeslund Nielsen - detecting unnecessary and (therefore) confusing code in the type checking phase; harmless, but nice to get rid of it.

2020-01-10: Alexander Køllund Nissen - detecting unnecessary and (therefore) confusing code in two locations; currently harmless, but nice to get rid of it.

2019-11-20: Nikolai Nøjgaard - bug discovery: the code inserted for the 16 byte alignment seems to be at an incorrect location. Fixed: For some reason, this problem does not seem to occur often on linux, so it passed all the tests. A more complicated solution has been implemented to tidy up on the stack correctly after a call to printf.

2019-10-24: Frederik Vogt Bolding - reporting that \r is treated as an illegal character. This doesn't matter on Linux or in WSL, if you edit inside WSL, but if you edit outside WSL, you get an error. Fixed: The scanner has been updated so it likes windows users better now.

2019-09-26: Erik Andersen - suggested fix in test script to accommodate file names containing spaces, suggested layout improvements to fix PEP 8 style guide violations.

2019-08-02: Jakob Lykke Andersen - helpful discussions on the 16 byte alignment problem.

2019-07-23: Mikkel Pilegaard - bug discovery: The compiler crashes if it scans a unicode (non-ascii) symbol. Fixed: Unicode characters were not allowed, but it is still preferable that the compiler does not crash no matter what, and an appropriate test has been inserted.

2019-07-23: Mikkel Pilegaard - bug discovery and fix: Missing check for the identifier in a function call having been declared as a function.

2019-01-03: Jakob Lykke Andersen - helpful discussions on programming style and the use of visitor patterns.

Older Releases

Version 1.2.2[2023-06-01]:scil_v_1.2.2.zip
Version 1.2.1[2022-01-29]:scil_v_1.2.1.zip
Version 1.2[2021-10-11]:scil_v_1.2.zip
Version 1.1.5[2020-11-06]:scil_v_1.1.5.zip
Version 1.1.4[2020-10-21]:scil_v_1.1.4.zip
Version 1.1.3[2020-10-02]:scil_v_1.1.3.zip
Version 1.1.2[2020-09-23]:scil_v_1.1.2.zip
Version 1.1.1[2020-09-21]:scil_v_1.1.1.zip
Version 1.1[2020-06-26]:scil_v_1.1.zip
Version 1.0.5[2020-01-11]:scil_v_1.0.5.zip
Version 1.0.4[2019-11-21]:scil_v_1.0.4.zip
Version 1.0.3[2019-10-25]:scil_v_1.0.3.zip
Version 1.0.2[2019-10-11]:scil_v_1.0.2.zip
Version 1.0.1[2019-09-26]:scil_v_1.0.1.zip
Version 1.0[2019-09-17]:scil_v_1.0.zip
Version 0.9[2019-09-01]:scil_v_0.9.zip

 


   Data protection at SDUDatabeskyttelse på SDU