Skip to content

Consolidating overlapping DCG rules #2622

Answered by dnmfarrell
dnmfarrell asked this question in Q&A
Discussion options

You must be logged in to vote

Aha, this seems to work!

patt([])     --> [].
patt([C|Cs]) -->
  wildcard([C|Cs]) | placeholder([C|Cs]) | escape([C|Cs]) | regular([C|Cs]).

wildcard(['*'|Cs])     --> word([]), patt(Cs).
placeholder(['?'|Cs])  --> [_], patt(Cs).
escape(['\\'|Cs])      --> same(Cs).
regular([C|Cs])        --> [C], patt(Cs).

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@triska
Comment options

@jjtolton
Comment options

@triska
Comment options

@jjtolton
Comment options

@jjtolton
Comment options

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