Boolean expression parser #560
Replies: 1 comment
-
Have you looked at the tutorial? It helps get you in the mindset which is that you only think about things in terms of the next byte(s) and not the grammar as a whole.
This parser is a good starting place as it is doing something similar to yours. The main differences are
If you parse once and evaluate many times, having it in an AST or byte code would be faster than always re-parsing. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm new to parser combinators so this is all pretty tough for me. I'm confused how to create a boolean expression parser like VSCode "when clause contexts": https://code.visualstudio.com/api/references/when-clause-contexts
I've been looking at this as the most similar but I'm still confused about the order and what functions to include what operators in and stuff: https://github.com/winnow-rs/winnow/blob/main/examples/arithmetic/parser_ast.rs
Right now I want this:
I've written a handwritten parser for this before using Logos as the lexer. I'm wondering if this will be faster. I'm guessing the best approach is to store it into an AST and evaluate the AST everytime I want to check if the expression is true or false? Thanks Ed Page for the library
Beta Was this translation helpful? Give feedback.
All reactions