BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
582 stars 161 forks source link

Error location missing with recent `menhir` (starting with 2021-12-30 release) #414

Closed andreasabel closed 2 years ago

andreasabel commented 2 years ago

Recent menhir departs in its error handling from ocamlyacc. With ocamlyacc:

bnfc/testing/regression-tests/100_coercion_lists$ ocaml/TestTest bad01.in 
Parse error at 1.9-1.10
(exitcode 1)

With menhir:

$ ocaml-menhir/TestTest bad01.in 
Fatal error: exception ParTest.MenhirBasics.Error
(exitcode 2)

Upstream issue:

andreasabel commented 2 years ago

We could get rid of the error rules (entrypoints) altogether and let the user catch Parsing.Parse_error (ocamlyacc) or <Lang>.Error (menhir). For menhir, we have no choice than to do this. For ocamlyacc, we keep the error rules for now so that we do not change the API without need. Getting rid of these in the future we could also retire the BNFC_Util module. Maybe in 3.0.