sedlex
sedlex copied to clipboard
Bug in examples/substraction.ml?
I try to compile the code
let rec token buf =
match%sedlex buf with
| white_space -> print_endline "\tWhitespace"; token buf
| Sub (Chars "ab","b") -> print_endline "a"; token buf
| (Chars "ab"|"c") -> print_endline "abc"; token buf
| Intersect ("d", Chars "abd") -> print_endline "d"; token buf
| eof -> print_endline "\tEnd"
| any -> print_endline "Other"; token buf
| _ -> failwith "Internal failure: Reached impossible place"
let () =
let lexbuf = Sedlexing.Utf8.from_string "a b c d e" in
token lexbuf
And it said Sedlex: this pattern is not a valid regexp
, which told me the regexp Sub (Chars "ab","b")
is not valid.
I can't reproduce, did you changed something ? Can you give details about your setup ?
I also hit this problem with sedlex.1.99.2 installed from OPAM. Reproducing:
ocamlfind ocamlc -c -package sedlex -package gen substraction.ml
File "substraction.ml", line 4, characters 6-26:
Sedlex: this pattern is not a valid regexp
I am facing the similar issue. It seems we get this issue when using packages from opam and using 'ocamlfind'.
Yup, I can reproduce the error. Change Makefile
for subtraction
target to below,
subtraction$(EXE): subtraction.ml
ocamlfind ocamlc -package gen -ppx "$HOME/.opam/4.02.3/lib/sedlex/ppx_sedlex$(EXE)" -I $HOME/.opam/4.02.3/lib/sedlex -o subtraction$(EXE) -linkpkg sedlexing.cma subtraction.ml
You get the error as below,
File "subtraction.ml", line 4, characters 6-26:
Sedlex: this pattern is not a valid regexp
Makefile:22: recipe for target 'subtraction' failed
make: *** [subtraction] Error 2
Pretty sure it's because you are using the stable version and not the dev version.
Should likely be closed.
@toots, what do you think of closing this one ?
Looks like it. Anyone can re-open/resubmit if it sill occurs.