<img align="right" src="https://github.com/mearvk/SLeeLa/blob/master/images/debian/debian-logo.png" width="75" height="75" alt="SLeeLa">
Mid — ExpressionCompiler
Goal: build a conventional front end for a small expression language.
Example subset: let total = 12 + 3 * 4; print total;. Support integer literals, identifiers, parentheses, unary minus, multiplication/division, addition/subtraction, let, and print. Do not claim full SLeeLa language coverage.
Pipeline
- Lexer emits token kinds, lexemes, and source spans.
- Parser builds an expression tree using precedence-aware parsing (or Pratt parsing).
- IR represents constants, local reads/writes, arithmetic, and print operations.
- Semantic checks reject unknown identifiers and malformed expressions.
- Emitter serializes normalized IR deterministically; it does not execute the source.
See ExpressionCompiler.sleela, a coordinator scaffold to extend with token and syntax-tree types supported by the current compiler.
Tests
2 + 3 * 4parses as addition with multiplication on the right.(2 + 3) * 4parses with addition inside parentheses.- Unknown variables and missing parentheses produce source-located errors.
- Identical source and configuration produce identical normalized IR.
- Any phase failure blocks emission.