Home > Archive > Prolog > December 2006 > Syntax Error in GNU Prolog 1.2.16
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Syntax Error in GNU Prolog 1.2.16
|
|
| amill123@gmail.com 2006-12-13, 4:16 pm |
| I have some facts in a program that I am running under GNU Prolog that
I am trying to declare as dynamic. Here are the facts:
:- dynamic(loc_list/2).
loc_list([apple, broccoli, crackers], kitchen).
:- dynamic(turned_off/1).
turned_off(flashlight).
:- dynamic(here/1).
here(kitchen).
:- dynamic(door_closed/2).
door_closed(kitchen, cellar).
When I try to run:
consult('myadven.pro').
....in the listener I get the following error for each of the above
facts:
error: syntax error: previous operator needs brackets (char:<a number> )
....where <a number> seems to indicate the position where the error
occurs. In each of these facts, the error is occurring immediately
after the '/' character.
I also get a similar bracket error for the following:
can_take(Thing) :-
Thing = door,
write('You can''t take a door.'), % Error occurs here!
...
And a bracket error here as well:
can_take(Thing) :-
(not(Thing = door)), % Error occurs here!
write('There is no '),
...
In both of these rules the error is occuring immediately before the ','
following the 'X = X' query.
I cannot figure out why these errors are occurring. I don't see
anything wrong with my syntax; it compiled fine on Amzi! Prolog but I
need it to work on GNU Prolog. Any help is GREATLY appreciated!
| |
| Darren Bane 2006-12-13, 4:16 pm |
| amill123@gmail.com wrote:
> I have some facts in a program that I am running under GNU Prolog that
> I am trying to declare as dynamic. Here are the facts:
>
> :- dynamic(loc_list/2).
I think this should be
:- dynamic loc_list/2.
!snip!
> can_take(Thing) :-
> (not(Thing = door)), % Error occurs here!
I can guess what not does, and I think the standard way to write it is
\+ Thing = door,
or probably even better,
Thing \= door,
!snip!
I can't really help with your other problems. But just from looking at
the names chosen, I can guess that your problem domain is an adventure
game. Are you aware of
http://www.ainewsletter.com/downloads/if_docs/
?
--
Darren Bane
| |
| amill123@gmail.com 2006-12-13, 4:16 pm |
| Hi, I tried removing the parentheses from the dynamic facts. I get the
same error as previously for loc_list/2, I get the following warning
for turned_off/1:
warning: unknown directive (/)/2 - maybe use initialization/1 -
directive ignored
....and the following error for the rest of the dynamic facts:
error: syntax error: . or operator expected after expression (char:11)
As far as not, I have in my code the rule:
not(X) :- \+(X).
....so using not shouldn't be a problem.
I'm actually doing the tutorial at
http://www.amzi.com/AdventureInProlog/index.htm which is very similar
to the info in the link you sent.
Thanks,
A
Darren Bane wrote:
> amill123@gmail.com wrote:
>
> I think this should be
>
> :- dynamic loc_list/2.
>
> !snip!
>
>
> I can guess what not does, and I think the standard way to write it is
>
> \+ Thing = door,
>
> or probably even better,
>
> Thing \= door,
>
> !snip!
>
> I can't really help with your other problems. But just from looking at
> the names chosen, I can guess that your problem domain is an adventure
> game. Are you aware of
>
> http://www.ainewsletter.com/downloads/if_docs/
>
> ?
> --
> Darren Bane
| |
| Jerome Abela 2006-12-15, 7:05 pm |
| amill123@gmail.com wrote:
> :- dynamic(loc_list/2).
> loc_list([apple, broccoli, crackers], kitchen).
>
> :- dynamic(turned_off/1).
> turned_off(flashlight).
>
> :- dynamic(here/1).
> here(kitchen).
>
> :- dynamic(door_closed/2).
> door_closed(kitchen, cellar).
>
> When I try to run:
>
> consult('myadven.pro').
>
> ...in the listener I get the following error for each of the above
> facts:
A simple copy/paste on your posted code doesn't exhibits the problem.
It just says:
| ?- consult('test.pro').
compiling /home/a/test.pro for byte code...
/home/a/test.pro compiled, 13 lines read - 855 bytes written, 7 ms
yes
| ?-
Could you please try with only the code you posted, and enhance it with
the real complete code until an error appears ?
Jerome.
|
|
|
|
|