caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sen Horak <sen.horak@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Stream parser/make_lexer
Date: Sun, 26 Jun 2005 12:12:40 +0200	[thread overview]
Message-ID: <a80eebd40506260312508f0408@mail.gmail.com> (raw)

Hi,

I tried building a small parser using Genlexer.make_parser and the
stream parser through the camlp4 preprocessor. I'm using the ocaml
compiler 3.08.1.

let lexer=make_lexer ["begin";"end";...]

let parse = parser
      [<'Kwd "name=";'String t>] -> wm#setname t
  |  ...

let istream = of_channel stdin

let ilexer = lexer istream in
  parse ilexer

The program exits with a Stream.Failure exception. The "stream
builders" documentation clearly says that we are not to mix the of_*
functions to build streams with <> streams - so I guess this is
expected. Although I've come across some examples that use of_string
to build the char stream and use the lexer on it.

How then does one build a stream compatible with the stream parser
connected to stdin?

Also, is the make_lexer/stream parser way of building a parser
deprecated? I find it a convenient way to build small parsers quickly.
Or do most ocaml programmers just use ocamllex/ocamlyacc for
everything?

SH


             reply	other threads:[~2005-06-26 10:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-26 10:12 Sen Horak [this message]
2005-06-26 12:18 ` [Caml-list] " Oliver Bandel
2005-06-26 13:25   ` Sen Horak
2005-06-26 14:24     ` Oliver Bandel
2005-06-26 13:52 ` Virgile Prevosto
2005-06-27 11:24   ` Sen Horak

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=a80eebd40506260312508f0408@mail.gmail.com \
    --to=sen.horak@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).