mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 14:58:50 +00:00
Continue massaging Ostap
This commit is contained in:
parent
848fd31dc4
commit
b4ba38a0f7
8 changed files with 84 additions and 31 deletions
20
stdlib/regression/test12.expr
Normal file
20
stdlib/regression/test12.expr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import Ostap;
|
||||
import Expr;
|
||||
import Fun;
|
||||
|
||||
fun gen (depth) {
|
||||
if depth == 0
|
||||
then "a"
|
||||
else gen (depth-1) ++ "*" ++ gen (depth-1)
|
||||
fi
|
||||
}
|
||||
|
||||
local a = token ("a"),
|
||||
add = [token ("+"), fun (l, r) {Add (l, r)}],
|
||||
sub = [token ("-"), fun (l, r) {Sub (l, r)}],
|
||||
mul = [token ("*"), fun (l, r) {Mul (l, r)}],
|
||||
div = [token ("/"), fun (l, r) {Div (l, r)}],
|
||||
exp = expr ({[left, {add, sub}], [left, {mul, div}]}, a) (id),
|
||||
i;
|
||||
|
||||
printf ("%s\n", parseString (exp |> bypass (eof), gen (10)).string)
|
||||
Loading…
Add table
Add a link
Reference in a new issue