Skip to content

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

@MagicWinnie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions