For Instructors¶
SLangCC exposes the major stages of a small native compiler and includes focused benchmark suites for lexer, parser, semantic, IR, code-generation, and integration behavior.
Suggested progression¶
| Module | Repository evidence |
|---|---|
| Lexical analysis | lexer/lexer.l and benchmark/lexer/ |
| Parsing and ASTs | parser/parser.y, parser/AST.md, and benchmark/parser/ |
| Names and types | semantic_analyzer/ and benchmark/semantic/ |
| Intermediate representation | SLangIR/ and benchmark/slangir/ |
| Native code generation | codegen/ and benchmark/codegen/ |
| End-to-end compilation | driver/, slangcc.cpp, and integration programs |
Compiler-stage artifacts¶
Students can preserve every major representation without modifying the compiler:
./slangcc lesson.sl \
--ast-dump \
--ast-semantic-dump \
--ir-dump \
--asm-dump
This makes it practical to compare source constructs with the parser AST, semantic annotations, SLangIR, and x86-64 assembly.
Exercise ideas¶
- classify examples as lexer, parser, or semantic failures;
- compare ASTs before and after semantic analysis;
- trace a typed expression through SLangIR;
- explain the labels and branches generated for loops;
- compare iterative and recursive Fibonacci programs;
- extend one stage and add matching legal and illegal tests.
Reproducibility¶
Specify the exact SLangCC release or repository revision used by a course. The current prebuilt release is v0.1.0. Generated programs require x86-64 Linux plus GCC or Clang.