bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02-fyi-hairy.patch


From: Akim Demaille
Subject: 02-fyi-hairy.patch
Date: Thu, 27 Dec 2001 18:57:51 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * src/bison.hairy: Formatting/comment changes.
        ANSIfy.
        Remove `register' indications.
        Add plenty of `static'.
        
Index: src/bison.hairy
--- src/bison.hairy Fri, 19 Jan 2001 21:02:00 +0100 akim
+++ src/bison.hairy Sun, 23 Dec 2001 12:02:56 +0100 akim
@@ -1,83 +1,88 @@
-                                                          /* -*- C -*- */
-extern int timeclock;
+                                                         /* -*- C -*- */
 
+/* YYERROR and YYCOST are set by guards. If yyerror is set to a
+   nonzero value by a guard, the reduction with which the guard is
+   associated is not performed, and the error recovery mechanism is
+   invoked.  Yycost indicates the cost of performing the reduction
+   given the attributes of the symbols.  */
+static int yyerror;
+static int yycost;
 
-int yyerror;           /*  Yyerror and yycost are set by guards.       */
-int yycost;            /*  If yyerror is set to a nonzero value by a   */
-                       /*  guard, the reduction with which the guard   */
-                       /*  is associated is not performed, and the     */
-                       /*  error recovery mechanism is invoked.        */
-                       /*  Yycost indicates the cost of performing     */
-                       /*  the reduction given the attributes of the   */
-                       /*  symbols.                                    */
-
-
-/*  YYMAXDEPTH indicates the size of the parser's state and value      */
-/*  stacks.                                                            */
+/* YYMAXDEPTH indicates the size of the parser's state and value
+   stacks.  */
 
 #ifndef        YYMAXDEPTH
-#define        YYMAXDEPTH      500
+# define YYMAXDEPTH 500
 #endif
 
-/*  YYMAXRULES must be at least as large as the number of rules that   */
-/*  could be placed in the rule queue.  That number could be determined        
*/
-/*  from the grammar and the size of the stack, but, as yet, it is not.        
*/
+/* YYMAXRULES must be at least as large as the number of rules that
+   could be placed in the rule queue.  That number could be determined
+   from the grammar and the size of the stack, but, as yet, it is not.
+   */
 
 #ifndef        YYMAXRULES
-#define        YYMAXRULES      100
+# define YYMAXRULES 100
 #endif
 
 #ifndef        YYMAXBACKUP
-#define YYMAXBACKUP    100
+# define YYMAXBACKUP 100
 #endif
 
 
