Bug 13562

Summary: export YYERRCODE to y.tab.h, add parameter support to yyparse
Product: Base System Reporter: wghicks <wghicks>
Component: binAssignee: David E. O'Brien <obrien>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description wghicks 1999-09-04 00:10:01 UTC
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 :-)
Comment 1 Jeroen Ruigrok/Asmodai 1999-09-04 09:36:50 UTC
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.
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 1999-10-07 08:04:21 UTC
Responsible Changed
From-To: freebsd-bugs->obrien

I did the last Yacc commit. 

Comment 3 David O'Brien 2000-01-16 03:10:33 UTC
Weren't there suppose to be more patches following this PR?

-- 
-- David    (obrien@NUXI.com)
Comment 4 David E. O'Brien freebsd_committer freebsd_triage 2000-11-10 18:28:37 UTC
State Changed
From-To: open->closed

There were supose to be followup patches to this PR that never were 
received.