Fixed bug in parser; perhaps we need to scrap Ostap and go back to Yacc

This commit is contained in:
Dmitry Boulytchev 2019-12-26 20:02:30 +03:00
parent 59a7d48568
commit f4467ec540
2 changed files with 37 additions and 9 deletions

View file

@ -59,7 +59,7 @@ fun insert (m, k, v) {
esac
}
return inner (m, k, v).snd
return m.inner (k, v).snd
}
fun find (m, k) {
@ -110,15 +110,32 @@ fun validate (t) {
fi
esac
}
inner (t, fun (x) {return true})
}
local tree = {}, i;
for i := 1, i <= 100, i := i+1 do
for i := 100, i >= 1, i := i-1 do
validate (tree);
tree := insert (tree, i, i);
printf ("Inserting: %s\n", i.string);
printf ("Result : %s\n", tree.string)
od
od;
tree := {};
for i := 1, i <= 100, i := i+2 do
validate (tree);
tree := insert (tree, i, i);
printf ("Inserting: %s\n", i.string);
printf ("Result : %s\n", tree.string)
od;
for i := 2, i <= 100, i := i+2 do
validate (tree);
tree := insert (tree, i, i);
printf ("Inserting: %s\n", i.string);
printf ("Result : %s\n", tree.string)
od