Skip to content

Boolean Expression Evaluator? #582

Answered by zesterer
test3211234 asked this question in Q&A
Discussion options

You must be logged in to vote

Parsing arithmetic operations like + is not really any different to parsing boolean operators like ==, &&, etc. Each operator has precedence (indicated by the number given for each operator: see the pratt module docs for more information) and an associativity (left or right). Along with that, you provide a function that tells chumsky how it can combine the operator and operands together (usually you'd use this function to construct an AST node representing that operation, but in the example we just evaluate the result immediately).

You can read the guide to see how to use chumsky in a Rust project. The guide also covers key concepts in crate, and a little parser theory.

That said, your re…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@test3211234
Comment options

@zesterer
Comment options

Answer selected by test3211234
@test3211234
Comment options

@zesterer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants