home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
USCX
/
YACC.ARC
/
CPY.Y
next >
Wrap
Text File
|
1986-03-29
|
2KB
|
157 lines
%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
={$$ = !$1;}
| '~' term
={$$ = ~$1;}
| '(' e ')'
={$$ = $2;}
| DEFINED '(' number ')'
={$$= $3;}
| DEFINED number
={$$ = $2;}
| number
={$$= $1;}
%%
# include "yylex.c"
| DEFINED number
={$$ = $2;}
| number
={$$= $1;}
%%
# include "yylex.c"