From: Joe K. <kr...@ni...> - 2008-10-02 15:22:41
|
In trying to understand the source code, I found that --main and --nomain don't work because the flags set user_defs instead of setting m4 macros. The %top scanning is not well-implemented. It counts braces, and can easily be misled with comments. It should have ended with '%}' like other code sections. Maybe it's not too late to change, and use the current syntax only when '%}' is not found? The code also defined YY_INT_ALIGNED as "short int" or "long int" even though the actual table code uses int32_t and int16_t for C99, or "short int" and "int". It probably is not used much externally, and maybe really can just be skipped? I also think the reentrant code is not designed well. It expects the yylval and yylloc arguments to yylex() to have a "_param" suffix, even for the non-reentrant version. This interferes with an external YY_DECL definition, which normally expects not to have the _param suffix. Another problem is that user code inserted at the beginning of yylex() also has to use the _param suffix because the arguments are not yet copied to the local or struct variables. My suggestion is to leave the suffix off, and insert the yylval access macros after the beginning of yylex(). To avoid breaking existing code that already uses the _param suffix, there could be a CPP macro that allows the user to define the name of the yylval and yylloc args. In addition, it should be possible to not have yylval or yylloc args, but still support them in the scanner, via the set/get functions. Right now, the set functions are nearly useless because yylex() always sets them at the beginning of a call. Joe Krahn |