-
I was revisiting #2260 to try to adapt it into the Scryer libraries and I wondered how I could implement eos --> call(eos_raw).
eos_raw([], []). But from what I remember of the discussion there, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Oh, I think I got it: eos_new --> call(eos_new_raw).
eos_new_helper(S0, S, S0, S).
eos_new_raw(S0, S) :-
phrase(eos_new_helper(S0, S), [], []). Because this uses % Gets the difference list at the given point in the grammar rule body
diff_list(Ls0, Ls) --> call(call(diff_list_raw, Ls0, Ls)).
diff_list_helper(S0, S, S0, S).
diff_list_raw(Ls0, Ls, S0, S) :-
phrase(diff_list_helper(S0, S), Ls0, Ls).
eos_new --> diff_list([], []). |
Beta Was this translation helpful? Give feedback.
-
The original definition you provided seems to be perfectly valid, using the non-terminal The discussion in #2260 was about a different issue, where the predicate |
Beta Was this translation helpful? Give feedback.
The original definition you provided seems to be perfectly valid, using the non-terminal
call//1
to invoke a predicate from within a DCG in such a way that the predicate can reason about the list difference.The discussion in #2260 was about a different issue, where the predicate
call/3
was originally used to invoke a non-terminal, and that is not portable. Use the predicatesphrase/N
, and the non-terminalsphrase//N
, to invoke DCG non-terminals.