Having trouble with Menhir

Hey all,

I’m just getting started with Ocaml (other than using it in a class 10 years ago) and I’m trying to parse a programming language with Menhir. I’m using this ocaml-parsing project as my basis and had a little trouble installing the dependencies at first, but now I think I’ve gotten past that. My error now is something strange about all_of_float, which not only doesn’t seem to be text that exists locally it also seems difficult to google for. I think something is generating _build/default/src/Lexer.pp.ml and referring to that symbol, but I’m not sure what or why.

Here’s the full error message:

mhalair ~/scm/ocaml-parsing (master) $ make
time -p jbuilder build @install
      menhir src/Menhir_parser.{ml,mli}
File "Menhir_parser.mly", line 14, characters 21-24:
Warning: the token FOR is unused.
File "Menhir_parser.mly", line 10, characters 16-22:
Warning: the token FUNIDE is unused.
File "Menhir_parser.mly", line 26, characters 6-9:
Warning: the token NEG is unused.
File "Menhir_parser.mly", line 14, characters 15-20:
Warning: the token WHILE is unused.
File "Menhir_parser.mly", line 26, characters 0-5:
Warning: the precedence level assigned to NEG is never useful.
Warning: 13 states have shift/reduce conflicts.
Warning: 87 shift/reduce conflicts were arbitrarily resolved.
Warning: 12 states have an end-of-stream conflict.
File "Menhir_parser.mly", line 38, characters 4-8:
Warning: production prog -> defs is never reduced.
Warning: in total, 1 production is never reduced.
    ocamlopt src/.ocaml_parsing.objs/ocaml_parsing__Lexer.{cmx,o} (exit 2)
(cd _build/default && /usr/local/bin/ocamlopt.opt -w -40 -g -I src/.ocaml_parsing.objs -I /Users/xitrium/.opam/system/lib/base -I /Users/xitrium/.opam/system/lib/base/caml -I /Users/xitrium/.opam/system/lib/base/shadow_stdlib -I /Users/xitrium/.opam/system/lib/bytes -I /Users/xitrium/.opam/system/lib/gen -I /Users/xitrium/.opam/system/lib/menhirLib -I /Users/xitrium/.opam/system/lib/ppx_deriving -I /Users/xitrium/.opam/system/lib/result -I /Users/xitrium/.opam/system/lib/sedlex -I /Users/xitrium/.opam/system/lib/sexplib0 -I /Users/xitrium/.opam/system/lib/stdio -I /usr/local/lib/ocaml/compiler-libs -intf-suffix .ml -no-alias-deps -open Ocaml_parsing -o src/.ocaml_parsing.objs/ocaml_parsing__Lexer.cmx -c -impl src/Lexer.pp.ml)
File "src/Lexer.ml", line 10, characters 13-18:
Error: Unbound value all_of_float
Hint: Did you mean int_of_float?
      ocamlc src/.ocaml_parsing.objs/ocaml_parsing__Lexer.{cmo,cmt} (exit 2)
(cd _build/default && /usr/local/bin/ocamlc.opt -w -40 -g -bin-annot -I src/.ocaml_parsing.objs -I /Users/xitrium/.opam/system/lib/base -I /Users/xitrium/.opam/system/lib/base/caml -I /Users/xitrium/.opam/system/lib/base/shadow_stdlib -I /Users/xitrium/.opam/system/lib/bytes -I /Users/xitrium/.opam/system/lib/gen -I /Users/xitrium/.opam/system/lib/menhirLib -I /Users/xitrium/.opam/system/lib/ppx_deriving -I /Users/xitrium/.opam/system/lib/result -I /Users/xitrium/.opam/system/lib/sedlex -I /Users/xitrium/.opam/system/lib/sexplib0 -I /Users/xitrium/.opam/system/lib/stdio -I /usr/local/lib/ocaml/compiler-libs -intf-suffix .ml -no-alias-deps -open Ocaml_parsing -o src/.ocaml_parsing.objs/ocaml_parsing__Lexer.cmo -c -impl src/Lexer.pp.ml)
File "src/Lexer.ml", line 10, characters 13-18:
Error: Unbound value all_of_float
Hint: Did you mean int_of_float?
real         4.36      
user         2.31
sys          1.47
make: *** [build] Error 1

If I can avoid it I’d like to not post the full grammar file (I’m working from someone else’s private repo for their dissertation), but probably the relevant bit is that there is a float token:
%token <float> REAL in Menhir_parser.mly.

Any help appreciated! So confused about where this symbol is coming from - wondering if the code generation is worth it.

Can you post the production for which the error is reported? The obvious problem is that all_of_float is undefined.

all_of_float does not occur in my code at all, just in the generated binary Lexer.pp.ml, and I actually am not sure how to tell which production it would be associated with… Any tips?

Suspiciously one of the line numbers it’s pointing to is the last one here from within a generated Lexer.ml:

type token = 
  | WHILE
  | VECTOR
  | SIM
  | SEMICOLON
  | RIGHT
  | RET
  | REALTYPE
  | REAL of (float)
...<continues>

I think I got it - I’m trying to convert from an FSharp project using a more standard ocamllex style project to this ocaml-parsing's sedlex project and missed some of the lexing conversions. Weird error message though. Anyone have thoughts on sedlex vs ocamllex?

Edit: Nope, I was missing some stuff but I’m still getting this weird Error: Unbound value all_of_float. But it seems like some weird property of this sedlex library, which I will maybe try to stop using now…