[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jul 11 23:25:33 2000 
Subject:Re: defining "|" as or in Poplog Prolog 
From:Aaron Sloman See text for reply address 
Volume-ID:1000712.01 

Alan Newman <Alan_Newman-P20582@email.mot.com> writes, helpfully:

> Date: Tue, 11 Jul 2000 14:46:41 -0700
> Organization: Motorola
>
> Aaron Sloman wrote:
> > ...
> > Some versions of prolog allow "|" as an alterantive to ";" for
> > disjunction. In Poplog prolog, code written like that causes
> > compile time (syntax) error.
> >
> > Does anyone have a modification for poplog prolog that accepts
> > "|" in that context.
>
> ...
> I'm not familiar with Poplog's implementation of Prolog, but in a
> typical Prolog system, the following two lines should work.
> ....
>     :- op( 1100, xfy, | ) .
>
>     X | Y :- X ; Y .

Thanks Alan.
The required precedence in poplog prolog is 254.

Unfortunately the compiler complains if it finds "|" in either of
those two positions.

;;; PROLOG SYNTAX ERROR - EXPECTED THE START OF A TERM
;;; FOUND  : |
;;; READING: :- op ( 254 , xfy , <<HERE>> |
;;; FILE   : /home/staff/axs/plog/test.pl     LINE NUMBER: 5

etc.

I have had a look at the code in $usepop/pop/plog/src/parse.p

It looks as if the restriction to use of "|" in lists is built into
this stuff:

lconstant procedure (
	illegal_start_item =
		;;; items which cannot start a term
		mkassoc([% ")", "]", "}", "|", "," %]),
	illegal_after_prefix_op =
		;;; as above, plus "." to allow "spy." etc. for upward compatability
		mkassoc([% ")", "]", "}", "|", ",", "." %]),
	punctuation_in_term =
		mkassoc([% "(", ")", "[", "]", "{", "}", "|", "." %]),
	punctuation_in_argument =
		mkassoc([% ",", "(", ")", "[", "]", "{", "}", "|" %]),
	punctuation_in_bracketedterm =
		mkassoc([% "(", ")", "[", "]", "{", "}", "|" %])
);

I guess removing occurrences in "|" from the first two lists will
solve the problem.

Presumably this
     X | Y :- X ; Y .

will not suffice to ensure that "|" works as expected after "->".

Maybe in the src/transform.p file, perhaps replace
		elseif fn == ";" and arity == 2 then
with
		elseif (fn == ";" or fin == "|") and arity == 2 then

I wondered if some poplog prolog user might already have done this,
checked it out, etc.

Aaron
===