1

I am using JFlex + BYACC/J to parse a small language.

Everything works but the error message for any syntax error (yyerror) is simply "Error: syntax error".

Is there any (easy) way of generating more verbose error messages? The -v (verbose) flag only generates a y.output file with a description of the state machine.

Goal is to have error messages such as: "Expected X before Y but found Z" or something similar.

EDIT (w.r.t comments):

Above goal can be achieved in Bison but it does not solve my problem with BYACC/J

User
  • 229
  • 3
  • 11
  • bison will produce errors of that form if you `%define parse.error verbose`, which the manual claims works in all supported languages (C, C++, Java). However, that option works best if you also `%define parse.lac full`, and that is only implemented for C. I've never tried bison's Java generator, but apparently it works. (Assuming you need Java; if you're actually producing a C parser, then I'd suggest just going with bison.) – rici Oct 10 '16 at 22:02
  • AFAIK BYACC/J is not the same as Bison. Maybe I should give Bison a try. – User Oct 11 '16 at 07:26
  • It's not the same but it's similar since both are derived from yacc. – rici Oct 11 '16 at 07:52

0 Answers0