-short  yyss[YYMAXDEPTH];       /*  the state stack                     */
-YYSTYPE        yyvs[YYMAXDEPTH];       /*  the semantic value stack            
*/
-YYLTYPE yyls[YYMAXDEPTH];      /*  the location stack                  */
-short  yyrq[YYMAXRULES];       /*  the rule queue                      */
-int    yychar;                 /*  the lookahead symbol                */
-
-YYSTYPE        yylval;                 /*  the semantic value of the           
*/
-                               /*  lookahead symbol                    */
-
-YYSTYPE yytval;                        /*  the semantic value for the state    
*/
-                               /*  at the top of the state stack.      */
-
-YYSTYPE yyval;                 /*  the variable used to return         */
-                               /*  semantic values from the action     */
-                               /*  routines                            */
-
-YYLTYPE yylloc;                /*  location data for the lookahead     */
-                               /*  symbol                              */
-
-YYLTYPE yytloc;                /*  location data for the state at the  */
-                               /*  top of the state stack              */
-
-
-int    yynunlexed;
-short  yyunchar[YYMAXBACKUP];
-YYSTYPE        yyunval[YYMAXBACKUP];
-YYLTYPE yyunloc[YYMAXBACKUP];
+/* The state stack. */
+static short yyss[YYMAXDEPTH];
+/* The semantic value stack.  */
+static YYSTYPE yyvs[YYMAXDEPTH];
+/* The location stack.  */
+static YYLTYPE yyls[YYMAXDEPTH];
+/* The rule queue. */
+static short yyrq[YYMAXRULES];
+/* The lookahead symbol. */
+static int yychar;
+
+/* the semantic value of the lookahead symbol.  */
+static YYSTYPE yylval;
+
+/* the semantic value for the state at the top of the state stack.  */
+static YYSTYPE yytval;
+
+/* the variable used to return semantic values from the action
+   routines.  */
+static YYSTYPE yyval;
+
+/* location data for the lookahead symbol.  */
+static YYLTYPE yylloc;
+
+/* location data for the state at the top of the state stack.  */
+static YYLTYPE yytloc;
+
+
+static int yynunlexed;
+static short yyunchar[YYMAXBACKUP];
+static YYSTYPE yyunval[YYMAXBACKUP];
+static YYLTYPE yyunloc[YYMAXBACKUP];
+
+/* a pointer to the top of the state stack; only set during error
+   recovery.  */
+static short *yygssp;
+
+/* a pointer to the top of the value stack; only set during error
+   recovery.  */
+static YYSTYPE *yygvsp;
+
+/* a pointer to the top of the location stack; only set during error
+   recovery.  */
+static YYLTYPE *yyglsp;
+
+
+/*--------------------------------------------------------------------.
+| Yyget is an interface between the parser and the lexical analyzer.  |
+| It is costly to provide such an interface, but it avoids requiring  |
+| the lexical analyzer to be able to back up the scan.                |
+`--------------------------------------------------------------------*/
 
-short *yygssp;                 /*  a pointer to the top of the state   */
-                               /*  stack; only set during error        */
-                               /*  recovery.                           */
-
-YYSTYPE *yygvsp;               /*  a pointer to the top of the value   */
-                               /*  stack; only set during error        */
-                               /*  recovery.                           */
-
-YYLTYPE *yyglsp;               /*  a pointer to the top of the         */
-                               /*  location stack; only set during     */
-                               /*  error recovery.                     */
-
-
-/*  Yyget is an interface between the parser and the lexical analyzer. */
-/*  It is costly to provide such an interface, but it avoids requiring */
-/*  the lexical analyzer to be able to back up the scan.               */
-
-yyget()
+static inline void
+yyget (void)
 {
   if (yynunlexed > 0)
     {
@@ -90,19 +95,17 @@
     yychar = 0;
   else
     {
-      yychar = yylex();
+      yychar = yylex ();
       if (yychar < 0)
        yychar = 0;
-      else yychar = YYTRANSLATE(yychar);
+      else
+       yychar = YYTRANSLATE (yychar);
     }
 }
 
 
-
-yyunlex(chr, val, loc)
-int chr;
-YYSTYPE val;
-YYLTYPE loc;
+static inline void
+yyunlex (int chr, YYSTYPE val, YYLTYPE loc)
 {
   yyunchar[yynunlexed] = chr;
   yyunval[yynunlexed] = val;
@@ -111,19 +114,17 @@
 }
 
 
-
-yyrestore(first, last)
-register short *first;
-register short *last;
+static inline void
+yyrestore (short *first, short *last)
 {
-  register short *ssp;
-  register short *rp;
-  register int symbol;
-  register int state;
-  register int tvalsaved;
+  short *ssp;
+  short *rp;
+  int symbol;
+  int state;
+  int tvalsaved;
 
   ssp = yygssp;
-  yyunlex(yychar, yylval, yylloc);
+  yyunlex (yychar, yylval, yylloc);
 
   tvalsaved = 0;
   while (first != last)
@@ -131,7 +132,7 @@
       symbol = yystos[*ssp];
       if (symbol < YYNTBASE)
        {
-         yyunlex(symbol, yytval, yytloc);
+         yyunlex (symbol, yytval, yytloc);
          tvalsaved = 1;
          ssp--;
        }
@@ -161,9 +162,9 @@
        }
     }
 
-  if ( ! tvalsaved && ssp > yyss)
+  if (!tvalsaved && ssp > yyss)
     {
-      yyunlex(yystos[*ssp], yytval, yytloc);
+      yyunlex (yystos[*ssp], yytval, yytloc);
       ssp--;
     }
 
@@ -173,14 +174,14 @@
 
 
 int
-yyparse()
+yyparse (void)
 {
-  register int yystate;
-  register int yyn;
-  register short *yyssp;
-  register short *yyrq0;
-  register short *yyptr;
-  register YYSTYPE *yyvsp;
+  int yystate;
+  int yyn;
+  short *yyssp;
+  short *yyrq0;
+  short *yyptr;
+  YYSTYPE *yyvsp;
 
   int yylen;
   YYLTYPE *yylsp;
@@ -195,16 +196,17 @@
   yyrq1 = yyrq0;
   yyrq2 = yyrq0;
 
-  yychar = yylex();
+  yychar = yylex ();
   if (yychar < 0)
     yychar = 0;
-  else yychar = YYTRANSLATE(yychar);
+  else
+    yychar = YYTRANSLATE (yychar);
 
 yynewstate:
 
   if (yyssp >= yyss + YYMAXDEPTH - 1)
     {
-      yyabort("Parser Stack Overflow");
+      yyabort ("Parser Stack Overflow");
       YYABORT;
     }
 
@@ -239,31 +241,30 @@ yyresume:
       yyvsp -= yylen;
       yylsp -= yylen;
 
-      yyguard(yyn, yyvsp, yylsp);
+      yyguard (yyn, yyvsp, yylsp);
       if (yyerror)
        goto yysemerr;
 
-      yyaction(yyn, yyvsp, yylsp);
+      yyaction (yyn, yyvsp, yylsp);
       *++yyvsp = yyval;
 
       yylsp++;
       if (yylen == 0)
        {
-         yylsp->timestamp = timeclock;
          yylsp->first_line = yytloc.first_line;
          yylsp->first_column = yytloc.first_column;
-         yylsp->last_line = (yylsp-1)->last_line;
-         yylsp->last_column = (yylsp-1)->last_column;
+         yylsp->last_line = (yylsp - 1)->last_line;
+         yylsp->last_column = (yylsp - 1)->last_column;
          yylsp->text = 0;
        }
       else
        {
-         yylsp->last_line = (yylsp+yylen-1)->last_line;
-         yylsp->last_column = (yylsp+yylen-1)->last_column;
+         yylsp->last_line = (yylsp + yylen - 1)->last_line;
+         yylsp->last_column = (yylsp + yylen - 1)->last_column;
        }
 
       if (yyptr == yyrq + YYMAXRULES)
-        yyptr = yyrq;
+       yyptr = yyrq;
     }
 
   if (yystate == YYFINAL)
@@ -276,7 +277,7 @@ yyresume:
   *++yylsp = yytloc;
   yytval = yylval;
   yytloc = yylloc;
-  yyget();
+  yyget ();
 
   goto yynewstate;
 
@@ -295,7 +296,7 @@ yyreduce:
 
   if (yyrq0 == yyrq2)
     {
-      yyabort("Parser Rule Queue Overflow");
+      yyabort ("Parser Rule Queue Overflow");
       YYABORT;
     }
 
@@ -320,8 +321,8 @@ yyerrlab:
   yygssp = yyssp;
   yygvsp = yyvsp;
   yyglsp = yylsp;
-  yyrestore(yyrq0, yyrq2);
-  yyrecover();
+  yyrestore (yyrq0, yyrq2);
+  yyrecover ();
   yystate = *yygssp;
   yyssp = yygssp;
   yyvsp = yygvsp;
@@ -331,4 +332,4 @@ yyerrlab:
   goto yyresume;
 }
 
-%% actions
+%%actions



reply via email to

[Prev in Thread] Current Thread [Next in Thread]