(parse "abcd" (assert-iso (at (match letter)) #\a) (assert-iso parsepos* '(#\a #\b #\c #\d))) (ptest "ab123" (do (next) (try x (n-of 2 (match letter)) 'didnt-expect-success parsepos*)) '(#\b #\1 #\2 #\3)) (ptest "greetings" (mliteral "xyz") '<>) (ptest "greetings" (mliteral "greet") "greet") (ptest "greetings" (list (mliteral "greet") (mliteral "ings")) '("greet" "ings")) (ptest "greetings" (list (mliteral "greetx") (mliteral "ings")) '<>) (ptest "greetings" (list (mliteral "greet") (mliteral "xings")) '<>) (ptest "greetings" (alt) '<>) (ptest "greeting" (alt (mliteral "greet")) "greet") (ptest "greetings" (alt (mliteral "greet") (mliteral "foo")) "greet") (ptest "greetings" (alt (mliteral "foo") (mliteral "greet")) "greet") (ptest "greetings" (alt (mliteral "foo") (mliteral "bar") (mliteral "greet")) "greet") (ptest "greetings" (list (mliteral "greet") (optional (mliteral "ings"))) '("greet" "ings")) (ptest "greetings" (list (mliteral "greet") (optional (mliteral "xyz"))) '("greet" nil)) (ptest "ghi" (mliteral-in "abc" "def" "ghi") "ghi") (ptest "xxxyz" (many (mliteral "x")) '("x" "x" "x")) (ptest "xxxyz" (list (many (mliteral "x")) (mliteral "y")) '(("x" "x" "x") "y")) (ptest "yzzz" (list (many (mliteral "x")) (mliteral "y")) '(nil "y")) (ptest "xxxyzzz" (list (many1 (mliteral "x")) (mliteral "y")) '(("x" "x" "x") "y")) (ptest "yzzz" (list (many1 (mliteral "x")) (mliteral "y")) '<>) (ptest-err "xyzzy" (must "want cookie!" (mliteral "cookie")) "want cookie!") (ptest "abc" (match #\a) #\a) (ptest "abc" (match #\x) '<>) (ptest "abc" (match alphadig) '#\a) (ptest "#bc" (match alphadig) '<>) (ptest "" (match (fn (x) t)) '<>) (ptest '(1 2 3) (munch [+ _ 10]) 11) (ptest '() (munch [+ _ 10]) '<>) (ptest "a,b,c" (parse-intersperse (match #\,) (match alphadig) "comma must be followed by alphadig") '(#\a #\b #\c)) (ptest " abc" (do (skipwhite) (match #\a)) #\a) (ptest-err "a ,b ,c" (comma-separated (match #\a) "comma must be followed by 'a'") "comma must be followed by 'a'") (ptest "a ,b ,c" (comma-separated (match alphadig) "comma must be followed by alphadig") '(#\a #\b #\c)) (ptest "abc" (entire (mliteral "abc")) "abc") (ptest "abc" (entire (mliteral "ab")) '<>) (ptest "abcd" (matched-input (match #\a) (match #\b) (match #\c)) '(#\a #\b #\c)) (def good () (mliteral "green")) (ptest "green" (good) "green") (alt-extend good () (mliteral "blue")) (ptest "green" (good) "green") (ptest "blue" (good) "blue") (def good (n) (n-of n (mliteral "g"))) (ptest "ggggg" (good 3) '("g" "g" "g")) (alt-extend good (n) (mliteral (string n))) (ptest "ggggg" (good 3) '("g" "g" "g")) (ptest "3gggg" (good 3) "3") (ptest "abc" (do (mliteral "ab") (not (match #\!)) (mliteral "c")) "c") (ptest "ab" (do (mliteral "ab") (not (match #\!))) t) (ptest "ab!c" (do (mliteral "ab") (not (match #\!))) '<>) (ptests (upto 3 (match #\a)) "b" '() "ab" '(#\a) "aaab" '(#\a #\a #\a) "aaaab" '(#\a #\a #\a) ) (ptests (from1upto 3 (match #\a)) "" '<> "b" '<> "ab" '(#\a) "aaab" '(#\a #\a #\a) "aaaab" '(#\a #\a #\a) )