Generating a C++ parser from this grammar[1] produces code that crashes under clang++. The reason is that bnfc it doesn't write a return statement in the initialize_lexer function:
int initialize_lexer(FILE *inp) { yyrestart(inp); BEGIN YYINITIAL; }
BEGIN is #defined as #define BEGIN (yy_start) = 1 + 2 * and YYINITIAL as #define YYINITIAL 1.
So there is no return in this function which will result in SIGILL when compiled with clang++ (because it's undefined behavior in C++).
A simple fix for me was to add a simple "return 0;" at the end because the return value is never used in my parser. Looking at the code in bfnc that generates the lexer that doesn't seem like a reuseable fix though.
[1] http://www.cse.chalmers.se/edu/year/2016/course/DAT151_Programming_Language_Technology/laborations/lab2/CPP.cf
Generating a C++ parser from this grammar[1] produces code that crashes under clang++. The reason is that bnfc it doesn't write a return statement in the initialize_lexer function:
BEGIN is #defined as
#define BEGIN (yy_start) = 1 + 2 *and YYINITIAL as#define YYINITIAL 1.So there is no return in this function which will result in SIGILL when compiled with clang++ (because it's undefined behavior in C++).
A simple fix for me was to add a simple "return 0;" at the end because the return value is never used in my parser. Looking at the code in bfnc that generates the lexer that doesn't seem like a reuseable fix though.
[1] http://www.cse.chalmers.se/edu/year/2016/course/DAT151_Programming_Language_Technology/laborations/lab2/CPP.cf