Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Does Prolog have an unambiguous syntax definition? Message-ID: <4764@goanna.cs.rmit.oz.au> Date: 13 Feb 91 06:31:16 GMT References: <12166@darkstar.ucsc.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 28 In article <12166@darkstar.ucsc.edu>, kjell@terra.ucsc.edu writes: > Is there a document that describes the reader's behaviour when it > sees an ambiguous term? Which Prolog? There *is* a document: the public-domain DEC-10 Prolog parser, published in 1984 (or was it 1983)? > :- op(300,fx,#). % prefix > :- op(500,xf,#). % postfix > :- op(400,fx,@). % prefix > display(@ #). > Will Prolog display @(#) or #(@), and why is one preferred over the other? In a Prolog system whose reader is based on the public-domain parser (the *point* of providing that was to help implementors tell the truth when they claimed "Edinburgh" compatibility), the answer must be #(@). THERE IS NOTHING AMBIGUOUS ABOUT THIS TERM: if a possible prefix operator is followed by - a right bracket of some sort , ) | ] } . - a possible infix operator of wider scope (bigger number) - or a possible postfix operator of wider scope (bigger number) then the possible prefix operator is read as an atom. (In the case of a following infix or postfix operator, this forces the operator reading.) -- Professional programming is paranoid programming