%term LETTER DIGIT SQRT LENGTH _IF FFF EQ
%term _WHILE _FOR NE LE GE INCR DECR
%term _RETURN _BREAK _DEFINE BASE OBASE SCALE
%term EQPL EQMI EQMUL EQDIV EQREM EQEXP
char cary[1000], *cp = { cary };
char string[1000], *str = {string};
int rcrs = '0'; /* reset crs */
" 0", " 1", " 2", " 3", " 4", " 5",
" 6", " 7", " 8", " 9", " 10", " 11",
| start def dargs ')' '{' dlist slist '}'
={ bundle( 6,pre, $7, post ,"0",numb[lev],"Q");
={ bundle(2, $1, "ps." ); }
={ bundle(3,"[",$1,"]P");}
={ bundle(3, $3, "s", $1 ); }
={ bundle(4, $6, $3, ":", geta($1)); }
={ bundle(6, "l", $1, $3, $2, "s", $1 ); }
| LETTER '[' e ']' EQOP e
={ bundle(8,$3, ";", geta($1), $6, $5, $3, ":", geta($1));}
={ bundle(2, numb[lev-bstack[bindx-1]], "Q" ); }
= bundle(4, $3, post, numb[lev], "Q" );
= bundle(4, "0", post, numb[lev], "Q" );
= bundle(4,"0",post,numb[lev],"Q");
= bundle(4,"K",$3,$2,"k");
= bundle(4,"I",$3,$2,"i");
= bundle(4,"O",$3,$2,"o");
| _IF CRS BLEV '(' re ')' stat
| _WHILE CRS '(' re ')' stat BLEV
={ bundle(3, $6, $4, $2 );
| fprefix CRS re ';' e ')' stat BLEV
={ bundle(5, $7, $5, "s.", $3, $2 );
bundle(5, $1, "s.", $3, $2, " " );
={ bundle(3,$4,"S",$2); }
= bundle(3, $1, $3, "=" );
= bundle(3, $1, $3, ">" );
= bundle(3, $1, $3, "<" );
= bundle(3, $1, $3, "!=" );
= bundle(3, $1, $3, "!>" );
= bundle(3, $1, $3, "!<" );
= bundle(2, $1, " 0!=" );
= bundle(3, $1, $3, "+" );
= bundle(3, $1, $3, "-" );
= bundle(3, " 0", $2, "-" );
= bundle(3, $1, $3, "*" );
= bundle(3, $1, $3, "/" );
= bundle(3, $1, $3, "%%" );
= bundle(3, $1, $3, "^" );
={ bundle(3,$3, ";", geta($1)); }
= bundle(4, "l", $1, "d1+s", $1 );
= bundle(4, "l", $2, "1+ds", $2 );
= bundle(4, "l", $2, "1-ds", $2 );
= bundle(4, "l", $1, "d1-s", $1 );
= bundle(7,$3,";",geta($1),"d1+",$3,":",geta($1));
= bundle(7,$4,";",geta($2),"1+d",$4,":",geta($2));
= bundle(7,$3,";",geta($1),"d1-",$3,":",geta($1));
= bundle(7,$4,";",geta($2),"1-d",$4,":",geta($2));
= bundle(4, $3, "l", getf($1), "x" );
= bundle(3, "l", getf($1), "x" );
={ bundle(2, " ", $1 ); }
={ bundle(2, " .", $2 ); }
={ bundle(4, " ", $1, ".", $3 ); }
={ bundle(3, " ", $1, "." ); }
= { bundle(2, "l", $1 ); }
={ bundle(3, $3, "ds", $1 ); }
| LETTER EQOP e %prec '='
={ bundle(6, "l", $1, $3, $2, "ds", $1 ); }
= { bundle(5,$6,"d",$3,":",geta($1)); }
| LETTER '[' e ']' EQOP e
= { bundle(9,$3,";",geta($1),$6,$5,"d",$3,":",geta($1)); }
= bundle(2,$3,"X"); /* must be before '(' e ')' */
={ bundle(2, $3, "v" ); }
= bundle(4,"K",$3,$2,"dk");
= bundle(4,"I",$3,$2,"di");
= bundle(4,"O",$3,$2,"do");
={ $$ = cp; *cp++ = '_'; }
={ $$ = cp; *cp++ = $1; }
={ $$ = cp; *cp++ = crs++; *cp++ = '\0';
if(crs >= 0241){yyerror("program too big");
bstack[bindx++] = lev++; }
01,0,02,0,03,0,04,0,05,0,06,0,07,0,010,0,011,0,012,0,013,0,014,0,015,0,016,0,017,0,
020,0,021,0,022,0,023,0,024,0,025,0,026,0,027,0,030,0,031,0,032,0 };
0241,0,0242,0,0243,0,0244,0,0245,0,0246,0,0247,0,0250,0,0251,0,0252,0,0253,0,
0254,0,0255,0,0256,0,0257,0,0260,0,0261,0,0262,0,0263,0,0264,0,0265,0,0266,0,
0267,0,0270,0,0271,0,0272,0};
"a","b","c","d","e","f","g","h","i","j",
"k","l","m","n","o","p","q","r","s","t",
"u","v","w","x","y","z" } ;
while( c == ' ' || c == '\t' ) c = getch();
if( c<= 'z' && c >= 'a' ) {
/* look ahead to look for reserved words */
if( peekc >= 'a' && peekc <= 'z' ){ /* must be reserved word */
if( c=='i' && peekc=='f' ){ c=_IF; goto skip; }
if( c=='w' && peekc=='h' ){ c=_WHILE; goto skip; }
if( c=='f' && peekc=='o' ){ c=_FOR; goto skip; }
if( c=='s' && peekc=='q' ){ c=SQRT; goto skip; }
if( c=='r' && peekc=='e' ){ c=_RETURN; goto skip; }
if( c=='b' && peekc=='r' ){ c=_BREAK; goto skip; }
if( c=='d' && peekc=='e' ){ c=_DEFINE; goto skip; }
if( c=='s' && peekc=='c' ){ c= SCALE; goto skip; }
if( c=='b' && peekc=='a' ){ c=BASE; goto skip; }
if( c=='i' && peekc == 'b'){ c=BASE; goto skip; }
if( c=='o' && peekc=='b' ){ c=OBASE; goto skip; }
if( c=='d' && peekc=='i' ){ c=FFF; goto skip; }
if( c=='a' && peekc=='u' ){ c=_AUTO; goto skip; }
if( c == 'l' && peekc=='e'){ c=LENGTH; goto skip; }
if( c == 'q' && peekc == 'u'){getout();}
skip: /* skip over rest of word */
while( (ch = getch()) >= 'a' && ch <= 'z' );
/* usual case; just one single letter */
if( c>= '0' && c <= '9' || c>= 'A' && c<= 'F' ){
switch( peekc = getch() ){
case '=': c=EQ; goto gotit;
case '+': c=EQPL; goto gotit;
case '-': c=EQMI; goto gotit;
case '*': c=EQMUL; goto gotit;
case '/': c=EQDIV; goto gotit;
case '%': c=EQREM; goto gotit;
case '^': c=EQEXP; goto gotit;
gotit: peekc = -1; return(c);
case '+': return( cpeek( '+', INCR, '+' ) );
case '-': return( cpeek( '-', DECR, '-' ) );
case '<': return( cpeek( '=', LE, '<' ) );
case '>': return( cpeek( '=', GE, '>' ) );
case '!': return( cpeek( '=', NE, '!' ) );
if((peekc = getch()) == '*'){
while((getch() != '*') || ((peekc = getch()) != '/'));
while((c=getch()) != '"'){*str++ = c;
if(str >= &string[999]){yyerror("string space exceeded");
if( (peekc=getch()) != c ) return( no );
ch = (peekc < 0) ? getc(in) : peekc;
if(ifile >= sargc+2)getout();
if((in = fopen(sargv[ifile],"r")) != NULL){
yyerror("cannot open input file");
int b_space [ b_sp_max ];
int * b_sp_nxt = { b_space };
if( bdebug ) printf("bundle %d elements at %o\n",i, q );
if( b_sp_nxt >= & b_space[b_sp_max] ) yyerror( "bundling space exceeded" );
if( bdebug ) printf("routput(%o)\n", p );
if( p >= &b_space[0] && p < &b_space[b_sp_max]){
while( *p != 0 ) routput( *p++ );
else printf( p ); /* character string */
conout( p, s ) int *p; char *s; {
if(ifile > sargc)ss="teletype";
printf("c[%s on line %d, %s]pc\n", s ,ln+1,ss);
/* puts the relevant stuff on pre and post for the letter s */
bundle(4, post, "L", s, "s." );
tp( s ) char *s; { /* same as pp, but for temps */
bundle(3, "0S", s, pre );
bundle(4, post, "L", s, "s." );
yyinit(argc,argv) int argc; char *argv[];{
signal( 2, (int(*)())1 ); /* ignore all interrupts */
else if((in = fopen(sargv[1],"r")) == NULL)
yyerror("cannot open input file");
return(&funtab[2*(*p -0141)]);
return(&atab[2*(*p - 0141)]);
if (argc > 1 && *argv[1] == '-') {
if((argv[1][1] == 'd')||(argv[1][1] == 'c')){
printf("unrecognizable argument\n");
argv[1] = "/usr/lib/lib.b";
execl("/bin/dc", "dc", "-", 0);
execl("/usr/bin/dc", "dc", "-", 0);