ANSI C conversion.
This commit is contained in:
parent
f9916fb680
commit
dfefbcae86
|
@ -1,9 +1,5 @@
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#ifndef NORCSID
|
|
||||||
static char rcsid[]="$Id$";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
|
@ -15,13 +11,17 @@ static char rcsid[]="$Id$";
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <em_spec.h>
|
#include "em_spec.h"
|
||||||
#include <em_flag.h>
|
#include "em_flag.h"
|
||||||
#include <em_reg.h>
|
#include "em_reg.h"
|
||||||
|
|
||||||
#define extern
|
#define INIT_VAR
|
||||||
|
#define EXTERN
|
||||||
#include "booth.h"
|
#include "booth.h"
|
||||||
#undef extern
|
#undef INIT_VAR
|
||||||
|
#undef EXTERN
|
||||||
|
|
||||||
|
extern int yylex(void);
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ tokenexpression
|
||||||
: PIDENT
|
: PIDENT
|
||||||
{ $$ = machprops[$1->i_i.i_prpno].propset; }
|
{ $$ = machprops[$1->i_i.i_prpno].propset; }
|
||||||
| TIDENT
|
| TIDENT
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
for(i=0;i<SETSIZE;i++) $$.set_val[i]=0;
|
for(i=0;i<SETSIZE;i++) $$.set_val[i]=0;
|
||||||
$$.set_val[($1->i_i.i_tokno+nmachregs+1)>>4] |=
|
$$.set_val[($1->i_i.i_tokno+nmachregs+1)>>4] |=
|
||||||
|
@ -278,7 +278,7 @@ tokenexpression
|
||||||
| EIDENT
|
| EIDENT
|
||||||
{ $$=machsets[$1->i_i.i_expno]; }
|
{ $$=machsets[$1->i_i.i_expno]; }
|
||||||
| tokenexpression '*' tokenexpression
|
| tokenexpression '*' tokenexpression
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
if (($$.set_size=$1.set_size)==0)
|
if (($$.set_size=$1.set_size)==0)
|
||||||
$$.set_size = $3.set_size;
|
$$.set_size = $3.set_size;
|
||||||
|
@ -286,7 +286,7 @@ tokenexpression
|
||||||
$$.set_val[i] = $1.set_val[i] & $3.set_val[i];
|
$$.set_val[i] = $1.set_val[i] & $3.set_val[i];
|
||||||
}
|
}
|
||||||
| tokenexpression '+' tokenexpression
|
| tokenexpression '+' tokenexpression
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
if ($1.set_size == -1)
|
if ($1.set_size == -1)
|
||||||
$$.set_size = $3.set_size;
|
$$.set_size = $3.set_size;
|
||||||
|
@ -300,7 +300,7 @@ tokenexpression
|
||||||
$$.set_val[i] = $1.set_val[i] | $3.set_val[i];
|
$$.set_val[i] = $1.set_val[i] | $3.set_val[i];
|
||||||
}
|
}
|
||||||
| tokenexpression '-' tokenexpression
|
| tokenexpression '-' tokenexpression
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
if ($1.set_size == -1)
|
if ($1.set_size == -1)
|
||||||
$$.set_size = $3.set_size;
|
$$.set_size = $3.set_size;
|
||||||
|
@ -403,7 +403,7 @@ empattern
|
||||||
: /* empty */
|
: /* empty */
|
||||||
{ empatlen=0; }
|
{ empatlen=0; }
|
||||||
| mnemlist optboolexpr
|
| mnemlist optboolexpr
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
empatexpr = $2;
|
empatexpr = $2;
|
||||||
patbyte(0);
|
patbyte(0);
|
||||||
|
@ -441,7 +441,7 @@ mnem : IDENT
|
||||||
|
|
||||||
stackpattern
|
stackpattern
|
||||||
: optnocoerc tokenexpressionlist optstack
|
: optnocoerc tokenexpressionlist optstack
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
if (tokpatlen != 0) {
|
if (tokpatlen != 0) {
|
||||||
outbyte(($1 ? ( $3 ? DO_XXMATCH: DO_XMATCH ) : DO_MATCH)+(tokpatlen<<5));
|
outbyte(($1 ? ( $3 ? DO_XXMATCH: DO_XMATCH ) : DO_MATCH)+(tokpatlen<<5));
|
||||||
|
@ -1053,7 +1053,7 @@ tokeninstanceno
|
||||||
|
|
||||||
tokeninstance
|
tokeninstance
|
||||||
: '%' '[' tokargno subreg ']'
|
: '%' '[' tokargno subreg ']'
|
||||||
{ register i;
|
{ register int i;
|
||||||
|
|
||||||
if ($4!=0)
|
if ($4!=0)
|
||||||
chkregexp(pattokexp[$3]);
|
chkregexp(pattokexp[$3]);
|
||||||
|
@ -1065,7 +1065,7 @@ tokeninstance
|
||||||
}
|
}
|
||||||
| '%' '[' tokargno '.' IDENT ']'
|
| '%' '[' tokargno '.' IDENT ']'
|
||||||
{ int typ;
|
{ int typ;
|
||||||
register i;
|
register int i;
|
||||||
$$.in_which = IN_COPY;
|
$$.in_which = IN_COPY;
|
||||||
$$.in_info[0] = $3;
|
$$.in_info[0] = $3;
|
||||||
$$.in_info[1] = findstructel(pattokexp[$3],$5,&typ);
|
$$.in_info[1] = findstructel(pattokexp[$3],$5,&typ);
|
||||||
|
@ -1075,14 +1075,14 @@ tokeninstance
|
||||||
$$.in_info[i] = 0;
|
$$.in_info[i] = 0;
|
||||||
}
|
}
|
||||||
| RIDENT
|
| RIDENT
|
||||||
{ register i;
|
{ register int i;
|
||||||
$$.in_which = IN_RIDENT;
|
$$.in_which = IN_RIDENT;
|
||||||
$$.in_info[0] = $1->i_i.i_regno;
|
$$.in_info[0] = $1->i_i.i_regno;
|
||||||
for (i=1;i<TOKENSIZE;i++)
|
for (i=1;i<TOKENSIZE;i++)
|
||||||
$$.in_info[i] = 0;
|
$$.in_info[i] = 0;
|
||||||
}
|
}
|
||||||
| REGVAR '(' expr ')'
|
| REGVAR '(' expr ')'
|
||||||
{ register i;
|
{ register int i;
|
||||||
MUST1BEINT($3);
|
MUST1BEINT($3);
|
||||||
$$.in_which = IN_REGVAR;
|
$$.in_which = IN_REGVAR;
|
||||||
$$.in_info[0] = exp1;
|
$$.in_info[0] = exp1;
|
||||||
|
@ -1090,7 +1090,7 @@ tokeninstance
|
||||||
$$.in_info[i] = 0;
|
$$.in_info[i] = 0;
|
||||||
}
|
}
|
||||||
| '%' '[' LCASELETTER subreg ']'
|
| '%' '[' LCASELETTER subreg ']'
|
||||||
{ register i;
|
{ register int i;
|
||||||
if ($3 >= 'a'+nallreg)
|
if ($3 >= 'a'+nallreg)
|
||||||
yyerror("Bad letter in %[x] construct");
|
yyerror("Bad letter in %[x] construct");
|
||||||
$$.in_which = IN_ALLOC;
|
$$.in_which = IN_ALLOC;
|
||||||
|
@ -1100,7 +1100,7 @@ tokeninstance
|
||||||
$$.in_info[i] = 0;
|
$$.in_info[i] = 0;
|
||||||
}
|
}
|
||||||
| '{' TIDENT attlist '}'
|
| '{' TIDENT attlist '}'
|
||||||
{ register i;
|
{ register int i;
|
||||||
$$.in_which = IN_DESCR;
|
$$.in_which = IN_DESCR;
|
||||||
$$.in_info[0] = $2->i_i.i_tokno;
|
$$.in_info[0] = $2->i_i.i_tokno;
|
||||||
for(i=0;i<narexp;i++) {
|
for(i=0;i<narexp;i++) {
|
||||||
|
|
197
util/cgg/booth.h
197
util/cgg/booth.h
|
@ -1,6 +1,6 @@
|
||||||
#include <local.h>
|
#include <local.h>
|
||||||
|
|
||||||
#ifdef extern
|
#ifdef INIT_VAR
|
||||||
#define INIT(x) = x
|
#define INIT(x) = x
|
||||||
#else
|
#else
|
||||||
#define INIT(x) /* empty */
|
#define INIT(x) /* empty */
|
||||||
|
@ -33,9 +33,9 @@
|
||||||
#define MAXSPLIT 4 /* Maximum degree of split */
|
#define MAXSPLIT 4 /* Maximum degree of split */
|
||||||
#define MAXNSTR 40 /* Maximum consecutive strings in coderule */
|
#define MAXNSTR 40 /* Maximum consecutive strings in coderule */
|
||||||
|
|
||||||
extern char *hname INIT("tables.h");
|
EXTERN char *hname INIT("tables.h");
|
||||||
extern char *cname INIT("tables.c");
|
EXTERN char *cname INIT("tables.c");
|
||||||
extern char *iname; /* stdin */
|
EXTERN char *iname; /* stdin */
|
||||||
|
|
||||||
/* Derived constants */
|
/* Derived constants */
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ extern char *iname; /* stdin */
|
||||||
typedef char byte;
|
typedef char byte;
|
||||||
typedef char * string;
|
typedef char * string;
|
||||||
|
|
||||||
extern char *myalloc();
|
EXTERN char *myalloc();
|
||||||
|
|
||||||
#include <cg_pattern.h>
|
#include <cg_pattern.h>
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ typedef struct ident {
|
||||||
} ident_t,*ident_p;
|
} ident_t,*ident_p;
|
||||||
|
|
||||||
#define ITABSIZE 32
|
#define ITABSIZE 32
|
||||||
extern ident_p identtab[ITABSIZE];
|
EXTERN ident_p identtab[ITABSIZE];
|
||||||
|
|
||||||
#define LOOKUP 0
|
#define LOOKUP 0
|
||||||
#define HALFWAY 1
|
#define HALFWAY 1
|
||||||
|
@ -125,90 +125,90 @@ typedef struct expr {
|
||||||
int expr_index;
|
int expr_index;
|
||||||
} expr_t,*expr_p;
|
} expr_t,*expr_p;
|
||||||
|
|
||||||
extern unsigned cc1 INIT(1),cc2 INIT(1),cc3 INIT(1),cc4 INIT(1);
|
EXTERN unsigned cc1 INIT(1),cc2 INIT(1),cc3 INIT(1),cc4 INIT(1);
|
||||||
|
|
||||||
extern node_t nodes[MAXNODES];
|
EXTERN node_t nodes[MAXNODES];
|
||||||
extern node_p lastnode INIT(nodes+1);
|
EXTERN node_p lastnode INIT(nodes+1);
|
||||||
|
|
||||||
extern string codestrings[MAXSTRINGS];
|
EXTERN string codestrings[MAXSTRINGS];
|
||||||
extern int ncodestrings;
|
EXTERN int ncodestrings;
|
||||||
|
|
||||||
extern int strar[MAXNSTR];
|
EXTERN int strar[MAXNSTR];
|
||||||
extern int nstr;
|
EXTERN int nstr;
|
||||||
|
|
||||||
extern int pathash[256];
|
EXTERN int pathash[256];
|
||||||
|
|
||||||
extern reginfo machregs[MAXREGS];
|
EXTERN reginfo machregs[MAXREGS];
|
||||||
extern char stregclass[MAXREGS];
|
EXTERN char stregclass[MAXREGS];
|
||||||
extern int nmachregs INIT(1);
|
EXTERN int nmachregs INIT(1);
|
||||||
extern int nregclasses INIT(1);
|
EXTERN int nregclasses INIT(1);
|
||||||
extern int maxmembers;
|
EXTERN int maxmembers;
|
||||||
extern struct {
|
EXTERN struct {
|
||||||
ident_p propname;
|
ident_p propname;
|
||||||
set_t propset;
|
set_t propset;
|
||||||
} machprops[MAXPROPS];
|
} machprops[MAXPROPS];
|
||||||
extern int nprops;
|
EXTERN int nprops;
|
||||||
extern token_t machtokens[MAXTOKENS];
|
EXTERN token_t machtokens[MAXTOKENS];
|
||||||
extern int nmachtokens INIT(1);
|
EXTERN int nmachtokens INIT(1);
|
||||||
extern set_t machsets[MAXSETS];
|
EXTERN set_t machsets[MAXSETS];
|
||||||
extern int nmachsets;
|
EXTERN int nmachsets;
|
||||||
extern int patmnem[MAXEMPATLEN];
|
EXTERN int patmnem[MAXEMPATLEN];
|
||||||
extern int empatlen;
|
EXTERN int empatlen;
|
||||||
extern int maxempatlen;
|
EXTERN int maxempatlen;
|
||||||
extern int empatexpr;
|
EXTERN int empatexpr;
|
||||||
extern int maxrule INIT(1);
|
EXTERN int maxrule INIT(1);
|
||||||
extern int pattokexp[MAXPATLEN];
|
EXTERN int pattokexp[MAXPATLEN];
|
||||||
extern int tokpatlen;
|
EXTERN int tokpatlen;
|
||||||
extern int lookident; /* lexical analyzer flag */
|
EXTERN int lookident; /* lexical analyzer flag */
|
||||||
extern list3 structpool;
|
EXTERN list3 structpool;
|
||||||
extern int nallreg;
|
EXTERN int nallreg;
|
||||||
extern int allreg[MAXALLREG];
|
EXTERN int allreg[MAXALLREG];
|
||||||
extern int maxallreg;
|
EXTERN int maxallreg;
|
||||||
extern int lino;
|
EXTERN int lino;
|
||||||
extern int nerrors;
|
EXTERN int nerrors;
|
||||||
extern int curtokexp;
|
EXTERN int curtokexp;
|
||||||
extern expr_t arexp[TOKENSIZE];
|
EXTERN expr_t arexp[TOKENSIZE];
|
||||||
extern int narexp;
|
EXTERN int narexp;
|
||||||
extern inst_t arinstance[MAXINSTANCE];
|
EXTERN inst_t arinstance[MAXINSTANCE];
|
||||||
extern int narinstance INIT(1);
|
EXTERN int narinstance INIT(1);
|
||||||
extern move_t machmoves[NMOVES];
|
EXTERN move_t machmoves[NMOVES];
|
||||||
extern int nmoves;
|
EXTERN int nmoves;
|
||||||
extern byte pattern[MAXPATTERN];
|
EXTERN byte pattern[MAXPATTERN];
|
||||||
extern int npatbytes;
|
EXTERN int npatbytes;
|
||||||
extern int prevind;
|
EXTERN int prevind;
|
||||||
extern int rulecount; /* Temporary index for ... construct */
|
EXTERN int rulecount; /* Temporary index for ... construct */
|
||||||
extern int ncoderules;
|
EXTERN int ncoderules;
|
||||||
extern int codebytes;
|
EXTERN int codebytes;
|
||||||
extern FILE *cfile;
|
EXTERN FILE *cfile;
|
||||||
extern FILE *hfile;
|
EXTERN FILE *hfile;
|
||||||
extern int maxtokensize;
|
EXTERN int maxtokensize;
|
||||||
extern int dealflag;
|
EXTERN int dealflag;
|
||||||
extern int emrepllen;
|
EXTERN int emrepllen;
|
||||||
extern int replmnem[MAXEMPATLEN];
|
EXTERN int replmnem[MAXEMPATLEN];
|
||||||
extern int tokrepllen;
|
EXTERN int tokrepllen;
|
||||||
extern int replinst[MAXPATLEN];
|
EXTERN int replinst[MAXPATLEN];
|
||||||
extern int replexpr[MAXPATLEN];
|
EXTERN int replexpr[MAXPATLEN];
|
||||||
extern c1_t c1coercs[MAXC1];
|
EXTERN c1_t c1coercs[MAXC1];
|
||||||
extern c2_t c2coercs[MAXC2];
|
EXTERN c2_t c2coercs[MAXC2];
|
||||||
extern c3_t c3coercs[MAXC3];
|
EXTERN c3_t c3coercs[MAXC3];
|
||||||
extern int nc1,nc2,nc3;
|
EXTERN int nc1,nc2,nc3;
|
||||||
extern int maxsplit;
|
EXTERN int maxsplit;
|
||||||
extern int wsize INIT(-1);
|
EXTERN int wsize INIT(-1);
|
||||||
extern int psize INIT(-1);
|
EXTERN int psize INIT(-1);
|
||||||
extern int bsize INIT(-1);
|
EXTERN int bsize INIT(-1);
|
||||||
extern char *fmt;
|
EXTERN char *fmt;
|
||||||
|
|
||||||
extern int cchandled;
|
EXTERN int cchandled;
|
||||||
extern int ccspoiled;
|
EXTERN int ccspoiled;
|
||||||
extern int ccregexpr;
|
EXTERN int ccregexpr;
|
||||||
extern int ccinstanceno;
|
EXTERN int ccinstanceno;
|
||||||
extern int cocopropno;
|
EXTERN int cocopropno;
|
||||||
extern int cocosetno;
|
EXTERN int cocosetno;
|
||||||
extern int allexpno;
|
EXTERN int allexpno;
|
||||||
|
|
||||||
extern int rvused; /* regvars used */
|
EXTERN int rvused; /* regvars used */
|
||||||
extern int nregvar[4]; /* # of register variables of all kinds */
|
EXTERN int nregvar[4]; /* # of register variables of all kinds */
|
||||||
extern int rvnumbers[4][MAXREGVARS]; /* The register numbers */
|
EXTERN int rvnumbers[4][MAXREGVARS]; /* The register numbers */
|
||||||
|
|
||||||
#define chktabsiz(size,maxsize,which) if(size>=maxsize) tabovf(which)
|
#define chktabsiz(size,maxsize,which) if(size>=maxsize) tabovf(which)
|
||||||
|
|
||||||
|
@ -217,7 +217,36 @@ extern int rvnumbers[4][MAXREGVARS]; /* The register numbers */
|
||||||
#define MUST1BEBOOL(e) int exp1=e.expr_index;tstbool(e)
|
#define MUST1BEBOOL(e) int exp1=e.expr_index;tstbool(e)
|
||||||
#define MUST2BEBOOL(e1,e2) int exp1=e1.expr_index,exp2=e2.expr_index;tstbool(e1);tstbool(e2)
|
#define MUST2BEBOOL(e1,e2) int exp1=e1.expr_index,exp2=e2.expr_index;tstbool(e1);tstbool(e2)
|
||||||
|
|
||||||
extern ident_p ilookup();
|
ident_p ilookup(string name, int enterf);
|
||||||
extern list2 lookstruct();
|
unsigned hash(register string name);
|
||||||
extern string scopy();
|
int lookup(int comm, int operator, int lnode, int rnode);
|
||||||
extern unsigned hash();
|
list2 lookstruct(list2 ll);
|
||||||
|
string scopy(string s);
|
||||||
|
void tabovf(string tablename);
|
||||||
|
int strlookup(string s);
|
||||||
|
int structsize(register list2 s);
|
||||||
|
void yyerror(string s, ...);
|
||||||
|
int instno(inst_t inst);
|
||||||
|
int yyparse(void);
|
||||||
|
int stringno(register string s);
|
||||||
|
int exprlookup(set_t sett);
|
||||||
|
void tstint(expr_t e);
|
||||||
|
void tstbool(expr_t e);
|
||||||
|
void inbetween(void);
|
||||||
|
int formconversion(register char *p, register token_p tp);
|
||||||
|
void setfields(register token_p tp, string format);
|
||||||
|
void chkregexp(int number);
|
||||||
|
int findstructel(int number, string name, int *t);
|
||||||
|
int argtyp(int mn);
|
||||||
|
int commontype(expr_t e1, expr_t e2);
|
||||||
|
void inithash(void);
|
||||||
|
void enter(char *name, int value);
|
||||||
|
int mlookup(char *name);
|
||||||
|
void hashpatterns(void);
|
||||||
|
int max(int a, int b);
|
||||||
|
void out(int n);
|
||||||
|
void outbyte(int n);
|
||||||
|
void pat(int n);
|
||||||
|
void patshort(int n);
|
||||||
|
void patbyte(int n);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#ifndef NORCSID
|
|
||||||
static char rcsid2[]="$Id$";
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
|
@ -14,11 +11,14 @@ static char rcsid2[]="$Id$";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <em_spec.h>
|
#include <stdarg.h>
|
||||||
#include <em_flag.h>
|
#include "em_spec.h"
|
||||||
#include <em_reg.h>
|
#include "em_flag.h"
|
||||||
|
#include "em_reg.h"
|
||||||
|
|
||||||
|
#define EXTERN extern
|
||||||
#include "booth.h"
|
#include "booth.h"
|
||||||
|
#undef EXTERN
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
int lineno = 1;
|
int lineno = 1;
|
||||||
|
@ -158,10 +158,15 @@ return return(RETURN);
|
||||||
. return(yytext[0]);
|
. return(yytext[0]);
|
||||||
%%
|
%%
|
||||||
|
|
||||||
yyerror(s,a1,a2,a3,a4) string s; {
|
|
||||||
|
void yyerror(string s, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, s);
|
||||||
|
|
||||||
fprintf(stderr,"\"%s\", line %d:",iname ? iname : "",lineno);
|
fprintf(stderr,"\"%s\", line %d:",iname ? iname : "",lineno);
|
||||||
fprintf(stderr,s,a1,a2,a3,a4);
|
vfprintf(stderr,s,ap);
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
nerrors++;
|
nerrors++;
|
||||||
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
531
util/cgg/main.c
531
util/cgg/main.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue