Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Chris Tilt <cet@webcriteria.com>
To: Steve Stevenson <steve@cs.clemson.edu>
Cc: caml-list@inria.fr
Subject: Re: Multiple Yacc-style Parsers in one application?
Date: Fri, 23 Jun 2000 09:46:27 -0700	[thread overview]
Message-ID: <39539463.D82BE216@webcriteria.com> (raw)
In-Reply-To: <14675.23674.237350.612515@merlin.cs.clemson.edu>

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



  reply	other threads:[~2000-06-26 10:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-23 12:49 Steve Stevenson
2000-06-23 16:46 ` Chris Tilt [this message]
2000-06-26 10:05 ` Christian Rinderknecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39539463.D82BE216@webcriteria.com \
    --to=cet@webcriteria.com \
    --cc=caml-list@inria.fr \
    --cc=steve@cs.clemson.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox