Home /Modules/compiler/README.md

README.md

lib/compiler/examples/Mid/README.md · 25 line(s) · markdown

<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

  1. Lexer emits token kinds, lexemes, and source spans.
  2. Parser builds an expression tree using precedence-aware parsing (or Pratt parsing).
  3. IR represents constants, local reads/writes, arithmetic, and print operations.
  4. Semantic checks reject unknown identifiers and malformed expressions.
  5. 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