lama_byterun/stdlib/regression/test10.lama
Dmitry Boulytchev eeddb0b25a eta in test
2021-01-12 01:14:18 +03:00

19 lines
No EOL
492 B
Text

import Ostap;
import List;
import Fun;
fun many (a) {
memo (
eta (
empty @ lift({})
| many (a) |> fun (as) {a @ fun (x) {as +++ singleton (x)}}
)
)
}
local a = token ("a"), b = token ("b");
local bad_alter = a | a |> fun (x) {b @ fun (y) {x ++ y}};
--logOn ();
printf ("Parsing ""aaa"" with many ... %s\n", parseString (many (a) |> bypass (eof), "aaa").string);
printf ("Parsing ""ab"" with bad_alter ... %s\n", parseString (bad_alter |> bypass (eof), "ab").string)