Skip to content

Commit

Permalink
Catch lexer error and print a nicer error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Apr 15, 2020
1 parent 4a6b4b2 commit dc2ff9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Makefile
@@ -1,13 +1,11 @@
apigen.native: $(wildcard *.ml* src/*.ml*)
dune clean
dune build --profile release
cp _build/default/apigen.exe $@

test/%/dune: test/dune-template Makefile
sed -e 's/%NAME%/$*/g' $< > $@

check: $(patsubst %,%dune,$(dir $(wildcard test/*/*.api.h)))
dune clean
BISECT_ENABLE=yes dune runtest

coverage: check
Expand Down
7 changes: 5 additions & 2 deletions apigen.ml
Expand Up @@ -27,5 +27,8 @@ let () =
| [|_; "-ast" ; input|] -> main input Ast
| [|_; "-api" ; input|] -> main input Api
| _ -> print_endline "Usage: apigen <file>"
with Failure (msg) ->
print_endline ("Failure: " ^ msg)
with
| Failure msg -> print_endline ("Failure: " ^ msg)
| ApiLexer.Lexing_error (start_p, token) ->
let error = ApiPasses.format_lex_error start_p token in
print_endline ("Lexing_error: " ^ error)

0 comments on commit dc2ff9c

Please sign in to comment.