| Summary: | export YYERRCODE to y.tab.h, add parameter support to yyparse | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | wghicks <wghicks> | ||||
| Component: | bin | Assignee: | David E. O'Brien <obrien> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 4.0-CURRENT | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
FWIW: patch applied cleanly to yesterday's CURRENT. Made cleanly, installed cleanly. Then after installation made world from scratch with the new yacc installed. Compiled and installed with no problems. I am in favour of the patches. JFYI, HTH. -- Jeroen Ruigrok van der Werven asmodai(at)wxs.nl The BSD Programmer's Documentation Project <http://home.wxs.nl/~asmodai> Network/Security Specialist BSD: Technical excellence at its best Might makes right. Responsible Changed From-To: freebsd-bugs->obrien I did the last Yacc commit. Weren't there suppose to be more patches following this PR? -- -- David (obrien@NUXI.com) State Changed From-To: open->closed There were supose to be followup patches to this PR that never were received. |
We have found that it is sometimes useful for lex to have YYERRCODE defined for reporting scanning errors back to yacc. The first section of the patch emits the defined value into y.tab.h The second section of the patch allows for a user specified parameter to 'yyparse()', in a manner similar to that used by bison. The names are consistent with the bison implementation but this one also allows the type of the parameter to be specified. We generate an old-style function header for 'yyparse()' in the y.tab.c outfile. Generally, we supplement this with a hand-coded prototype in a shared header file. for a desired prototype of: int yyparse __P((struct yyresult *)); ... compile like this: yacc -dv grammar.y cc -c -DYYPARSE_PARAM_TYPE="struct yyresult *" -DYYPARSE_PARAM="parm" \ y.tab.c ... use like this: ${ #include "usrtypes.h" #include "usrproto.h" }$ %token NUMBER %% goal : NUMBER { parm->value = yylval; } ; If YYPARSE_PARAM_TYPE isn't specified then "void *" is the default type If YYPARSE_PARAM is not specified then the generated code behaves exactly as traditional byacc. How-To-Repeat: Apply the patch :-)