caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Caml Parsing
@ 1996-09-17 18:57 Stephan Zdancewic
  1996-09-18 14:42 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Stephan Zdancewic @ 1996-09-17 18:57 UTC (permalink / raw)
  To: caml-list


Hello!
	I'm trying to use the SML version of yacc to write a parser
for Objective Caml, but I've run into problems because of some
differences in SML-yacc and Caml-yacc.  More precisely, Caml-yacc
allows you to specify precedence and associativity for non-terminals
in the grammar, while SML-yacc will let you do this only for
terminals.  Since the Caml-yacc grammar for OCaml makes extensive use
of this feature, I need a way of getting the same behavior in
SML-yacc.
	If anyone knows of a way around this, I'd be very greatful
for the information. Alternatively, does there exist a specification
of the OCaml grammar that doesn't rely on these precedence 
levels/associativities?  Or, better yet, has anyone already written
an OCaml parser for SML?

Thanks,
Steve Zdancewic
zdance@cs.cornell.edu





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

* Re: Caml Parsing
  1996-09-17 18:57 Caml Parsing Stephan Zdancewic
@ 1996-09-18 14:42 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1996-09-18 14:42 UTC (permalink / raw)
  To: Stephan Zdancewic; +Cc: caml-list


> 	I'm trying to use the SML version of yacc to write a parser
> for Objective Caml, but I've run into problems because of some
> differences in SML-yacc and Caml-yacc.  More precisely, Caml-yacc
> allows you to specify precedence and associativity for non-terminals
> in the grammar, while SML-yacc will let you do this only for
> terminals.

If you're talking about the "%prec" directive, I'm very, very
surprised that SML-yacc does not have an equivalent feature (to
override the default precedence and associativities assigned to a
production). It's the standard trick for handling e.g. unary minus,
and also very useful to resolve reduce/reduce conflicts. You may want
to check with the author of SML-yacc (David Tarditi, I think).

> Alternatively, does there exist a specification
> of the OCaml grammar that doesn't rely on these precedence 
> levels/associativities?

There have been several attempts at writing recursive-descent parsers
for Caml, but none that will handle the whole O'Caml syntax. More
generally, it can be very hard to disambiguate a grammar by rewriting
the rules (as opposed to playing with precedences).

Regards,

- Xavier Leroy





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

end of thread, other threads:[~1996-09-18 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-17 18:57 Caml Parsing Stephan Zdancewic
1996-09-18 14:42 ` Xavier Leroy

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).