I have build a DCG with Prolog. The code works, when I do the following call:
phrase(programm(R), [1,+,2], []).
I want the user to write the input, so I did this:
main :- read(Input), atom_chars(Input, R), write(R), phrase(programm(E), R).
Calling main and input e.g. '1+2' doesn't work. How can I process the user input to the phrase method for calling my DCG?
phrase(programm(R), [1,+,2], [])
is what works when you run it on its own, why not use,phrase(programm(E), R, [])
in yourmain
predicate? – lurker