caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] CFG's and OCaml
@ 2004-08-13 14:04 David McClain
  2004-08-13 15:05 ` Damien Doligez
  2004-08-13 15:49 ` Brian Hurt
  0 siblings, 2 replies; 27+ messages in thread
From: David McClain @ 2004-08-13 14:04 UTC (permalink / raw)
  To: caml-list

Okay... here's a case where when I do "exactly" what the gurus at Inria 
do, I get a reduce/reduce conflict, and yet when I build OCaml it does 
not report any such conflicts. [I say "exactly" because obviously I'm 
not...]

simple_expr:
	constant
	...

simple_pattern:
	signed_constant
	...

constant:
	INT
| 	FLOAT

signed_constant:
	constant
|	MINUS INT
|	MINUS FLOAT
  ;; /*  ---------------------------------------------------------- */

The reduce/reduce conflict comes on deciding whether to assign an INT 
seen to signed_constant which will reduce to simple_pattern, or instead 
to become constant which reduces to simple_expr. Both Inria and I do 
completely different semantic reductions in these two cases, and so a 
reduce/reduce conflict could be fatal here...

[ I found many instances of my own reduce/reduce conflicts arising from 
error trapping clauses with things like missing RPAREN's etc. Both 
pattern and expressions had these error traps, and so it was simple to 
remove the reduce/reduce conflict by eliding a trap from one or the 
other of these two places. That's pretty harmless since the compiler 
aborts there anyway and it makes no difference which reduction is 
chosen.

But the last few reduce/reduce conflicts are like the one shown above 
and they do matter.]

So, as so often happens with the master's touch, everything works fine 
for them, but it doesn't for me. Why should this be, in this example 
case?


David McClain
Senior Corporate Scientist
Avisere, Inc.

david.mcclain@avisere.com
+1.520.390.7738 (USA)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Caml-list] CFG's and OCaml
@ 2004-08-12 19:15 David McClain
  0 siblings, 0 replies; 27+ messages in thread
From: David McClain @ 2004-08-12 19:15 UTC (permalink / raw)
  To: caml-list

Heh! I just dug out Andrew Appel's book from the closet and began 
reading it anew.

Lo and behold, he shows how grammars that invite reduce/reduce 
conflicts are best handled by opening up the universe of sytactically 
recognizable sentences -- well beyond anything meaningful for the 
language at hand -- and then using a later semantic analysis stage to 
detect and report the error.

So this explains why the parser.ml for OCaml has all those apparently 
illegal accepting clauses in it. The parser recognizes all kinds of 
wild things that would be patently invalid OCaml code.

I began life in this field more than 30 years ago using a simple 
language called Forth to control a large 100 inch telescope in 
Wyoming... I learned many "bad habits" in programming -- most notably 
to write code that works when fed correct input for its intended 
purpose -- and to hell with what happens in any other case. I watched 
and learned from the practicioners of this language what I came to call 
"Kamakazi Programming Style".

Now after spending the last 30 years trying hard to overcome these 
initial misguidings, I find once again, that this is the appropriate 
solution -- at least in the parsing stage.

Very interesting...

David McClain
Senior Corporate Scientist
Avisere, Inc.

david.mcclain@avisere.com
+1.520.390.7738 (USA)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2004-08-15 16:57 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-13 14:04 [Caml-list] CFG's and OCaml David McClain
2004-08-13 15:05 ` Damien Doligez
2004-08-13 15:26   ` David McClain
2004-08-13 16:12     ` Damien Doligez
2004-08-13 15:28   ` David McClain
2004-08-13 15:49 ` Brian Hurt
2004-08-13 16:04   ` David McClain
2004-08-13 16:29     ` Brian Hurt
2004-08-13 16:42       ` Xavier Leroy
2004-08-13 17:18         ` Ken Rose
2004-08-13 18:55         ` Brian Hurt
2004-08-14  0:25           ` Jon Harrop
2004-08-14  0:57             ` Erik de Castro Lopo
2004-08-14  8:52               ` Alan Schmitt
2004-08-14  3:33             ` Brian Hurt
2004-08-14  7:55             ` skaller
2004-08-14 20:19               ` Jon Harrop
2004-08-14 20:55                 ` Brian Hurt
2004-08-14 20:57                   ` Marcin 'Qrczak' Kowalczyk
2004-08-14 22:15                     ` skaller
2004-08-15  1:26                   ` Jon Harrop
2004-08-15  8:24                     ` skaller
2004-08-15 15:39                     ` Brian Hurt
2004-08-15 16:54                       ` Jon Harrop
2004-08-14 22:13                 ` skaller
2004-08-13 16:58     ` Paul Snively
  -- strict thread matches above, loose matches on Subject: below --
2004-08-12 19:15 David McClain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).