Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Michel Levy <Michel.Levy@imag.fr>, caml-list@inria.fr
Subject: Re: analysis of expression
Date: Fri, 17 Nov 2000 18:11:47 +0100	[thread overview]
Message-ID: <20001117181147.25121@pauillac.inria.fr> (raw)
In-Reply-To: <3A10230E.F4EFBBEE@imag.fr>; from Michel Levy on Mon, Nov 13, 2000 at 06:21:18PM +0100

> In definition of expr I read :
> expr := expr expr
> 	| expr infix-op expr
> with that syntax its possible to have two analysis of the sentence "let
> x = 1 in x-1" ?
> 1) The correct analysis (the Ocaml anlysis) : - is an operation between
> x et 1
> 2) x is applied to -1 and we find a type error
> Where it's possible to find in the Ocaml reference the choosen solution ?

It's not very explicit, I agree, but the table of operator precedences
for expressions says that function application has higher precedence
than unary minus.  So, "x-1" cannot be parsed as "x applied to -1"
since this would violate the precedences.  And of course "x-1" cannot
be parsed as "(x applied to -) applied to 1" because "-" in itself is
not a valid expression.  This leaves "x binary minus 1" as the only
legal parsing.

- Xavier Leroy



      reply	other threads:[~2000-11-19 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-13 17:21 Michel Levy
2000-11-17 17:11 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20001117181147.25121@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=Michel.Levy@imag.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox