Rewrite expression parsing and evaluation using expr-parser #22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://github.com/zyxw59/expr-parser
It's now ready for use, and should let us simplify the parser code and potentially evaluation code (relevant for #18)
Hmm, expr-parser does still hard-code some assumptions that don't hold here, namely
Tokens can borrow from and reference with theirSpansactually maybe this can be solved with an iterator adapter
except we still need a way to detect parens that doesn't conflict with parens that might exist within an expression, for parsing things like the
points fromsyntax. Or maybe we should add capability toexpr-parserto do something like "start with a delimiter on the stack and return once its matching delimiter has been parsed". Alternatively, we could change the syntax ofpoints from(and others with similar constraints) to use a delimiter not used by expressions.hmm, we could just include the open paren at the start. there' still the issue of knowing when to stop though. maybe the parser just needs an option to say, "parse one term and then stop", which would just add a check after each call to
parse_nextthat would break if the stack is emptyOh, I'll also need to make
expr_parserable to handle a fallible lexer, since our lexer performs fallible I/O.Or we could buffer one statement at a time and use that as the basis for the lexer
Oh wait, the canonical way to handle errors in lexing is to just pass them as their own tokens that the parser decides what to do with (raising an error, presumably).