Internals

This page contains a sketch of the SMOL implementation internals.

Parsing and Typechecking Program Flow

flowchart TB input([ `-i` argument or REPL `read` command]) antlr[[WhileParser.program]] translate[[Translate.generateStatic]] typecheck[TypeChecker] interpret[Interpreter] click antlr "https://github.com/smolang/SemanticObjects/blob/master/src/main/antlr/While.g4" _blank click translate "https://github.com/smolang/SemanticObjects/blob/master/src/main/kotlin/no/uio/microobject/ast/Translate.kt" _blank click interpret "https://github.com/smolang/SemanticObjects/blob/master/src/main/kotlin/no/uio/microobject/runtime/Interpreter.kt" _blank click typecheck "https://github.com/smolang/SemanticObjects/blob/master/src/main/kotlin/no/uio/microobject/type/TypeChecker.kt" _blank input-- smol filename -->antlr subgraph REPL.initInterpreter direction TB antlr -- antlr tree -->translate antlr -- antlr tree -->typecheck translate -- StaticTable -->interpret translate -- StaticTable -->typecheck end

The program flow of smol program text inside REPL.initInterpreter

Statement Execution

Executing a smol program is controlled by the REPL class. An Interpreter object keeps track of the execution state, which consists of a stack of StackEntry objects and a GlobalMemory instance, which in turn maps object names to their Memory.

A single statement is executed by the method Interpreter.makeStep.