From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA16979 for caml-red; Mon, 26 Jun 2000 12:23:01 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA23741 for ; Fri, 23 Jun 2000 18:48:00 +0200 (MET DST) Received: from ugly.gaggle (mail.webcriteria.com [207.173.34.253]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e5NGlwX02494 for ; Fri, 23 Jun 2000 18:47:59 +0200 (MET DST) Received: from webcriteria.com (euler.gaggle [192.168.168.107]) by ugly.gaggle (8.9.3/8.9.3) with ESMTP id JAA17594; Fri, 23 Jun 2000 09:47:19 -0700 Message-ID: <39539463.D82BE216@webcriteria.com> Date: Fri, 23 Jun 2000 09:46:27 -0700 From: Chris Tilt Organization: WebCriteria, Inc. X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Steve Stevenson CC: caml-list@inria.fr Subject: Re: Multiple Yacc-style Parsers in one application? References: <14675.23674.237350.612515@merlin.cs.clemson.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr 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