%term xxif 300 xxelse 301 xxwhile 302 xxrept 303 xxdo 304 xxrb 305 xxpred 306
%term xxident 307 xxle 308 xxge 309 xxne 310 xxnum 311 xxcom 312
%term xxstring 313 xxexplist 314 xxidpar 315 xxelseif 316 xxlb 318 xxend 319
%term xxcase 320 xxswitch 321 xxuntil 322 xxdefault 323
%binary '<' '>' xxeq xxne xxge xxle
stat: iftok pred nlevel elsetok nlevel
| xxtab whtok pred nlevel
| xxtab rpttok nlevel optuntil
| xxtab swtok oppred pindent lbtok caseseq xxtab rbtok mindent
if (!xxlablast) tab(xxindent);
xxnew: = putout('\n',"\n");
nlevel: pindent stat mindent;
if (xxstack[xxstind] != xxlb)
{if (xxstack[xxstind] != xxlb && xxstack[xxstind] != xxelseif)
casetok: xxtab xxctok predlist pindent prog mindent
| xxtab xxctok predlist pindent mindent
| xxtab deftok pindent prog mindent
xxctok: xxcase = {putout(xxcase,"case "); free ($1); push(xxcase); }
deftok: xxdefault ':' = {
putout(xxcase,"default");
swtok: xxswitch = {putout(xxswitch,"switch"); free($1); push(xxswitch); }
identtok: xxident '(' explist ')' = {
xxt = addroot($1,xxident,0,0);
$$ = addroot("",xxidpar,xxt,$3);
| xxident = $$ = addroot($1,xxident,0,0);
predlist: explist ':' = {
explist: expr ',' explist = $$ = addroot($2,xxexplist,checkneg($1,0),$3);
| expr = $$ = checkneg($1,0);
pred: '(' expr ')' = { t = checkneg($2,0);
yield(t,100); freetree(t); };
expr: '(' expr ')' = $$ = $2;
| '-' expr %prec xxuminus = $$ = addroot($1,xxuminus,$2,0);
| '!' expr = $$ = addroot($1,'!',$2,0);
| expr '+' expr = $$ = addroot($2,'+',$1,$3);
| expr '-' expr = $$ = addroot($2,'-',$1,$3);
| expr '*' expr = $$ = addroot($2,'*',$1,$3);
| expr '/' expr = $$ = addroot($2,'/',$1,$3);
| expr '^' expr = $$ = addroot($2,'^',$1,$3);
| expr '|' expr = $$ = addroot($2,'|',$1,$3);
| expr '&' expr = $$ = addroot($2,'&',$1,$3);
| expr '>' expr = $$ = addroot($2,'>',$1,$3);
| expr '<' expr = $$ = addroot($2,'<',$1,$3);
| expr xxeq expr = $$ = addroot($2,xxeq,$1,$3);
| expr xxle expr = $$ = addroot($2,xxle,$1,$3);
| expr xxge expr = $$ = addroot($2,xxge,$1,$3);
| expr xxne expr = $$ = addroot($2,xxne,$1,$3);
| xxnum = $$ = addroot($1,xxnum,0,0);
| xxstring = $$ = addroot($1,xxstring,0,0);
if (xxstack[xxstind] == xxelse && !xxlablast)
xxstack[xxstind] = xxelseif;
optuntil: xxtab unttok pred
dopart: xxdo identtok '=' expr ',' expr =
rbtok: '}' = { putout('}',"}"); pop(); }
comtok: xxcom = { putout(xxcom,$1); free($1); xxlablast = 0; }
| comtok xxcom = { putout ('\n',"\n"); putout(xxcom,$2); free($2); xxlablast = 0; };
#define ASSERT(X,Y) if (!(X)) error("struct bug: assertion 'X' invalid in routine Y","","");
fprintf(stderr,"\n%s",s);
fprintf(stderr," in beautifying, output line %d,",xxlineno + 1);
fprintf(stderr," on input: ");
case '\t': fprintf(stderr,"\\t\n"); return;
case '\n': fprintf(stderr,"\\n\n"); return;
case '\0': fprintf(stderr,"$end\n"); return;
default: fprintf(stderr,"%c\n",yychar); return;
yyinit(argc, argv) /* initialize pushdown store */
if ( signal(SIGINT, SIG_IGN) != SIG_IGN)
putout(type,string) /* output string with proper indentation */
if ( (lasttype != 0) && (lasttype != '\n') && (lasttype != ' ') && (lasttype != '\t') && (type == xxcom))
else if (lasttype == xxcom && type != '\n')
(lasttype == xxident && (type == xxident || type == xxnum) ) ||
(lasttype == xxnum && type == xxnum) )
accum(token) /* fill output buffer, generate continuation lines */
static int lstatus,llen,bufind;
buffer = malloc(xxmaxchars);
if (buffer == 0) error("malloc out of space","","");
for (i = 0; i < tlen; ++i)
ASSERT(token[i] != '\n' || tlen == 1,accum);
case '\n': tstatus = NEW;
case '(': tstatus = CONT;
if (llen + bufind + tlen > xxmaxchars && lstatus == CONT && tstatus != NEW)
for (i = 0; i < xxindent; ++i)
putchar(' ');putchar(' ');
llen = 2 + xxindent * xxbpertab;
if (lstatus == CONT && tstatus == MID)
{ /* store in buffer in case need \n after last CONT char */
ASSERT(bufind + tlen < xxmaxchars,accum);
for (i = 0; i < tlen; ++i)
buffer[bufind++] = token[i];
for (i = 0; i < bufind; ++i)
for (i = 0; i < tlen; ++i)
if (tstatus == NEW) ++xxlineno;
llen = (tstatus == NEW) ? 0 : llen + tlen;
error(mess1, mess2, mess3)
char *mess1, *mess2, *mess3;
fprintf(stderr,"\nerror in beautifying, output line %d: %s %s %s \n",
xxlineno, mess1, mess2, mess3);
error("nesting too deep, stack overflow","","");
error("stack exhausted, can't be popped as requested","","");
while( (xxval = yylex()) != '\n')