From 4c8178e05c427ab6d443f605e3e38cfcc635c817 Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Sat, 21 Aug 2021 15:12:27 +0200 Subject: [PATCH] Added note on syntax and inspiration. Improved title --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2320092..9a88e21 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NimVM +# NimVM - A stack-based bytecode virtual machine written in Nim A basic programming language written in Nim ## Project structure @@ -11,14 +11,14 @@ The project is split into several directories and submodules: ## Language design NimVM is a generic stack-based bytecode VM implementation, meaning that source files are compiled into an -imaginary instruction set for which we implemented all the required operations in a virtual machine. NimVM -uses a triple-pass compiler where the input is first tokenized, then parsed into an AST and finally optimized -before being translated to bytecode. +imaginary instruction set for which all required operations are implemented in a virtual machine. NimVM +uses a triple-pass compiler where the input is first tokenized and parsed into an AST, then optimized and +eventually translated to bytecode. The compilation toolchain has been designed as follows: - First, the input is tokenized. This process aims to break down the source input into a sequence of easier to process tokens for the next step. The lexer (or tokenizer) detects basic syntax errors like unterminated - string literals and multi-line comments and invalid usage of unknown tokens (for example UTF-8 runes) + string literals and invalid usage of unknown tokens (for example UTF-8 runes) - Then, the tokens are fed into a parser. The parser recursively traverses the list of tokens coming from the lexer and builds a higher-level structure called an Abstract Syntax Tree-- or AST for short-- and also catches the rest of static or syntax errors such as illegal statement usage (for example return outside a function), malformed expressions @@ -34,3 +34,11 @@ The compilation toolchain has been designed as follows: - Once the optimizater is done, the compiler takes the AST and compiles it to bytecode for it to be later interpreted by our virtual machine implementation + +## Language syntax + +NimVM uses a syntax mostly inspired from C and Java, although some influences come from Python as well. + +## Credits + +NimVM was inspired by Bob Nystrom's amazing [Crafting Interpreters](https://craftinginterpreters.com) book