Version française
Home     About     Download     Resources     Contact us    
Browse thread
Multiple Yacc-style Parsers in one application?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Tilt <cet@w...>
Subject: Re: Multiple Yacc-style Parsers in one application?
Steve,

When I discovered the lex/yacc tools for caml I was very impressed.
They are implemented in a completely functional way, with no magic
entry points or expected symbols, etc. We have an application with
two yacc parsers, each with their own lexer. Since the yacc-created
parser takes a lex buffer and a lexer function, you can build any
number of co-existing parsers. Each lexer also has its own name
space, so it's very different from the old C yacc/lex experience.

As a partial example of how the machinery works, here is a code
snippet (with no exception handling, which you need). The returned
document is of the type returned by the function "Xmlparse.document".
The cool part is that *any* of the left-hand-side productions can
be used as entry points for your parser. This makes it trivial to
parse, e.g. document fragments in this XML example.

let doc =
  let lexbuf = Lexing.from_channel in_chan
in
  Xmlparse.document Xmlscan.scan lexbuf

-Chris

P.S. Thanks to the CAML team for these great tools. We are building
our second industrial product with CAML 3.0 release.

Steve Stevenson wrote:
> 
> Good morning.
> 
> I'm interested in hearing experiences from people who have used
> multiple yacc parsers in one application. I assume that they would
> share one lexer buffer (but maybe not). Do you have to manipulate the
> lexical world to deal with the one-lookahead?
> 
> Any experiences, stories, etc, greatly appreciated.
> 
> Best regards,
> 
> steve
> -----
> Steve (really "D. E.") Stevenson           Assoc Prof
> Department of Computer Science, Clemson,   (864)656-5880.mabell
> Support V&V mailing list: ivandv@cs.clemson.edu

-- 
Chris Tilt			mailto:cet@webcriteria.com
CTO, WebCriteria, Inc.		http://www.webcriteria.com