mitanu@goedel.top.cis.syr.edu (Mitanu Paul) (02/14/91)
Hi, I came across this problem. The following operators are defined: :- op(500, fx, +). :- op(500, yfx, +). :- op(200, xfy, ^). :- op(550, xf, !). :- op(550, xfx, !). The query ?- X = (a+b!). produces the following error: ** Syntax error: ** X=(a+b! ** here ** ) Similarly, the query "X=(a^b!)" gives a syntax error at the same location. Why? I guess that it is because of two op declarations for !, since I don't get the error when the op(550,xfx,!) declaration is removed. Does the parser get confused when confronted with such operators? Both C-prolog and Quintus prolog produce this error. Please reply by e-mail. Thank you. -- Mitanu (mitanu@top.cis.syr.edu)
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (02/19/91)
In article <1991Feb13.123619.23855@rodan.acs.syr.edu>, mitanu@goedel.top.cis.syr.edu (Mitanu Paul) writes: > :- op(550, xf, !), op(550, xfx, !). [This is not accepted as valid syntax:] > ?- X = (a+b!). > Does the parser get confused when confronted with such operators? > Both C-prolog and Quintus prolog produce this error. The version number *does* make a difference. There were versions of C Prolog that should have got this right. There are Prolog systems around that can handle this: % np NU-Prolog 1.5#18 1?- op(550, xf, !), op(550, xfx, !). 2?- display( a+b! ). !(+(a, b)) % sicstus SICStus 0.7 #1: Tue Sep 4 21:39:16 EST 1990 | ?- op(550, xf, !), op(550, xfx, !). | ?- display(a+b!). !(+(a,b)) | ?- compile(tokens), compile(read). % Public-domain parser. | ?- portable_read(X), display(X). |: a+b!. ** expression expected a + b ! <<here>> no | ?- portable_read(X), display(X). |: (a+b!). ** ) cannot start an expression ( a + b ! ) <<here>> no This is a mistake, as the term is quite unambiguous. To users of the public domain Prolog parser, I can only apologise for the mistake. -- Professional programming is paranoid programming