higher-order DCG rule exported from module #2450
-
|
I'm attempting to export a higher-order DCG rule from a module: % test.pl
:- module(test, [p//1]).
p(G_0) --> G_0.?- [test].
true.
?- phrase(p("hello"), R).
error(existence_error(procedure,phrase/3),phrase/3).I don't understand what the error means. I attempted to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Scryer Prolog transforms the DCG you wrote to the following Prolog predicate: p(A,B,C) :- phrase(A,B,C). However, You can import :- use_module(library(dcgs)). You can also simply use $ scryer-prolog
?- use_module(library(dcgs)).
true.
?- phrase("hello", Ls).
Ls = "hello".
|
Beta Was this translation helpful? Give feedback.
Scryer Prolog transforms the DCG you wrote to the following Prolog predicate:
However,
phrase/3is not defined in your module, and so you get an existence error when invoking the DCG.You can import
library(dcgs)to makephrase/3available in your code, by adding the directive:You can also simply use
phrase/2orphrase/3directly:$ scryer-prolog ?- use_module(library(dcgs)). true. ?- phrase("hello", Ls). Ls = "hello".