egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
459 stars 54 forks source link

In REPL, evaluates only when parens are closed #402

Closed yihozhang closed 3 months ago

yihozhang commented 3 months ago

Currently, the REPL mode evaluates programs line by line, which means egglog < main.egg almost certainly won't work because most expressions are multi-lines. Moreover, simply concatenating all lines in the source file (e.g., tr -d "\n" < main.egg | egglog) also does not work if the source file contains comments.

This PR fixes this by only evaluating a multi-line block when all the parentheses are closed. So that the program

(extract "1
2
3 
)
"
) (extract
";;;""))"
)

will only call parse_and_run_program once once at the end of the program

yihozhang commented 3 months ago

I added a small test