From: Bill Joy Date: Mon, 19 Nov 1979 08:10:23 +0000 (-0800) Subject: BSD 3 development X-Git-Tag: BSD-3~707 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/e2816c8fbe33e87ac78c642281216953b781e9d6 BSD 3 development Work on file usr/src/cmd/cpp/cpy.y Synthesized-from: 3bsd --- diff --git a/usr/src/cmd/cpp/cpy.y b/usr/src/cmd/cpp/cpy.y new file mode 100644 index 0000000000..a93b80fa1a --- /dev/null +++ b/usr/src/cmd/cpp/cpy.y @@ -0,0 +1,80 @@ +%term number stop DEFINED +%term EQ NE LE GE LS RS +%term ANDAND OROR +%left ',' +%right '=' +%right '?' ':' +%left OROR +%left ANDAND +%left '|' '^' +%left '&' +%binary EQ NE +%binary '<' '>' LE GE +%left LS RS +%left '+' '-' +%left '*' '/' '%' +%right '!' '~' UMINUS +%left '(' '.' +%% +S: e stop ={return($1);} + + +e: e '*' e + ={$$ = $1 * $3;} + | e '/' e + ={$$ = $1 / $3;} + | e '%' e + ={$$ = $1 % $3;} + | e '+' e + ={$$ = $1 + $3;} + | e '-' e + ={$$ = $1 - $3;} + | e LS e + ={$$ = $1 << $3;} + | e RS e + ={$$ = $1 >> $3;} + | e '<' e + ={$$ = $1 < $3;} + | e '>' e + ={$$ = $1 > $3;} + | e LE e + ={$$ = $1 <= $3;} + | e GE e + ={$$ = $1 >= $3;} + | e EQ e + ={$$ = $1 == $3;} + | e NE e + ={$$ = $1 != $3;} + | e '&' e + ={$$ = $1 & $3;} + | e '^' e + ={$$ = $1 ^ $3;} + | e '|' e + ={$$ = $1 | $3;} + | e ANDAND e + ={$$ = $1 && $3;} + | e OROR e + ={$$ = $1 || $3;} + | e '?' e ':' e + ={$$ = $1 ? $3 : $5;} + | e ',' e + ={$$ = $3;} + | term + ={$$ = $1;} +term: + '-' term %prec UMINUS + ={$$ = -$1;} + | '!' term + ={$$ = !$2;} + | '~' term + ={$$ = ~$2;} + | '(' e ')' + ={$$ = $2;} + | DEFINED '(' number ')' + ={$$= $3;} + | DEFINED number + ={$$ = $2;} + | number + ={$$= $1;} +%% +# include "yylex.c"