From 15429e67dc885638b9084e6db780b4f2cbe0c9cb Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 1 Jan 2022 14:57:49 +0100 Subject: [PATCH] ARCHITECTURE.md --- ARCHITECTURE.md | 26 ++++++++++++++++++++++++++ src/compile.rs | 3 --- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 ARCHITECTURE.md diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..6f5ce7f --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,26 @@ +# The interpreter consists of several stages +* Lexing +* Parsing +* Compiling +* Interpreting (+GC) + +# Lexer +The lexer is handwritten and implemented as an Iterator. Lexing errors are passed on using +`Error` tokens. The lexer already allocates identifiers and string literals into the GC. + +# Parser +The parser is handwritten using recursive descent. It calls the `next` method on the lexer to get the next token, +but the iterator could be any Iterator and doesn't have to be a lexer. + +The AST is allocated using a bump-allocator with the lifetime `'ast`. + +# Compiler +The compiler takes the AST and compiles it down to bytecode. The full instruction set my change and can be found in the code. + +The bytecode is allocated using a bump-allocator with the lifetime `'bc` + +# Interpreter (VM) +The VM executes the bytecode. It uses the GC for its allocations. + +# GC +The garbage-collector is work-in-progress. \ No newline at end of file diff --git a/src/compile.rs b/src/compile.rs index 4dd614b..807d54f 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -356,6 +356,3 @@ enum StackChange { None = 0, Grow = 1, } - -#[cfg(test)] -mod test {}