Skip to content

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

Closed

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

  1. MagicWinnie commented on Feb 1, 2025

    @MagicWinnie
    Author

    That CFtoBisonSTL.hs file containing the parse_error call was removed in #351

  2. changed the title [-]C++ generated files do not throw parse_error[/-] [+]Generated files for C++ do not throw parse_error[/+] on Feb 1, 2025
  3. added a commit that references this issue on Feb 1, 2025
  4. MagicWinnie commented on Feb 1, 2025

    @MagicWinnie
    Author

    Fixed in #494

  5. added a commit that references this issue on Oct 20, 2025
  6. added
    parser
    error-reporting
    on Oct 20, 2025
  7. added this to the 2.9.6.2 milestone on Oct 20, 2025
  8. added
    regression in 2.9.2
    on Oct 20, 2025
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-reportingparserregression in 2.9.2

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions