keen/parse
Sourcegrammar[t] recordparse[t] t(a t grammar, text string)Match a string against a grammar. The whole string must match the grammar. If the string has leading or trailing spaces you must use a grammar that includes those. Throws a
parse-error on failure.inner-parse-error record~~[t, u] (t, u) grammar(a t grammar, b u grammar)Expects to parse
a followed by b. By default this does not allow spaces in between. For that, use a ~~ spaces ~~ b./[t] t grammar(a t grammar, b t grammar)Tries to parse with
a, and if that fails, tries to parse with b instead.transform[output, input] output grammar(a input grammar, f output data(input))Uses a function to transform the result if parsing is successful.
optional[t] t option grammar(a t grammar)Allows parsing to fail, returning an empty option if it does.
many[t] t[] grammar(a t grammar)Parses the same grammar as many times as possible (including 0 times).
separated-by[t] t[] grammar(a t grammar, separator string)Parses a as many times as possible, with 'separator' in between.
This does not allow a trailing separator; it is a parse error to have a separator not followed by another a. This does allow to parse nothing, returning an empty array.
lazy record (has private fields)Use this to allow recursive grammars.
tvalue. Use the functions in this module to build a grammar.