Replies: 2 comments 3 replies
-
I don't know exactly how to program it, but more-or-less I would've approached that problem in the following way (which is better to be described using an example):
I think such approach will be reasonably fast, it all will depend on how well is implemented step 3. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Does anyone have a good algorithm for rewriting left recursion, aka, "left factorization"? I realize now we can do this automatically with |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I ran into a "left recursion" situation, where I am struggling to efficiently parse expressions of the form
A op B
.This wouldn't work at all without @triska's great insight into using tabling for left recursion.
This does indeed end up working:
But it only works up to a certain number of expressions. The problem calls for solutions of up to 20 expressions. On my machine, which is fairly powerful, this code struggles with expressions of size 12:
?- Result^Expr+\(solve("99*99-4*99*1*99*1*2*99*36*42*74", Expr, Result)). %@ <diesel engine noises>
Would be interested if anyone has any thoughts!
This gives more insight into the problem:
Beta Was this translation helpful? Give feedback.
All reactions