Skip to content

Swipl DCG does not appear to function #131

@salamander-eng

Description

@salamander-eng

This seems to work when a file is consulted, but does not appear to work when utilized via assert:
Simplest possible example:

as --> [].
as --> [a], as.
?- phrase(as,[a,a,X,a]).
X = a.

If the DCG is described in a file and p.consult("dcgtest.pl") used, this works as expected:

for r in p.query("phrase(as,[a,X,a,a])"):
print(r)

If we try to assert instead, things do not appear to be parsing correctly

p.assertz("as --> []")
p.assertz("as --> [a], as")

yields

PrologError: Caused by: 'phrase(as,[a,X,a,a])'. Returned: 'error(existence_error(procedure, /(as, 2)), context(:($dcg, /(call_dcg, 3)), Variable(76)))'.

I need to generate and insert the DCG from the python side. Is there a way to accomplish this that I am not understanding ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions