Interpreter for the VL language
v.0.3alpha
Latest Rust Stable
Build with cargo build --release
Then run using vl binary in ./targets/release
e.g.
-
vl sourcefile
-
vl -s 'source string'
-
vl -r (repl mode)
In source string mode (-s) when a ' is wanted in the string you must replace it with: ''' (thanks bash)
(repl mode can currently only evaluate single line statements at a time)
see examples folder for source code examples
Some more examples:
Tests! Make use of rusts easy convenient test ability.String manipulation.- Basic File IO.
Commands:
w
(repeatable) Puts <value> to stdout
W
(repeatable) Puts <int> to stdout
l
(repeatable) Puts <value> to stdout new line version
L
(repeatable) Puts <int> to stdout new line version
e
Assigns stdin to <value>
'
Set <pointer> to character following ' and <index> to 0
`
(resets int) Set <pointer> to character following ` and <index> to <int>
]
(loopable) Increase <pointer> to next mark (a -> b -> c etc)
[
(loopable) Decrease <pointer> to previous mark
}
(loopable) Increase <index>
{
(loopable) Decrease <index>
y
(repeatable) Copies current selected memory value into <value>
Y
(repeatable) Copies current selected memory value into <int>
p
(repeatable) Copies <value> into currently selected memory
P
(repeatable) Copies <int> into currently selected memory
i
(repeatable) Enter insert mode, insert characters following i up until unescaped ('') ';' into <value> and currently selected memory
I
(repeatable) Enter insert mode, insert characters following i up until unescaped ('') ';' into <int> and currently selected memory
;
(insert mode only) Escape insert mode setting
\
(insert mode only) Treat next ; as normal part of string
a
(loopable, repeatable) Increment currently selected memory value by 1 if Integer type and set <value>
x
(loopable, repeatable) Decrement currently selected memory value by 1 if Integer type and set <value>
v
Copy <int> to <value>
V
Copy <value> to <int>
@
Copy length of string held in <value> into <int>
=
Convert <value> from string to int or int to string
+
(resets int) Set <value> to <value> + <int>
-
(resets int) Set <value> to <value> - <int>
*
(resets int) Set <value> to <value> * <int>
/
Set <value> to <value> / <int> and set <int> to <value> % <int>
Divide is unique in that it sets the internal <int> register and the <value> register
+
Set <value> to concatination of <value> + <int>
-
Splits string in <value> at point <int> setting <value> first part and <int> to second part
*
Flatten the current mark if all set values in mark are strings into <value> with placing a separator between each defined in <int>, or "" if <int> is not a string
/
Explode string in <value> splitting on the string in <int> or "" if <int> is not a string
^
Jump to beginning of current line
j
(loopable) Jump <int> lines down
k
(loopable) Jump <int> lines up
f
(loopable) Jump to <int>th next instance of character following f
F
(loopable) Jump to <int>th previous instance of character following F
?
(resets int) Do following jump only if <value> == <int>
!
(resets int) Do following jump only if <value> != <int>
<
(resets int) Do following jump only if <value> > <int>
>
(resets int) Do following jump only if <value> < <int>
(
Begin group
)
End group
.
(loopable) Repeat the previous (repeatable) command
$
Comment, anything between $ pairs is ignored, must always be in pairs
Groups are treated as isolated code segments, memory and registers carry through from and over to the outside code, but program flow cannot jump out from a group until the end.
Groups are (loopable) and so performed <int> times.
<int> can be set directly by an integer i.e.
10(aw)
This sets <int> to 10 then performs the following (loopable) function ten times, in this case the group (aw)
resulting in the numbers 1 to 10 being outputted.
<int> is 1 by default and reset to 1 after (loopable) and (resets int) commands, preserved otherwise.
Programs can access 26 'marks', named a to z by setting the pointer i.e. 'a
Each mark is an array which can hold Strings, Integers, or Characters
'b}}}yw
This is one way of outputting b[3].
Values are 0 by default and <pointer><index> points to a[0] by default