-
Hello, First of all, thanks for the great library! I am trying to create an Excel like formula expression language using winnow and my prototype seems to be working. However, it has some serious downsides when the expression is long and deeeeeeply nested. Example 1:
Since I can't right know right off the bat whether "Function1" is a binary operand OR one of the other possible operands like unary, function call, literal, etc, I have to literally try parsing "Function1" (or any other expression) as binary expression first and then other things. For instance, I could have had above expression written differently as follows: Example 2: In this case, I would use the parsed results from Function 1 to compare against true So, the problem is that I have to parse the same thing multiple times. This approach works great for small to mid expressions and im getting my expected result. But, as you can probably tell, if the expression is deeply deeply nested then performance is going to be bad, and, in my case, the evaluation doesn't even complete. To mitigate this issue, I was thinking about passing a hashmap to the parser using But, after much struggle, it seems to me that only simple values can be passed to the StateFul struct. Maybe I need to change my approach altogether? Any recommendations/helpful would be greatly appreciated! My background: Noob in parsing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Seems like its related to this #480? |
Beta Was this translation helpful? Give feedback.
Yes, packrat parsing would help with how you are parsing but my hope is that there are other ways to improve things.
For example, if you split up lexing and parsing, then the cost of re-parsing a section in an
alt
will be dramatically lower. Unsure if pratt parsing (#131) reduces the number of passes in handling each expression.