Version française
Home     About     Download     Resources     Contact us    
Browse thread
Stream parser/make_lexer
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sen Horak <sen.horak@g...>
Subject: Stream parser/make_lexer
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