Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MagicWinnie opened this issue Feb 1, 2025 · 2 comments
Open

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

MagicWinnie opened this issue Feb 1, 2025 · 2 comments

Comments

@MagicWinnie
Copy link

MagicWinnie commented Feb 1, 2025

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.

@MagicWinnie
Copy link
Author

MagicWinnie commented Feb 1, 2025

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

@MagicWinnie MagicWinnie changed the title C++ generated files do not throw parse_error Generated files for C++ do not throw parse_error Feb 1, 2025
MagicWinnie added a commit to MagicWinnie/bnfc that referenced this issue Feb 1, 2025
@MagicWinnie
Copy link
Author

Fixed in #494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant