Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Eckart Goehler <goehler@a...>
Subject: Re: [Caml-list] parsing forward references in ocamlyacc and other ocamlyacc questions

Hi,

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

> 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
ocamlyacc:
- 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 footoken.ml/footoken.mli).

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

eckart


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