- D 100%
| examples | support passing multiple files to the interpreter + STD lib | |
| source | support passing multiple files to the interpreter + STD lib | |
| .gitignore | initial | |
| dub.json | add REPL | |
| dub.selections.json | fix pushing order | |
| LICENSE | initial | |
| README.md | add reading files | |
| std.nv | support passing multiple files to the interpreter + STD lib | |
ynova
Toy nova interpreter
Build
dub build
Module: core
Imported by default
|:: print $x|
Prints $x to stdout
|:: import $mod|
Imports module $mod
(Variable arity) @shell
Runs and prints the given tuple as a shell command
|:: exit|
Exits the program
|:: write $str|
Prints $str without a new line
|:: read $file to $stack|
Pushes the characters from the file $file in reverse to $stack
Module: math
Imported by default
|:@math: +|
Pops 2 integers from the @math stack, adds them, and pushes the result
|:@math: -|
Pops 2 integers from the @math stack, subtracts them, and pushes the result
|:@math: *|
Pops 2 integers from the @math stack, multiplies them, and pushes the result
|:@math: /|
Pops 2 integers from the @math stack, divides them, and pushes the result
|:@math: %|
Pops 2 integers from the @math stack, divies them and calculates the remainder, and
pushes the result
Module: build
|:: compile source $src to $obj|
Gets all source files using the wildcard $src and iterates through them. First,
it pushes the tuple finalise to the @build stack. Then, it pushes
this tuple to the @build stack:
$src to $obj
Where:
$srcis one of the source files found using the wildcard from the rule$objis the$objfrom the rule, but with the*replaced with the current source file with the extension removed
Example to compile a C project:
|:@build: $src to $obj|
:@shell: gcc $src -o $obj -c
|:@build: finalise|
:@shell: gcc bin/*.o -o main
||
:: import build
:: compile source source/*.c to bin/*.o
:@shell: mkdir -p bin
|:--: compile source $src to $obj|
The same as the rule above, except it uses multithreading. A task pool is used with
as many threads as available CPU cores. The interpreter creates a copy of itself
for every source file, and in each copy a version of the :@build: $src to $obj tuple
is pushed. These interpreter copies run until their version of the program exits.
Module: graphics
|:: create $w x $h window named $title|
|:: close window|
|:: use colour $r $g $b|
|:: clear window|
|:: render window|
|:: fetch events|
Pushes :@events: quit if the window is closing