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: Re: [Caml-list] Stream parser/make_lexer
Hi,

Thanks for this. Your answer fixed the problem.

Additionally, i was wrongly using 'String instead of 'Ident. 'String
it appears, is
for quoted text - which of course is in the manual. My bad.

SH

On 6/26/05, Virgile Prevosto <virgile.prevosto@gmail.com> wrote:
> Hello,
> 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
> Virgile
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>