Version française
Home     About     Download     Resources     Contact us    
Browse thread
Another nasty with ocamlyacc: magic needed?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <a.baretta@b...>
Subject: Re: [Caml-list] Another nasty with ocamlyacc: magic needed?
skaller wrote:
> I have what looks like a showstopper (meaning black magic
> seems to be the only solution).
> 
> I need two *distinct* parsers which use the same set
> of tokens. This is currently impossible AFAICS without
> magic (distinct -- in a different module entirely)


Let's not overstate the problem. Yacc is an imperfect tool. Everybody who used 
it knows this, but it is usually flexible enough that you can--eventually--get 
it to do what you have in mind. I would suggest that you consider a couple of 
tools which might help get out of this /impasse/. Firstly, remember that can 
define as many parser entry points as your heat desires. Each entry point is 
virtually a distinct parser, except that the token type is shared and the 
non-terminal namespace is also shared, which might be a bane or a boon depending 
on whether the two grammars you wish to impolement share some productions or 
not. Secondly, after compiling the automaton with ocamlyacc, you can always 
delete and regenerate the interface with ocamlc -i. My Makefile generator for 
ocaml, builder, actually handles this pretty nicely, allowing the parser to 
export anything you put in the header.

Alex



-- 
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>

The FreerP Project
<http://www.freerp.org/>