Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-09-05 (12:07)
From: Eckart Goehler <goehler@a...>
Subject: Re: [Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions


On Wed, 3 Sep 2003, Rafael 'Dido' Sevilla wrote:

> I'm just wondering how you can guarantee that certain imperative effects
> occur, like adding a name into a symbol table hash.  I'm writing a
> compiler whose semantics allow some limited forward references, e.g.:
> until after the entire adt_declaration has been parsed.  The
> documentation for ocamlyacc has very little to say about it (unless
> there's more documentation in other places besides the ocaml manual).

As far as I understand ocamlyacc behaves as the original yacc (but not

> I'll also ask how I would go about processing file inclusion in
> ocamlyacc using ocamllex...

Tricky. Calling the parser function "main" from within the parser does not
work currently with ocamlyacc. I tried this myself and ended in patching
- the main function generated by ocamlyacc has to be recursive (let rec
  main = ...).
- the parser table written out has to be defined before the main function.
- because ocamllex needs the token information but must be defined
  *before* the parser (otherwise you can't recursively call ocamllex) the
  token  have to be written into a different file (for foo.mly I choosed
 the output file name to be

But file inclusion is a bit difficult because you can't always be shure
that the processing order is kept (mentioned by the main problem you have:
imperative features while parsing.

Maybe the patch should be implemented in ocamlyacc


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: