Consolidating overlapping DCG rules #2622
-
Yesterday I wrote a string pattern-matching library as a DCG but one wart it had was overlapping rules, which required an extra predicate `reg_char/1':
I was able to resolve this by combining all the rules into a single rule, but I couldn't express it as a DCG as I'm unable to replicate the if/then semantics (I think that's the reason).
I added the cuts after the first predicate in an attempt to be like if/then. But the test suite fails. My question is, is it possible to fix overlapping rules in DCGs using if/then or another technique? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Aha, this seems to work!
|
Beta Was this translation helpful? Give feedback.
Aha, this seems to work!