caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Stream parser/make_lexer
@ 2005-06-26 10:12 Sen Horak
  2005-06-26 12:18 ` [Caml-list] " Oliver Bandel
  2005-06-26 13:52 ` Virgile Prevosto
  0 siblings, 2 replies; 6+ messages in thread
From: Sen Horak @ 2005-06-26 10:12 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-06-27 11:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-26 10:12 Stream parser/make_lexer Sen Horak
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

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).