Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlbuild, menhir and keeping tokens in a separate file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Re: ocamlbuild, menhir and keeping tokens in a separate file
On 5/2/07, Joel Reymont <joelr1@gmail.com> wrote:
> Nicolas,
>
> Thank you very much for your help and answers. I'm slowly learning!
>
> I have the following in my plugin now...
>
>  > flag ["ocaml"; "parser"; "menhir" ] (A"--explain");
>
> I always want to run Menhir with --explain in the parsing phase.
>

Ok

>  > flag ["ocaml"; "parser"; "menhir"; "only_tokens" ] (A"--only-
> tokens");
>  > flag ["ocaml"; "menhir_ocamldep"; "only_tokens" ] (A"--only-tokens");
>
> I wish the tail portion could be combined, i.e. "only_tokens" ] (A"--
> only-tokens"); created once and then appended somehow. Just a minor
> wish, though, although comments are always appreciated.

That kind of factorisation is not yet available.

>  > flag ["ocaml"; "parser"; "menhir"; "ext_tokens" ] (S[A"--external-
> tokens";
>                                                         A"EasyToken";
>
> A"EasyToken.mly";
>                                                        ]);
>  > flag ["ocaml"; "menhir_ocamldep"; "ext_tokens" ] (S[A"--external-
> tokens";
>                                                      A"EasyToken";
>                                                      A"EasyToken.mly";
>                                                     ]);
>
> Is there a way to create a "hole" for A"EasyToken" that can be filled
> from the _tags file?
>
> I may have different parsers in the project and not all of then would
> use EasyToken as the external token module.

No but you can have some rules for each parser.

You can generate these rules:

let mk_ext_token parser token =
  flag ["ocaml"; "menhir_ocamldep"; "file:"^parser^".mly"]
    (S[A"--external-tokens"; A token; A(token^".mly")]);
  flag ["ocaml"; "parser"; "menhir"; "file:"^parser^".mly"]
    (S[A"--base"; A parser]);
  ....

[...]

> What happens when I run ocamlbuild?
>
> ocamlbuild Test.byte
> + /usr/local/bin/menhir --external-tokens EasyToken EasyToken.mly --
> base EasyParser --raw-depend --ocamldep '/usr/local/bin/ocamldep.opt -
> modules' EasyParser.mly > EasyParser.mly.depends
> Error: EasyToken.mly: No such file or directory
>
> Why are the external tokens and base options used above???
>
> And why is EasyToken.mly not found?
>
> What did I get wrong in my plugin and tags file?

>From here I don't know why it fails...

-- 
Nicolas Pouillard