* analysis of expression
@ 2000-11-13 17:21 Michel Levy
2000-11-17 17:11 ` Xavier Leroy
0 siblings, 1 reply; 2+ messages in thread
From: Michel Levy @ 2000-11-13 17:21 UTC (permalink / raw)
To: caml-list
Dans la définition de expr, on trouve :
expr := expr expr
| expr infix-op expr
Aussi la phrase "let x = 1 in x-1" peut-être analysée de 2 manières
1) La manière correcte (celle de Ocaml) : - est une opération infixée
entre x et 1
2) x est appliqué à -1 : d'où une erreur de types
Où est-il indiqué dans le "manuel de référence Ocaml", la solution
choisie ?
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
?
Thank you
--
Michel Levy
D106 - L.S.R. B.P.72 - 38042 SAINT MARTIN D'HERES CEDEX - France
e.mail : Michel.Levy@imag.fr tel :(33)476827246
http://www-lsr.imag.fr/Les.Personnes/Michel.Levy
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: analysis of expression
2000-11-13 17:21 analysis of expression Michel Levy
@ 2000-11-17 17:11 ` Xavier Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2000-11-17 17:11 UTC (permalink / raw)
To: Michel Levy, caml-list
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-11-19 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-13 17:21 analysis of expression Michel Levy
2000-11-17 17:11 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox