jhjourdan / C11parser

A correct C89/C90/C99/C11/C18 parser written using Menhir and OCaml
Other
190 stars 16 forks source link

Make failed at %type<declarator> in parser_ansi_compatible.mly #1

Closed hnakamur closed 7 years ago

hnakamur commented 7 years ago

Hi, I ran make and got the following error.

$ make
ocamlbuild -menhir "menhir --no-stdlib --unused-token IMAGINARY -lg 1 -la 1 -v" main.native
Finished, 1 target (0 cached) in 00:00:00.
+ menhir --no-stdlib --unused-token IMAGINARY -lg 1 -la 1 -v --ocamlc '/usr/bin/ocamlc -w @1..49-4-9-41-44' --explain --infer parser.mly
Grammar has 127 nonterminal symbols, among which 1 start symbols.
Grammar has 97 terminal symbols.
Grammar has 305 productions.
Built an LR(0) automaton with 506 states.
The grammar is not SLR(1) -- 15 states have a conflict.
Built an LR(1) automaton with 506 states.
One shift/reduce conflict was silently solved.
Warning: one state has reduce/reduce conflicts.
Warning: 3 reduce/reduce conflicts were arbitrarily resolved.
+ menhir --no-stdlib --unused-token IMAGINARY -lg 1 -la 1 -v --external-tokens Parser --raw-depend --ocamldep '/usr/bin/ocamldep -modules' parser_ansi_compatible.mly > parser_ansi_compatible.mly.depends
File "parser_ansi_compatible.mly", line 44, characters 29-46:
Error: how is this symbol parameterized?
It is used at sorts * -> * and *.
The sort * -> * is not compatible with the sort *.
Command exited with code 1.
Compilation unsuccessful after building 14 targets (0 cached) in 00:00:01.
Makefile:16: recipe for target 'all' failed
make: *** [all] Error 10

My environment information:

$ ocaml -version
The OCaml toplevel, version 4.02.3
$ opam show menhir | grep installed-version:
   installed-version: 20160825 [system]
$ git rev-parse HEAD
9e7237e43a916bf20a917689afe8ec3d7214216a

Could you tell me how to fix it? Thanks!

jhjourdan commented 7 years ago

This is a problem of incompatibility with this recent version of Menhir. Should be fixed by commit 22d42c957ed2.

The problem is that %type declaration do no longer work with parameterized non-terminals. Is this intended, @fpottier ?

hnakamur commented 7 years ago

I confirmed make finishes successfully with commit https://github.com/jhjourdan/C11parser/commit/22d42c957ed273b90784b261be44a34828f598e7. Thanks for the fix!

fpottier commented 7 years ago

Le 08/10/2016 15:03, Jacques-Henri Jourdan a écrit :

The problem is that %type declaration do no longer work with parameterized non-terminals. Is this intended, @fpottier https://github.com/fpottier ?

They should still work (if they don't, that's a bug).

I discovered that they were not properly kind-checked and tried to fix that, but I may have made a mistake.

François Pottier francois.pottier@inria.fr http://gallium.inria.fr/~fpottier/

jhjourdan commented 7 years ago

What do you mean by "properly kind-checked"? Should %type-annotated non-terminal have kind * ?

If that's the case, then, is there a way to declare generically the type of a parameterized non-terminal, independently of its parameter?

If you are speaking of something else, then you should look at file parser_ansi_compatible.mly, commit 9e7237e43a916bf20a917689afe8ec3d7214216a.

fpottier commented 7 years ago

Salut Jacques-Henri,

Le 09/10/2016 10:28, Jacques-Henri Jourdan a écrit :

What do you mean by "properly kind-checked"? Should %type-annotated non-terminal have kind * ?

Yes, I added this rule (which had been omitted).

If that's the case, then, is there a way to declare generically the type of a parameterized non-terminal, independently of its parameter?

No!

If you are speaking of something else, then you should look at file parser_ansi_compatible.mly, commit 9e7237e

Were you able to work around the restriction that I introduced?

François Pottier francois.pottier@inria.fr http://gallium.inria.fr/~fpottier/

jhjourdan commented 7 years ago

Were you able to work around the restriction that I introduced?

Yes. I simply removed the %type declaration.