math.parse

parse

added in 3.0

(parse expr)

parses string into clojure data structure

(parse “sin((1+1))”) => ’(sin ({:op “+”} 1 1))

(parse “a+b*c^f(1,2)”) => ’({:op “+”} a ({:op “*”} b ({:op “^”} c (f 1 2))))

(parse “a+b+c+d”) => ’({:op “+”} ({:op “+”} ({:op “+”} a b) c) d)

parse-expr

added in 3.0

(parse-expr expr)

parses string into SyntaxTree

(parse-expr “1 + 1”) => org.scijava.parsington.SyntaxTree

to-clj

multimethod

added in 3.0

converts syntax tree into clojure

(to-clj (parse-expr “1+1”)) => ’({:op “+”} 1 1)

(to-clj (parse-expr “sin((1+1))”)) => ’(sin (:infix/splice ({:op “+”} 1 1)))

walk-postfix

added in 3.0

(walk-postfix form)

fixes splice forms occuring in parsing

(walk-postfix ’(sin (:infix/splice ({:op “+”} 1 1)))) => ’(sin ({:op “+”} 1 1))