Source-Changes-HG archive

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

[src/trunk]: src/bin/sh remove redundant declaration of yyparse, and move cod...



details:   https://anonhg.NetBSD.org/src/rev/4a15e24ba791
branches:  trunk
changeset: 503306:4a15e24ba791
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 04 19:51:43 2001 +0000

description:
remove redundant declaration of yyparse, and move code to the bottom of
the file.

diffstat:

 bin/sh/arith.y |  116 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 58 insertions(+), 58 deletions(-)

diffs (151 lines):

diff -r 23f92c79f1da -r 4a15e24ba791 bin/sh/arith.y
--- a/bin/sh/arith.y    Sun Feb 04 19:51:14 2001 +0000
+++ b/bin/sh/arith.y    Sun Feb 04 19:51:43 2001 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $      */
+/*     $NetBSD: arith.y,v 1.14 2001/02/04 19:51:43 christos Exp $      */
 
 /*-
  * Copyright (c) 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)arith.y    8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $");
+__RCSID("$NetBSD: arith.y,v 1.14 2001/02/04 19:51:43 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -56,12 +56,67 @@
 const char *arith_buf, *arith_startbuf;
 
 void yyerror __P((const char *));
-int yyparse __P((void));
 #ifdef TESTARITH
 int main __P((int , char *[]));
 int error __P((char *));
 #endif
 
+%}
+%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN
+
+%left ARITH_OR
+%left ARITH_AND
+%left ARITH_BOR
+%left ARITH_BXOR
+%left ARITH_BAND
+%left ARITH_EQ ARITH_NE
+%left ARITH_LT ARITH_GT ARITH_GE ARITH_LE
+%left ARITH_LSHIFT ARITH_RSHIFT
+%left ARITH_ADD ARITH_SUB
+%left ARITH_MUL ARITH_DIV ARITH_REM
+%left ARITH_UNARYMINUS ARITH_UNARYPLUS ARITH_NOT ARITH_BNOT
+%%
+
+exp:   expr = {
+                       return ($1);
+               }
+       ;
+
+
+expr:  ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
+       | expr ARITH_OR expr    = { $$ = $1 ? $1 : $3 ? $3 : 0; }
+       | expr ARITH_AND expr   = { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; }
+       | expr ARITH_BOR expr   = { $$ = $1 | $3; }
+       | expr ARITH_BXOR expr  = { $$ = $1 ^ $3; }
+       | expr ARITH_BAND expr  = { $$ = $1 & $3; }
+       | expr ARITH_EQ expr    = { $$ = $1 == $3; }
+       | expr ARITH_GT expr    = { $$ = $1 > $3; }
+       | expr ARITH_GE expr    = { $$ = $1 >= $3; }
+       | expr ARITH_LT expr    = { $$ = $1 < $3; }
+       | expr ARITH_LE expr    = { $$ = $1 <= $3; }
+       | expr ARITH_NE expr    = { $$ = $1 != $3; }
+       | expr ARITH_LSHIFT expr = { $$ = $1 << $3; }
+       | expr ARITH_RSHIFT expr = { $$ = $1 >> $3; }
+       | expr ARITH_ADD expr   = { $$ = $1 + $3; }
+       | expr ARITH_SUB expr   = { $$ = $1 - $3; }
+       | expr ARITH_MUL expr   = { $$ = $1 * $3; }
+       | expr ARITH_DIV expr   = {
+                       if ($3 == 0)
+                               yyerror("division by zero");
+                       $$ = $1 / $3;
+                       }
+       | expr ARITH_REM expr   = {
+                       if ($3 == 0)
+                               yyerror("division by zero");
+                       $$ = $1 % $3;
+                       }
+       | ARITH_NOT expr        = { $$ = !($2); }
+       | ARITH_BNOT expr       = { $$ = ~($2); }
+       | ARITH_SUB expr %prec ARITH_UNARYMINUS = { $$ = -($2); }
+       | ARITH_ADD expr %prec ARITH_UNARYPLUS = { $$ = $2; }
+       | ARITH_NUM
+       ;
+%%
 int
 arith(s)
        const char *s;
@@ -134,62 +189,7 @@
        exit(1);
 }
 #endif
-%}
-%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN
 
-%left ARITH_OR
-%left ARITH_AND
-%left ARITH_BOR
-%left ARITH_BXOR
-%left ARITH_BAND
-%left ARITH_EQ ARITH_NE
-%left ARITH_LT ARITH_GT ARITH_GE ARITH_LE
-%left ARITH_LSHIFT ARITH_RSHIFT
-%left ARITH_ADD ARITH_SUB
-%left ARITH_MUL ARITH_DIV ARITH_REM
-%left ARITH_UNARYMINUS ARITH_UNARYPLUS ARITH_NOT ARITH_BNOT
-%%
-
-exp:   expr = {
-                       return ($1);
-               }
-       ;
-
-
-expr:  ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
-       | expr ARITH_OR expr    = { $$ = $1 ? $1 : $3 ? $3 : 0; }
-       | expr ARITH_AND expr   = { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; }
-       | expr ARITH_BOR expr   = { $$ = $1 | $3; }
-       | expr ARITH_BXOR expr  = { $$ = $1 ^ $3; }
-       | expr ARITH_BAND expr  = { $$ = $1 & $3; }
-       | expr ARITH_EQ expr    = { $$ = $1 == $3; }
-       | expr ARITH_GT expr    = { $$ = $1 > $3; }
-       | expr ARITH_GE expr    = { $$ = $1 >= $3; }
-       | expr ARITH_LT expr    = { $$ = $1 < $3; }
-       | expr ARITH_LE expr    = { $$ = $1 <= $3; }
-       | expr ARITH_NE expr    = { $$ = $1 != $3; }
-       | expr ARITH_LSHIFT expr = { $$ = $1 << $3; }
-       | expr ARITH_RSHIFT expr = { $$ = $1 >> $3; }
-       | expr ARITH_ADD expr   = { $$ = $1 + $3; }
-       | expr ARITH_SUB expr   = { $$ = $1 - $3; }
-       | expr ARITH_MUL expr   = { $$ = $1 * $3; }
-       | expr ARITH_DIV expr   = {
-                       if ($3 == 0)
-                               yyerror("division by zero");
-                       $$ = $1 / $3;
-                       }
-       | expr ARITH_REM expr   = {
-                       if ($3 == 0)
-                               yyerror("division by zero");
-                       $$ = $1 % $3;
-                       }
-       | ARITH_NOT expr        = { $$ = !($2); }
-       | ARITH_BNOT expr       = { $$ = ~($2); }
-       | ARITH_SUB expr %prec ARITH_UNARYMINUS = { $$ = -($2); }
-       | ARITH_ADD expr %prec ARITH_UNARYPLUS = { $$ = $2; }
-       | ARITH_NUM
-       ;
-%%
 void
 yyerror(s)
        const char *s;



Home | Main Index | Thread Index | Old Index