Skip to content

higher-order DCG rule exported from module #2450

Answered by triska
rodrigosetti asked this question in Q&A
Discussion options

You must be logged in to vote

Scryer Prolog transforms the DCG you wrote to the following Prolog predicate:

p(A,B,C) :- phrase(A,B,C).

However, phrase/3 is not defined in your module, and so you get an existence error when invoking the DCG.

You can import library(dcgs) to make phrase/3 available in your code, by adding the directive:

:- use_module(library(dcgs)).

You can also simply use phrase/2 or phrase/3 directly:

$ scryer-prolog
?- use_module(library(dcgs)).
   true.
?- phrase("hello", Ls).
   Ls = "hello".

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rodrigosetti
Comment options

@rodrigosetti
Comment options

@triska
Comment options

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