Skip to content

Generated files for C++ do not throw parse_error #493

Description

@MagicWinnie

I am running following command for generation:
bnfc --cpp -l -m -o src/Stella -p Stella Stella.cf

I get this Test.C file:

...
  Stella::Program *parse_tree = NULL;
  try {
  parse_tree = Stella::pProgram(input);
  } catch( Stella::parse_error &e) {
     std::cerr << "Parse error on line " << e.getLine() << "\n";
  }
...

But it does not throw parse_error when given a faulty input, in fact, it just prints following:

error: 1,1: syntax error at <....>

I found this PR that added parse_error: #288

But the file source/src/BNFC/Backend/CPP/STL/CFtoBisonSTL.hs is absent in 2.9.5 version, I assume BNFC uses somehow the C related stuff to generate the .y file. This is the generated Stella.y file that I get:

...
void yyerror(YYLTYPE *loc, yyscan_t scanner, YYSTYPE *result, const char *msg)
{
  fprintf(stderr, "error: %d,%d: %s at %s\n",
    loc->first_line, loc->first_column, msg, Stellaget_text(scanner));
}
...

I assume that here should be something like throw Stella::parse_error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++error-reportingConcerning error messages BNFC givesparserIssues concerning parser generatingregression in 2.9.2Regression that first appeared in BNFC 2.9.2

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions