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
yacc style
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-01-28 (01:14)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] yacc style
On Fri, 2005-01-28 at 08:39, Erik de Castro Lopo wrote:
> On Thu, 27 Jan 2005 15:17:13 -0500
> Chris King <> wrote:
> > Is it considered better style to
> > instead have the parser return a parse tree, and then use that to
> > generate the imperative structure, 
> Yes, normally the parser generates a parse tree which is then
> passed to the semantic analyser for semantic checking.

Unfortunately this is useless in the common case
of needing to parse C. It would surely be nice
to be able to pass an argument to ocamlyacc,
as can now be done for ocamllex.

Strangely in this case the ideal place to add
on  the typedef table would be the lexbuf,
which *is* passed to the parser .. but the client
can't get at it, and it isn't extensible.

The reason this isn't done right seems to be that
yacc/lex are used to bootstrap Ocaml and so fixing
them would destablise the bootstrap.

FYI: in Felix, the parser and lexer are built-in
to the language, and lexical scoping is supported:
whilst you cannot pass in an extra argument to the parser,
you *can* write action code that depends on its
environment, which need not be the top level.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language