This will be a toy language interpreter using the tree walk approach on a generated AST. Also, this is a work in progress project for educational fun only. Feel free to fork this.
- Paradigm(s):
- Imperative
- Dynamic Scoping
- Type System:
- NO "undefined" values for null safety.
- Variable types are inferred.
- Mismatched types for an operator causes runtime errors
- Variables can be mutable or not
- Booleans are written as
$T
and$F
!
- Syntax uses similar C-like operators:
- Example 1: logical operators are
&&, ||
. - Example 2: comparison operators are
==, !=, <, <=, >, >=
- Example 3: math operators are
, -, *, /, =, -=
- Example 1: logical operators are
- Syntax disallows control flow statements outside of function declarations to discourage messy code.
module
: Declares a module (a separate procedure group) by name.use
: Includes a module into a script. Specifically, the names of other procedures and constants become visible.let
: Declares a mutable variable.const
: Declares a deeply immutable variable. Lists will be immutable for now!set
: Tells Rubel that we're reassigning a variable. Fails onconst
valued variables during runtime!proc
: Declares a procedure.if
: Executes a block of statements if its conditional is true.otherwise
: Executes a block of statements if the lastif
failed.while
: Executes a block of statements as long as the conditional is true.end
: Marks the end of a block.- return: Returns a value from an expression in a procedure.
- See
tests
to get a sense of Rubel's syntax. I will add more tests later as I continue Rubel.
Make parser andvartypes.h
structures.
- Later add logical expressions.
Make interpreter: create scopes as HashTable using bucket list, native function API, and evaluator.- Test sample scripts!
- Refactor and test code even more?
- Add full support for modules: same names across modules should not conflict.
- Implement
copy_list_obj
to avoid accidental null values when list literals are passed into function arguments...funcargs_destroy
calls will free any value through their pointer rather than by value.