Re: js_of_ocaml and ocamllex

"Gabriel Scherer [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAPFanBFL8a96YwnMGX0Wev6DkRiH=X9XNZVmtWJH2PzDzYYAEQ@mail.gmail.com>
Unfortunately there was a small mistake in the documentation for refill
handlers (which was written for an earlier version of the feature). It was
fixed in

https://github.com/ocaml/ocaml/commit/0d9154a1a8d36aa56f79e55c0d3422c0f39352e0
but is not present in the released documentation.

On Sun, Nov 29, 2015 at 10:23 PM, Sébastien Dailly
[email protected] [ocaml_beginners] <
[email protected]> wrote:

>
>
> Le 21/11/2015 20:02, Sébastien Dailly [email protected]
> [ocaml_beginners] a écrit :
> >
> >
> > Hello,
> >
> > I'm looking for a documentation for js_of_ocaml
> >
> > - Reading a local file with the File api
> > - Send the data to ocamllex/menhir
> >
> > is there some examples available ?
> >
>
> Hello,
>
> I'm trying to experiment Lexer and refill function but does not
> understand how it works :
>
> I've used the example provided by the document :
>
> > {
> > type token = EOL | INT of int | PLUS
> >
> > module Make (M : sig
> > type 'a t
> > val return: 'a -> 'a t
> > val bind: 'a t -> ('a -> 'b t) -> 'b t
> > val fail : exn -> 'a t
> >
> > (* Set up lexbuf *)
> > val on_refill : Lexing.lexbuf -> unit t
> > end)
> > = struct
> >
> > let refill_handler k lexbuf arg =
> > M.bind (M.on_refill lexbuf) (fun () -> k lexbuf arg)
> >
> > }
> >
> > refill {refill_handler}
> >
> > rule token = parse
> > | [' ' '\t']
> > { token lexbuf }
> > | '\n'
> > { M.return EOL }
> > | ['0'-'9']+ as i
> > { M.return (INT (int_of_string i)) }
> > | '+'
> > { M.return PLUS }
> > | _
> > { M.fail (Failure "unexpected character") }
> > {
> > end
> > }
>
> with a simple example :
>
> main.ml :
> >
> > module L = Lexer.Make(struct
> > include Lwt
> >
> > let on_refill lexer =
> > Lwt.return_unit
> >
> > end)
>
> But this does not compile, and I don't understand this error message :
>
> $ ocamlbuild -pkgs lwt main.native
> File "lexer.ml", line 152, characters 9-55:
> Error: This expression has type token M.t
>        but an expression was expected of type 'a -> 'b M.t
>
> What did I did wrong ? It seems that the errors comes from the generated
> lexer.
>
> Thanks for your help !
>
> --
> Sébastien
>
>
> ------------------------------------
> Posted by: =?UTF-8?Q?S=c3=a9bastien_Dailly?= <[email protected]>
> ------------------------------------
>
> Archives up to December 31, 2011 are also downloadable at
> http://www.connettivo.net/cntprojects/ocaml_beginners
> The archives of the very official ocaml list (the seniors' one) can be
> found at http://caml.inria.fr
> Attachments are banned and you're asked to be polite, avoid flames etc.
> ------------------------------------
>
> Yahoo Groups Links
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.