jhjourdan / C11parser

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

File "parser.mly", line 45, characters 15-16: Error: unexpected character(s). #10

Closed cznic closed 5 years ago

cznic commented 5 years ago

While trying to verify my environment I did

==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> ocaml --version
The OCaml toplevel, version 4.05.0
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> ocamlbuild --version
ocamlbuild 0.13.0
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> menhir --version
menhir, version 20170712
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> git --no-pager log -1
commit dcb5d5863db24e39e8a16eeb571a1387647a6e19 (HEAD -> master, origin/master, origin/HEAD, wips, ok)
Merge: 69bb4cb d15c40d
Author: Jacques-Henri Jourdan <jourgun@gmail.com>
Date:   Wed Nov 14 15:48:27 2018 +0100

    Merge pull request #8 from waldyrious/patch-1

    README: add links and format code
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> make realclean test
rm -rf _build parse
rm -f parser.output parser.tab.c
rm -f parser.y
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 --raw-depend --ocamldep 'ocamldep.opt -modules' parser.mly > parser.mly.depends
File "parser.mly", line 45, characters 15-16:
Error: unexpected character(s).
Command exited with code 1.
Compilation unsuccessful after building 6 targets (0 cached) in 00:00:00.
make: *** [Makefile:34: all] Error 10
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> 

OS: openSuse Leap 15.0 64 bit

I'd expect make realclean test to succeed and produce parser.y.

jhjourdan commented 5 years ago

menhir, version 20170712

That's the issue. You need a more recent version of Menhir. Version 20181113.

jhjourdan commented 5 years ago

I've updated the readme.

cznic commented 5 years ago

Confirming all works with updated menhir

==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> make realclean test
rm -rf _build parse
rm -f parser.output parser.tab.c
rm -f parser.y
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 'ocamlc.opt -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 --ocamlc 'ocamlc.opt -w @1..49-4-9-41-44' --explain --infer --external-tokens Parser parser_ansi_compatible.mly
Grammar has 181 nonterminal symbols, among which 1 start symbols.
Grammar has 97 terminal symbols.
Grammar has 594 productions.
Built an LR(0) automaton with 934 states.
The grammar is not SLR(1) -- 100 states have a conflict.
Built an LR(1) automaton with 934 states.
One shift/reduce conflict was silently solved.
Warning: one state has reduce/reduce conflicts.
Warning: 3 reduce/reduce conflicts were arbitrarily resolved.
Finished, 31 targets (0 cached) in 00:00:03.
mv main.native parse
cram tests/tests.t
.
# Ran 1 tests, 0 skipped, 0 failed.
==== jnml@e5-1650:~/src/github.com/jhjourdan/C11parser> 

Thank you.