Liking cljdoc? Tell your friends :D

strojure.parsesso.expr

Parser combinators for expressions.

Parser combinators for expressions.
raw docstring

*chain-leftclj/s

(*chain-left p op x)

Parses zero or more occurrences of p, separated by op. Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. If there are zero occurrences of p, the value x is returned.

Parses _zero_ or more occurrences of `p`, separated by `op`. Returns a value
obtained by a _left_ associative application of all functions returned by `op`
to the values returned by `p`. If there are zero occurrences of `p`, the value
`x` is returned.
sourceraw docstring

*chain-rightclj/s

(*chain-right p op x)

Parses zero or more occurrences of p, separated by op. Returns a value obtained by a right associative application of all functions returned by op to the values returned by p. If there are no occurrences of p, the value x is returned.

Parses _zero_ or more occurrences of `p`, separated by `op`. Returns a value
obtained by a _right_ associative application of all functions returned by
`op` to the values returned by `p`. If there are no occurrences of `p`, the
value `x` is returned.
sourceraw docstring

+chain-leftclj/s

(+chain-left p op)

Parses one or more occurrences of p, separated by op. Returns a value obtained by a left associative application of all functions returned by op to the values returned by p. This parser can for example be used to eliminate left recursion which typically occurs in expression grammars.

(def mulop  (p/alt (p/after (char/is \*) (p/result *))
                   (p/after (char/is \/) (p/result /))))

(def addop  (p/alt (p/after (char/is \+) (p/result +))
                   (p/after (char/is \-) (p/result -))))

(def expr   (+chain-left term addop))
(def term   (+chain-left factor mulop))
(def factor (p/alt (parens expr) integer))
Parses _one_ or more occurrences of `p`, separated by `op`. Returns a value
obtained by a _left_ associative application of all functions returned by `op`
to the values returned by `p`. This parser can for example be used to
eliminate left recursion which typically occurs in expression grammars.

    (def mulop  (p/alt (p/after (char/is \*) (p/result *))
                       (p/after (char/is \/) (p/result /))))

    (def addop  (p/alt (p/after (char/is \+) (p/result +))
                       (p/after (char/is \-) (p/result -))))

    (def expr   (+chain-left term addop))
    (def term   (+chain-left factor mulop))
    (def factor (p/alt (parens expr) integer))
sourceraw docstring

+chain-rightclj/s

(+chain-right p op)

Parses one or more occurrences of p, separated by op. Returns a value obtained by a right associative application of all functions returned by op to the values returned by p.

Parses _one_ or more occurrences of `p`, separated by `op`. Returns a value
obtained by a _right_ associative application of all functions returned by
`op` to the values returned by `p`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close