Thusly is a dynamic and general-purpose programming language implemented using four main and custom-built components:
- Tokenizer
- Parser
- Compiler
- Virtual machine
- The tokenizer generates tokens on demand which is controlled by the parser, by advancing through the source code character-by-character.
- It performs lexical analysis to ensure use of valid characters and sequence of characters, and hence also flags any lexical errors encountered.
- Details: tokenizer.md
- The parser and the compiler work in tandem to parse the tokens generated by the tokenizer and write the corresponding bytecode instructions in the correct order based on the precedence of the operators used.
- The parser performs syntactic analysis to ensure coherence with the specified grammar as well as static semantic analysis and variable resolution.
- All steps are performed in a single pass.
- Details: parser-compiler.md
- The VM evaluates expressions and executes statements by decoding and executing the instructions in the compiled program in a sequential order.
- It specifies the instruction format of the bytecode which the compiler must adhere to when writing the instructions.
- Details: vm.md
To get an understanding of the process and data flow from the first step of analyzing characters in the source code up until interpreting the statements, the recommended reading order is:
The main components contain walk-throughs of their respective steps using example source code.