evalit
A toy interpreter.
example
use ;
syntax
primitive type
null
boolean
true, false
integer
$-2{63}$ ~ $2{63}$
float
float number, f64.
string
string quote by "
variable
variable name is a string, start with _ or letter, and can contain letter, number, _.
let a;
let a = 1;
expression
1 + 2 * 3;
operator
| operator | description |
|---|---|
+ |
add |
- |
subtract |
* |
multiply |
/ |
divide |
% |
remainder |
== |
equal |
!= |
not equal |
< |
less than |
<= |
less than or equal |
> |
greater than |
>= |
greater than or equal |
&& |
and |
|| |
or |
! |
not |
= |
assign |
+= |
add assign |
-= |
subtract assign |
*= |
multiply assign |
/= |
divide assign |
%= |
remainder assign |
[] |
index |
. |
member |
() |
call |
.. |
range |
control flow
loop statement
loop to repeat.
loop
while statement
while to conditional repeat.
while condition
for statement
for to iterate.
for i in 0..=10
if statement
if to choose branch.
if condition else
break statement
break to exist loop.
continue statement
continue to finish one iterate.
return statement
return to return value.
fn item
user defined function