defining "|" as or in Poplog Prolog 
Author Message
 defining "|" as or in Poplog Prolog

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]

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 could try to understand the compiler and change it, but if someone
has already done this I'll be grateful for the code.

Thanks.
Aaron
===
Aaron Sloman, ( http://www.*-*-*.com/ ~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK

PAPERS: http://www.*-*-*.com/
TOOLS: http://www.*-*-*.com/



Sat, 28 Dec 2002 03:00:00 GMT  
 defining "|" as or in Poplog Prolog

Quote:

> 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 could try to understand the compiler and change it, but if someone
> has already done this I'll be grateful for the code.

I'm not familiar with Poplog's implementation of Prolog, but in a
typical Prolog system, the following two lines should work.  The
first sets the operator status of the | symbol, and the second
defines the operator to behave the same as the ; operator.  The 1100
precedence value may need to be changed if Poplog uses a diferent
precendent for the ; operator as you want them both the same.

    :- op( 1100, xfy, | ) .

    X | Y :- X ; Y .

-- Alan Newman



Sat, 28 Dec 2002 03:00:00 GMT  
 defining "|" as or in Poplog Prolog


Quote:
> Date: Tue, 11 Jul 2000 14:46:41 -0700
> Organization: Motorola


> > ...
> > 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
===



Sat, 28 Dec 2002 03:00:00 GMT  
 defining "|" as or in Poplog Prolog

Quote:
> > ...
> > 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.

Just check whether your prolog compiler can accept
the "op" command if you put single quotes around the '|'.
This should turn it into an atom,
which may make the "op" command work.

    :- op( 1100, xfy, '|' ) .

    X | Y :- X ; Y .

--
    Martin Sondergaard,
    London.



Sun, 29 Dec 2002 03:00:00 GMT  
 defining "|" as or in Poplog Prolog

Quote:
> Some versions of prolog allow "|" as an alterantive to ";" for
> disjunction. In Poplog prolog, code written like that causes
> compile time (syntax) error.

In most Prologs, '|' is not a valid component of operator names (it is only
used as a separator in lists).  Unless you can modify the parser, you may be
out of luck.

--

  http://www.bawue.de/~jjk/          fax:+49-7031-464-7351
PGP:       06 04 1C 35 7B DC 1F 26 As the air to a bird, or the sea to a fish,
0x555DA8B5 BB A2 F0 66 77 75 E1 08 so is contempt to the contemptible. [Blake]



Sun, 29 Dec 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. defining "|" as or in Poplog Prolog

2. My prolog have no "define/2"!

3. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

4. define "variable" word

5. Redesigning "define interface"

6. Lets define "pointer"

7. Lets define "pointer"

8. Naming of "defined?"

9. defining "preferences" in cosmo with code

10. use defined PROTO in "Browser.createVrmlFromString"?

11. +define+unknown="'bx" chokes verilog

12. Defining "public" functions

 

 
Powered by phpBB® Forum Software