Parsing and running program strings#

You can provide your program in a special DSL language. Parse it with egglog.bindings.EGraph.parse_program() and run the resulting commands with egglog.bindings.EGraph.run_program():

from egglog.bindings import EGraph

egraph = EGraph()
commands = egraph.parse_program("(check (= (+ 1 2) 3))")
commands
[Check(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 0, 21), [Eq(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 7, 20), Call(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 10, 17), '+', [Lit(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 13, 14), Int(1)), Lit(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 15, 16), Int(2))]), Lit(EgglogSpan(SrcFile(None, '(check (= (+ 1 2) 3))'), 18, 19), Int(3)))])]
egraph.run_program(*commands)
[]