English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2005-06-26 (13:52)
From: Virgile Prevosto <virgile.prevosto@g...>
Subject: Re: [Caml-list] Stream parser/make_lexer
2005/6/26, Sen Horak <sen.horak@gmail.com>:
> let parse = parser
>       [<'Kwd "name=";'String t>] -> wm#setname t
>   |  ...
> let istream = of_channel stdin
> 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.

I can be wrong, but I think that the documentation prohibits stuff like
let s = Stream.of_string "foo" in [< s; s >], that is building a
stream with both the of_* functions and the [< >] notation. This is
not the case here, since [< >] is used only for pattern matching.

Concerning your original problem, I think that the main issue is that
"name=" is not a valid keyword for lexer. Try to split it in "name"
and "=" (cf documentation of Genlex.token), i.e. do something like
let lexer = Genlex.make_lexer ["name"; "="; ...]
let parse = parser [< 'Kwd "name"; 'Kwd "="; 'String t >] -> ... 

E tutto per oggi, a la prossima volta