Downgraded to standard C syntax.
This commit is contained in:
parent
f665403e7c
commit
a9b85b3405
|
|
@ -1,3 +1,7 @@
|
||||||
|
2007-12-26 Paolo Nenzi <p.nenzi@ieee.org>
|
||||||
|
* src/frontend/numparam/*: downgraded all files to standard C syntax with
|
||||||
|
the included washprog.c tool.
|
||||||
|
|
||||||
2007-12-14 Dietmar Warning
|
2007-12-14 Dietmar Warning
|
||||||
* configure.in, src/spicelib/devices/dev.c: allow mingw build w/o GUI
|
* configure.in, src/spicelib/devices/dev.c: allow mingw build w/o GUI
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ m Tarray(1,2,3) "typedef 2 1[3];"
|
||||||
m Tarray\2(1,2,3,4) "typedef 2 1[3][4];"
|
m Tarray\2(1,2,3,4) "typedef 2 1[3][4];"
|
||||||
m Darray(1,2,3) "2 1[3];"
|
m Darray(1,2,3) "2 1[3];"
|
||||||
|
|
||||||
!m Cconst(1,2) "typedef enum {1 = 2} _n1;"
|
m Cconst(1,2) "typedef enum {1 = 2} _n1;"
|
||||||
!m Str(1,2) "char 2[1+03]={00,00,(char)1}"
|
!m Str(1,2) "char 2[1+03]={00,00,(char)1}"
|
||||||
!m Strbig(1,2) "char 2[1+04]={00, (char)Hi(1), (char)Lo(1)}"
|
!m Strbig(1,2) "char 2[1+04]={00, (char)Hi(1), (char)Lo(1)}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,124 +1,4 @@
|
||||||
/* general.h */
|
/* general.h */
|
||||||
|
|
||||||
/*** Part 1: the C language redefined for quiche eaters ****
|
|
||||||
*
|
|
||||||
* Real Hackers: undo all these macros with the 'washprog.c' utility !
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Proc ...... Begin .... EndProc */
|
|
||||||
#define Proc void
|
|
||||||
#define Begin {
|
|
||||||
#define EndProc ;}
|
|
||||||
/* Func int ...(...) Begin...EndFunc */
|
|
||||||
#define Func
|
|
||||||
#define EndFunc ;}
|
|
||||||
/* If ... Then...ElsIf..Then...Else...EndIf */
|
|
||||||
#define If if(
|
|
||||||
#define Then ){
|
|
||||||
#define Else ;}else{
|
|
||||||
#define ElsIf ;}else if(
|
|
||||||
#define EndIf ;}
|
|
||||||
/* While...Do...Done */
|
|
||||||
#define While while(
|
|
||||||
#define Do ){
|
|
||||||
#define Done ;}
|
|
||||||
/* Repeat...Until...EndRep */
|
|
||||||
#define Repeat do{
|
|
||||||
#define Until ;}while(!(
|
|
||||||
#define EndRep ));
|
|
||||||
/* For i=1;i<=10; Inc(i) Do...Done */
|
|
||||||
#define For for(
|
|
||||||
/* Switch...CaseOne...Is...Case..Is...Default...EndSw */
|
|
||||||
#define Switch switch(
|
|
||||||
#define CaseOne ){ case
|
|
||||||
#define Case ;break;}case
|
|
||||||
#define AndCase :; case
|
|
||||||
#define Is :{
|
|
||||||
#define Default ;break;}default:{
|
|
||||||
#define EndSw ;break;}}
|
|
||||||
|
|
||||||
#define Record(x) typedef struct _t ## x {
|
|
||||||
#define RecPtr(x) typedef struct _t ## x *
|
|
||||||
#define EndRec(x) } x;
|
|
||||||
#define Addr(x) &x
|
|
||||||
|
|
||||||
#define False 0
|
|
||||||
#define True 1
|
|
||||||
#define Not !
|
|
||||||
#define And &&
|
|
||||||
#define Or ||
|
|
||||||
#define Div /
|
|
||||||
#define Mod %
|
|
||||||
|
|
||||||
#define Shl <<
|
|
||||||
#define Shr >>
|
|
||||||
#define AND &
|
|
||||||
#define OR |
|
|
||||||
#define XOR ^
|
|
||||||
#define NOT ~
|
|
||||||
#define AT *
|
|
||||||
|
|
||||||
#define Inc(p) (p)++
|
|
||||||
#define Dec(p) (p)--
|
|
||||||
|
|
||||||
/* see screened versions below:
|
|
||||||
#define New(t) (t*)malloc(sizeof(t))
|
|
||||||
#define Dispose(p) free((void*)p)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef NULL
|
|
||||||
#define Null NULL
|
|
||||||
#else
|
|
||||||
#define Null (void *)0L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define chr(x) (char)(x)
|
|
||||||
#define Zero(x) (!(x))
|
|
||||||
#define NotZ(x) (x)
|
|
||||||
|
|
||||||
typedef void* Pointer;
|
|
||||||
#define Type(a,b) typedef b a;
|
|
||||||
|
|
||||||
#ifdef _STDIO_H /* somebody pulled stdio */
|
|
||||||
Type(Pfile, FILE AT)
|
|
||||||
#else
|
|
||||||
#ifdef __STDIO_H /* Turbo C */
|
|
||||||
Type(Pfile, FILE AT)
|
|
||||||
#else
|
|
||||||
Type(Pfile, FILE*) /* sjb - was Pointer, now FILE* */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Type(Char, unsigned char)
|
|
||||||
Type(Byte, unsigned char)
|
|
||||||
#ifndef Bool
|
|
||||||
Type(Bool, unsigned char)
|
|
||||||
#endif
|
|
||||||
Type(Word, unsigned int)
|
|
||||||
Type(Pchar, char AT)
|
|
||||||
|
|
||||||
#define Intern static
|
|
||||||
#define Extern extern
|
|
||||||
#define Tarray(a,d,n) typedef d a[n];
|
|
||||||
#define Tarray2(a,d,n,m) typedef d a[n][m];
|
|
||||||
#define Darray(a,d,n) d a[n];
|
|
||||||
|
|
||||||
#define Const(x,y) const int x=y;
|
|
||||||
#define Cconst(x,y) typedef enum {x=y} _n ## x;
|
|
||||||
|
|
||||||
#define Aconst(a,tp,sze) tp a[sze] ={
|
|
||||||
#define EndAco };
|
|
||||||
|
|
||||||
/* the following require the 'mystring' mini-library */
|
|
||||||
|
|
||||||
#define Mcopy(a,b) rawcopy((Pchar)a, (Pchar)b, sizeof(a),sizeof(b))
|
|
||||||
#define Rcopy(a,b) rawcopy((Pchar)(&a), (Pchar)(&b), sizeof(&a),sizeof(&b))
|
|
||||||
#define New(tp) (tp *)new(sizeof(tp))
|
|
||||||
#define Dispose(p) dispose((void *)p)
|
|
||||||
#define NewArr(t,n) (t *)new(sizeof(t)*n)
|
|
||||||
|
|
||||||
|
|
||||||
/*** Part 2: common 'foolproof' string library ******/
|
|
||||||
/*
|
/*
|
||||||
include beforehand the following:
|
include beforehand the following:
|
||||||
#include <stdio.h> // NULL FILE fopen feof fgets fclose fputs fputc gets
|
#include <stdio.h> // NULL FILE fopen feof fgets fclose fputs fputc gets
|
||||||
|
|
@ -129,85 +9,87 @@ Type(Pchar, char AT)
|
||||||
#define Use(x) x=0;x=x
|
#define Use(x) x=0;x=x
|
||||||
#define Uses(s) s=s
|
#define Uses(s) s=s
|
||||||
#define Usep(x) x=x
|
#define Usep(x) x=x
|
||||||
#define Hi(x) (((x) Shr 8) AND 0xff)
|
#define Hi(x) (((x) >> 8) & 0xff)
|
||||||
#define Lo(x) ((x) AND 0xff)
|
#define Lo(x) ((x) & 0xff)
|
||||||
|
|
||||||
#define Strbig(n,a) char a[n+4]={0, (char)Hi(n), (char)Lo(n)}
|
#define Strbig(n,a) char a[n+4]={0, (char)Hi(n), (char)Lo(n)}
|
||||||
#define Str(n,a) char a[n+3]={0,0,(char)n} /* n<255 ! */
|
#define Str(n,a) char a[n+3]={0,0,(char)n} /* n<255 ! */
|
||||||
#define Sini(s) sini(s,sizeof(s)-4)
|
#define Sini(s) sini(s,sizeof(s)-4)
|
||||||
|
|
||||||
Cconst(Maxstr,25004) /* was 255, string maxlen, may be up to 32000 or so */
|
|
||||||
|
typedef enum {Maxstr=25004} _nMaxstr; /* was 255, string maxlen, may be up to 32000 or so */
|
||||||
|
typedef enum {Esc=27} _nEsc;
|
||||||
|
typedef enum {Tab=9} _nTab;
|
||||||
|
typedef enum {Bs=8} _nBs;
|
||||||
|
typedef enum {Lf=10} _nLf;
|
||||||
|
typedef enum {Cr=13} _nCr;
|
||||||
|
|
||||||
typedef char string[258];
|
typedef char string[258];
|
||||||
|
|
||||||
Cconst(Esc, 27)
|
|
||||||
Cconst(Tab, 9)
|
|
||||||
Cconst(Bs, 8)
|
|
||||||
Cconst(Lf, 10)
|
|
||||||
Cconst(Cr, 13)
|
|
||||||
|
|
||||||
Proc sini( Pchar s, int i);
|
void sini( char * s, int i);
|
||||||
Proc sfix(Pchar s, int i, int max);
|
void sfix(char * s, int i, int max);
|
||||||
Func int maxlen(Pchar s);
|
int maxlen(char * s);
|
||||||
Func Pchar pscopy( Pchar s, Pchar a, int i,int j);
|
char * pscopy( char * s, char * a, int i,int j);
|
||||||
Func Pchar pscopy_up( Pchar s, Pchar a, int i,int j);
|
char * pscopy_up( char * s, char * a, int i,int j);
|
||||||
Func Bool scopy( Pchar a, Pchar b);
|
unsigned char scopy( char * a, char * b);
|
||||||
Func Bool scopy_up( Pchar a, Pchar b);
|
unsigned char scopy_up( char * a, char * b);
|
||||||
Func Bool ccopy( Pchar a, char c);
|
unsigned char ccopy( char * a, char c);
|
||||||
Func Bool sadd( Pchar s, Pchar t);
|
unsigned char sadd( char * s, char * t);
|
||||||
Func Bool nadd( Pchar s, long n);
|
unsigned char nadd( char * s, long n);
|
||||||
Func Bool cadd( Pchar s, char c);
|
unsigned char cadd( char * s, char c);
|
||||||
Func Bool sins( Pchar s, Pchar t);
|
unsigned char sins( char * s, char * t);
|
||||||
Func Bool cins( Pchar s, char c);
|
unsigned char cins( char * s, char c);
|
||||||
Func int cpos( char c, Pchar s);
|
int cpos( char c, char * s);
|
||||||
Func int spos( Pchar sub, Pchar s);
|
int spos( char * sub, char * s);
|
||||||
int ci_prefix( register char *p, register char *s );
|
int ci_prefix( register char *p, register char *s );
|
||||||
Func int length(Pchar s);
|
int length(char * s);
|
||||||
Func Bool steq(Pchar s, Pchar t);
|
unsigned char steq(char * s, char * t);
|
||||||
Func Bool stne(Pchar s, Pchar t);
|
unsigned char stne(char * s, char * t);
|
||||||
Func int scompare(Pchar a, Pchar b);
|
int scompare(char * a, char * b);
|
||||||
Func int ord(char c);
|
int ord(char c);
|
||||||
Func int pred(int i);
|
int pred(int i);
|
||||||
Func int succ(int i);
|
int succ(int i);
|
||||||
Proc stri(long n, Pchar s);
|
void stri(long n, char * s);
|
||||||
Proc strif(long n, int f, Pchar s);
|
void strif(long n, int f, char * s);
|
||||||
Proc strf(double x, int a, int b, Pchar s); /* float -> string */
|
void strf(double x, int a, int b, char * s); /* float -> string */
|
||||||
Func long ival(Pchar s, int *err);
|
long ival(char * s, int *err);
|
||||||
Func double rval(Pchar s, int *err);
|
double rval(char * s, int *err);
|
||||||
|
|
||||||
Func char upcase(char c);
|
char upcase(char c);
|
||||||
Func char lowcase(char c);
|
char lowcase(char c);
|
||||||
Func int hi(long w);
|
int hi(long w);
|
||||||
Func int lo(long w);
|
int lo(long w);
|
||||||
Func Bool odd(long x);
|
unsigned char odd(long x);
|
||||||
Func Bool alfa(char c);
|
unsigned char alfa(char c);
|
||||||
Func Bool num(char c);
|
unsigned char num(char c);
|
||||||
Func Bool alfanum(char c);
|
unsigned char alfanum(char c);
|
||||||
Func Pchar stupcase( Pchar s);
|
char * stupcase( char * s);
|
||||||
|
|
||||||
/***** primitive input-output ***/
|
/***** primitive input-output ***/
|
||||||
Proc wc(char c);
|
void wc(char c);
|
||||||
Proc wln(void);
|
void wln(void);
|
||||||
Proc ws( Pchar s);
|
void ws( char * s);
|
||||||
Proc wi(long i);
|
void wi(long i);
|
||||||
Proc rs( Pchar s);
|
void rs( char * s);
|
||||||
Func char rc(void);
|
char rc(void);
|
||||||
|
|
||||||
Func int freadstr(Pfile f, Pchar s, int max);
|
int freadstr(FILE * f, char * s, int max);
|
||||||
Func char freadc(Pfile f);
|
char freadc(FILE * f);
|
||||||
Func long freadi(Pfile f);
|
long freadi(FILE * f);
|
||||||
|
|
||||||
Func long np_round(double d); // sjb to avoid clash with round() in math.h
|
long np_round(double d); // sjb to avoid clash with round() in math.h
|
||||||
Func long np_trunc(double x); // sjb to avoid clash with trunc() in math.h
|
long np_trunc(double x); // sjb to avoid clash with trunc() in math.h
|
||||||
Func double sqr(double x);
|
double sqr(double x);
|
||||||
Func double absf(double x); /* abs */
|
double absf(double x); /* abs */
|
||||||
Func long absi( long i);
|
long absi( long i);
|
||||||
Func double frac(double x);
|
double frac(double x);
|
||||||
|
|
||||||
Func Bool reset(Pfile f);
|
unsigned char reset(FILE * f);
|
||||||
Func Bool rewrite(Pfile f);
|
unsigned char rewrite(FILE * f);
|
||||||
Proc rawcopy(Pointer a, Pointer b, int la, int lb);
|
void rawcopy(void * a, void * b, int la, int lb);
|
||||||
Func Pointer new(long sz);
|
void * new(long sz);
|
||||||
Proc dispose(Pointer p);
|
void dispose(void * p);
|
||||||
Func Pchar newstring(int n);
|
char * newstring(int n);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,42 +12,42 @@
|
||||||
#define ln(x) log(x)
|
#define ln(x) log(x)
|
||||||
#define trunc(x) floor(x)
|
#define trunc(x) floor(x)
|
||||||
|
|
||||||
Cconst(Nul, 0)
|
typedef enum {Nul=0} _nNul;
|
||||||
Cconst(Nodekey,'#') /*introduces node symbol*/
|
typedef enum {Nodekey='#'} _nNodekey; /* Introduces node symbol */
|
||||||
Cconst(Intro ,'&') /*introduces preprocessor tokens*/
|
typedef enum {Intro='&'} _nIntro; /* Introduces preprocessor tokens */
|
||||||
Cconst(Comment,'*') /*Spice Comment lines*/
|
typedef enum {Comment='*'} _nComment; /* Spice Comment lines*/
|
||||||
Cconst(Pspice,'{') /*Pspice expression */
|
typedef enum {Pspice='{'} _nPspice; /* Pspice expression */
|
||||||
Cconst(Maxdico,40000) /*size of symbol table*/
|
typedef enum {Maxdico=40000} _nMaxdico; /* Size of symbol table*/
|
||||||
|
|
||||||
/* Composite line length
|
/* Composite line length
|
||||||
This used to be 250 characters, but this is too easy to exceed with a
|
This used to be 250 characters, but this is too easy to exceed with a
|
||||||
.model line, especially when spread over several continuation
|
.model line, especially when spread over several continuation
|
||||||
lines with much white space. I hope 1000 will be enough. */
|
lines with much white space. I hope 1000 will be enough. */
|
||||||
Cconst(Llen,15000)
|
typedef enum {Llen=15000} _nLlen;
|
||||||
|
|
||||||
typedef char str50 [54];
|
typedef char str50 [54];
|
||||||
typedef char str80 [84];
|
typedef char str80 [84];
|
||||||
|
|
||||||
Cconst(Maxline, 20000) /* size of initial unexpanded circuit code */
|
typedef enum {Maxline=20000} _nMaxline; /* Size of initial unexpanded circuit code */
|
||||||
Cconst(Maxckt, 40000) /* size of expanded circuit code */
|
typedef enum {Maxckt=40000} _nMaxckt; /* Size of expanded circuit code */
|
||||||
|
|
||||||
|
|
||||||
typedef Pchar auxtable; /* dummy */
|
typedef char * auxtable; /* dummy */
|
||||||
|
|
||||||
Record(entry)
|
typedef struct _tentry {
|
||||||
char tp; /* type: I)nt R)eal S)tring F)unction M)acro P)ointer */
|
char tp; /* type: I)nt R)eal S)tring F)unction M)acro P)ointer */
|
||||||
char nom[100];
|
char nom[100];
|
||||||
int level; /* subckt nesting level */
|
int level; /* subckt nesting level */
|
||||||
double vl; /* float value if defined */
|
double vl; /* float value if defined */
|
||||||
Word ivl; /*int value or string buffer index*/
|
unsigned short ivl; /*int value or string buffer index*/
|
||||||
Pchar sbbase; /* string buffer base address if any */
|
char * sbbase; /* string buffer base address if any */
|
||||||
EndRec(entry)
|
} entry;
|
||||||
|
|
||||||
Record(fumas) /*function,macro,string*/
|
typedef struct _tfumas { /*function,macro,string*/
|
||||||
Word start /*,stop*/ ; /*buffer index or location */
|
unsigned short start /*,stop*/ ; /*buffer index or location */
|
||||||
EndRec(fumas)
|
} fumas;
|
||||||
|
|
||||||
Record(tdico)
|
typedef struct _ttdico {
|
||||||
/* the input scanner data structure */
|
/* the input scanner data structure */
|
||||||
str80 srcfile; /* last piece of source file name */
|
str80 srcfile; /* last piece of source file name */
|
||||||
int srcline;
|
int srcline;
|
||||||
|
|
@ -61,21 +61,22 @@ Record(tdico)
|
||||||
int tos; /* top of stack index for symbol mark/release mechanics */
|
int tos; /* top of stack index for symbol mark/release mechanics */
|
||||||
str80 option; /* one-character translator options */
|
str80 option; /* one-character translator options */
|
||||||
auxtable nodetab;
|
auxtable nodetab;
|
||||||
Darray(refptr, Pchar, Maxline) /* pointers to source code lines */
|
char * refptr[Maxline]; /* pointers to source code lines */
|
||||||
Darray(category, char, Maxline) /* category of each line */
|
char category[Maxline]; /* category of each line */
|
||||||
EndRec(tdico)
|
} tdico;
|
||||||
|
|
||||||
Proc initdico(tdico * dico);
|
void initdico(tdico * dico);
|
||||||
Func int donedico(tdico * dico);
|
int donedico(tdico * dico);
|
||||||
Func Bool defsubckt( tdico *dico, Pchar s, Word w, char categ);
|
unsigned char defsubckt( tdico *dico, char * s, unsigned short w, char categ);
|
||||||
Func int findsubckt( tdico *dico, Pchar s, Pchar subname);
|
int findsubckt( tdico *dico, char * s, char * subname);
|
||||||
Func Bool nupa_substitute( tdico *dico, Pchar s, Pchar r, Bool err);
|
unsigned char nupa_substitute( tdico *dico, char * s, char * r, unsigned char err);
|
||||||
Func Bool nupa_assignment( tdico *dico, Pchar s, char mode);
|
unsigned char nupa_assignment( tdico *dico, char * s, char mode);
|
||||||
Func Bool nupa_subcktcall( tdico *dico, Pchar s, Pchar x, Bool err);
|
unsigned char nupa_subcktcall( tdico *dico, char * s, char * x, unsigned char err);
|
||||||
Proc nupa_subcktexit( tdico *dico);
|
void nupa_subcktexit( tdico *dico);
|
||||||
Func tdico * nupa_fetchinstance(void);
|
tdico * nupa_fetchinstance(void);
|
||||||
Func char getidtype( tdico *d, Pchar s);
|
char getidtype( tdico *d, char * s);
|
||||||
Func int attrib( tdico *dico, Pchar t, char op );
|
int attrib( tdico *dico, char * t, char op );
|
||||||
|
|
||||||
char *nupa_inst_name;
|
char *nupa_inst_name;
|
||||||
tdico *inst_dico;
|
tdico *inst_dico;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
Cconst(pfxsep,'_') /* official prefix separator is ':' not '_' ! */
|
Cconst(pfxsep,'_') /* official prefix separator is ':' not '_' ! */
|
||||||
|
|
||||||
Darray(buff, Pchar, Maxline) /* input lines */
|
Darray(buff, char *, Maxline) /* input lines */
|
||||||
Darray(buf2, Pchar, Maxline) /* stripped lines */
|
Darray(buf2, char *, Maxline) /* stripped lines */
|
||||||
Darray(pxbuf, Pchar, Maxline) /* prefix for subnodes */
|
Darray(pxbuf, char *, Maxline) /* prefix for subnodes */
|
||||||
Darray(runbuf, int, Maxckt) /* index list of expanded circuit */
|
Darray(runbuf, int, Maxckt) /* index list of expanded circuit */
|
||||||
Darray(pindex, int, Maxckt) /* prefix index list */
|
Darray(pindex, int, Maxckt) /* prefix index list */
|
||||||
int irunbuf= 0; /* count lines of runbuf */
|
int irunbuf= 0; /* count lines of runbuf */
|
||||||
|
|
@ -49,211 +49,211 @@ and substitute node/device name arguments.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Func int runscript( tdico *dico, Pchar prefix,
|
int runscript( tdico *dico, char * prefix,
|
||||||
int istart, int istop, int maxnest)
|
int istart, int istop, int maxnest)
|
||||||
/* recursive top-down expansion: circuit --> list of line numbers */
|
/* recursive top-down expansion: circuit --> list of line numbers */
|
||||||
/* keep it simple,stupid compared to Spice's code */
|
/* keep it simple,stupid compared to Spice's code */
|
||||||
/* prefix: inherited string for node & device prefixing */
|
/* prefix: inherited string for node & device prefixing */
|
||||||
/* istart, istop: allowed interval in table buf[], buf2[]. */
|
/* istart, istop: allowed interval in table buf[], buf2[]. */
|
||||||
/* return value: number of lines included */
|
/* return value: number of lines included */
|
||||||
Begin
|
{
|
||||||
int i,j, idef, nnest, nline, dn, myipx;
|
int i,j, idef, nnest, nline, dn, myipx;
|
||||||
Strbig(Llen, subpfx); /* subckt prefix */
|
Strbig(Llen, subpfx); /* subckt prefix */
|
||||||
Str(80, subname);
|
Str(80, subname);
|
||||||
char c;
|
char c;
|
||||||
Bool done= False;
|
unsigned char done= 0;
|
||||||
i=istart;
|
i=istart;
|
||||||
nline=0;
|
nline=0;
|
||||||
Inc(ipx); myipx= ipx; /* local copy */
|
Inc(ipx); myipx= ipx; /* local copy */
|
||||||
pxbuf[ipx]= newstring( length(prefix));
|
pxbuf[ipx]= newstring( length(prefix));
|
||||||
scopy( pxbuf[ipx], prefix);
|
scopy( pxbuf[ipx], prefix);
|
||||||
While (maxnest>0) And (i<istop) And (Not done) Do
|
while ( (maxnest>0) && (i<istop) && (! done) ) {
|
||||||
c= dico->category[i];
|
c= dico->category[i];
|
||||||
If c=='U' Then
|
if ( c=='U' ) {
|
||||||
done=True; /* subcircuit end. Keep as a comment? */
|
done=1; /* subcircuit end. Keep as a comment? */
|
||||||
buf2[i][0]='#';
|
buf2[i][0]='#';
|
||||||
EndIf
|
}
|
||||||
If c=='S' Then /* skip nested subcircuits */
|
if ( c=='S' ) { /* skip nested subcircuits */
|
||||||
nnest=1;
|
nnest=1;
|
||||||
Repeat
|
do {
|
||||||
Inc(i); c= dico->category[i];
|
Inc(i); c= dico->category[i];
|
||||||
If c=='S' Then
|
if ( c=='S' ) {
|
||||||
Inc(nnest)
|
Inc(nnest);
|
||||||
ElsIf c=='U' Then
|
} else if ( c=='U' ) {
|
||||||
Dec(nnest)
|
Dec(nnest);
|
||||||
EndIf
|
}
|
||||||
Until (nnest<=0) Or (i>=istop) EndRep
|
} while ( !( (nnest<=0) || (i>=istop) ));
|
||||||
ElsIf c=='X' Then /* recursion here ! */
|
} else if ( c=='X' ) { /* recursion here ! */
|
||||||
runbuf[irunbuf]= i;
|
runbuf[irunbuf]= i;
|
||||||
pindex[irunbuf]= myipx;
|
pindex[irunbuf]= myipx;
|
||||||
Inc(irunbuf); Inc(nline);
|
Inc(irunbuf); Inc(nline);
|
||||||
/* keep out-commented X line for parameter passing */
|
/* keep out-commented X line for parameter passing */
|
||||||
idef = findsubckt( dico, buf2[i], subname);
|
idef = findsubckt( dico, buf2[i], subname);
|
||||||
buf2[i][0]= '*';
|
buf2[i][0]= '*';
|
||||||
If idef>0 Then
|
if ( idef>0 ) {
|
||||||
scopy(subpfx, prefix);
|
scopy(subpfx, prefix);
|
||||||
cadd(subpfx, pfxsep);
|
cadd(subpfx, pfxsep);
|
||||||
j=1; /* add the instance name from buf2[i] */
|
j=1; /* add the instance name from buf2[i] */
|
||||||
While buf2[i][j] > ' ' Do
|
while ( buf2[i][j] > ' ' ) {
|
||||||
cadd( subpfx, buf2[i][j]); Inc(j)
|
cadd( subpfx, buf2[i][j]); Inc(j);
|
||||||
Done
|
}
|
||||||
dn= runscript(dico, subpfx, idef+1, istop, maxnest-1);
|
dn= runscript(dico, subpfx, idef+1, istop, maxnest-1);
|
||||||
nline= nline+dn;
|
nline= nline+dn;
|
||||||
Else /* FIXME: error message here! */
|
} else { /* FIXME: error message here! */
|
||||||
ws("cannot find subckt "); ws(buf2[i]); wln();
|
ws("cannot find subckt "); ws(buf2[i]); wln();
|
||||||
EndIf
|
}
|
||||||
ElsIf (c != '?') And NotZ(buf2[i][0]) Then
|
} else if ( (c != '?') && NotZ(buf2[i][0]) ) {
|
||||||
/* keep any other valid non-empty line, and its prefix pointer */
|
/* keep any other valid non-empty line, and its prefix pointer */
|
||||||
runbuf[irunbuf]= i;
|
runbuf[irunbuf]= i;
|
||||||
pindex[irunbuf]= myipx;
|
pindex[irunbuf]= myipx;
|
||||||
Inc(irunbuf); Inc(nline);
|
Inc(irunbuf); Inc(nline);
|
||||||
EndIf
|
}
|
||||||
Inc(i);
|
Inc(i);
|
||||||
Done
|
}
|
||||||
return nline
|
return nline;
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Proc gluepluslines( int imax)
|
void gluepluslines( int imax)
|
||||||
/* general sweep to eliminate continuation lines */
|
/* general sweep to eliminate continuation lines */
|
||||||
Begin
|
{
|
||||||
int i,j,k, ls, p;
|
int i,j,k, ls, p;
|
||||||
Strbig(Llen,s);
|
Strbig(Llen,s);
|
||||||
i=1;
|
i=1;
|
||||||
While i<= imax Do
|
while ( i<= imax ) {
|
||||||
If (buff[i][0]=='+') And (i>1) Then
|
if ( (buff[i][0]=='+') && (i>1) ) {
|
||||||
j= i-1;
|
j= i-1;
|
||||||
While (i < imax) And (buff[i+1][0]=='+') Do Inc(i) Done
|
while ( (i < imax) && (buff[i+1][0]=='+') ) { Inc(i) ;}
|
||||||
/* the lines j+1 ... i are continuation lines to j */
|
/* the lines j+1 ... i are continuation lines to j */
|
||||||
For k=j; k<=i; Inc(k) Do
|
for ( k=j; k<=i; Inc(k) ) {
|
||||||
ls=length(s);
|
ls=length(s);
|
||||||
sadd(s, buff[k]);
|
sadd(s, buff[k]);
|
||||||
p= spos("//",s);
|
p= spos("//",s);
|
||||||
If p>0 Then pscopy(s,s, 1,p-1) EndIf
|
if ( p>0 ) { pscopy(s,s, 1,p-1) ;}
|
||||||
If ls>0 Then s[ls]=' ' EndIf /* erase the + */
|
if ( ls>0 ) { s[ls]=' ' ;} /* erase the + */;
|
||||||
Done
|
}
|
||||||
ls= length(s);
|
ls= length(s);
|
||||||
If ls> 80 Then
|
if ( ls> 80 ) {
|
||||||
Dispose(buff[j]);
|
Dispose(buff[j]);
|
||||||
buff[j]=newstring(ls)
|
buff[j]=newstring(ls);
|
||||||
EndIf
|
}
|
||||||
scopy(buff[j], s)
|
scopy(buff[j], s);
|
||||||
EndIf
|
}
|
||||||
Inc(i)
|
Inc(i);
|
||||||
Done
|
}
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
#if 0 /* sjb - this is in mystring.c */
|
#if 0 /* sjb - this is in mystring.c */
|
||||||
Proc rs(Pchar s) /* 78 coumn limit */
|
void rs(char * s) /* 78 coumn limit */
|
||||||
Begin
|
{
|
||||||
int i;
|
int i;
|
||||||
Bool done;
|
unsigned char done;
|
||||||
char c;
|
char c;
|
||||||
int max=maxlen(s);
|
int max=maxlen(s);
|
||||||
If max>78 Then max=78 EndIf
|
if ( max>78 ) { max=78 ;}
|
||||||
i=0; done=False;
|
i=0; done=0;
|
||||||
scopy(s,"");
|
scopy(s,"");
|
||||||
While Not done Do
|
while ( ! done ) {
|
||||||
c=fgetc(stdin);
|
c=fgetc(stdin);
|
||||||
If (c>=' ')And(c<='~') And (i<max) Then
|
if ( (c>=' ')&&(c<='~') && (i<max) ) {
|
||||||
cadd(s,c); Inc(i)
|
cadd(s,c); Inc(i);
|
||||||
EndIf
|
}
|
||||||
done= (c==Lf) Or (c==Cr)
|
done= (c==Lf) || (c==Cr);
|
||||||
Done
|
}
|
||||||
EndProc
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Proc fwrites(Pfile f, Pchar s)
|
void fwrites(FILE * f, char * s)
|
||||||
Begin
|
{
|
||||||
fputs(s,f)
|
fputs(s,f);
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Proc fwriteln(Pfile f)
|
void fwriteln(FILE * f)
|
||||||
Begin
|
{
|
||||||
fputc('\n',f)
|
fputc('\n',f);
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Intern
|
static
|
||||||
Proc freadln(Pfile f, Pchar s, int max)
|
void freadln(FILE * f, char * s, int max)
|
||||||
Begin
|
{
|
||||||
int ls;
|
int ls;
|
||||||
freadstr(f,s,max);
|
freadstr(f,s,max);
|
||||||
ls=length(s);
|
ls=length(s);
|
||||||
If feof(f) And (ls>0) Then
|
if ( feof(f) && (ls>0) ) {
|
||||||
pscopy(s,s,1,ls-1)
|
pscopy(s,s,1,ls-1);
|
||||||
EndIf /* kill EOF character */
|
} /* kill EOF character */;
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Proc wordinsert(Pchar s, Pchar w, int i)
|
void wordinsert(char * s, char * w, int i)
|
||||||
/* insert w before s[i] */
|
/* insert w before s[i] */
|
||||||
Begin
|
{
|
||||||
Strbig(Llen,t);
|
Strbig(Llen,t);
|
||||||
int ls=length(s);
|
int ls=length(s);
|
||||||
pscopy(t,s,i+1,ls); pscopy(s,s,1,i);
|
pscopy(t,s,i+1,ls); pscopy(s,s,1,i);
|
||||||
sadd(s,w); sadd(s,t);
|
sadd(s,w); sadd(s,t);
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Func int worddelete(Pchar s, int i)
|
int worddelete(char * s, int i)
|
||||||
/* delete word starting at s[i] */
|
/* delete word starting at s[i] */
|
||||||
Begin
|
{
|
||||||
Strbig(Llen,t);
|
Strbig(Llen,t);
|
||||||
int ls= length(s);
|
int ls= length(s);
|
||||||
int j=i;
|
int j=i;
|
||||||
While (j<ls) And (s[j]>' ') Do Inc(j) Done
|
while ( (j<ls) && (s[j]>' ') ) { Inc(j) ;}
|
||||||
pscopy(t,s,j+1,ls);
|
pscopy(t,s,j+1,ls);
|
||||||
pscopy(s,s,1,i);
|
pscopy(s,s,1,i);
|
||||||
sadd(s,t);
|
sadd(s,t);
|
||||||
return j-i /* nb of chars deleted */
|
return j-i /* nb of chars deleted */;
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Func int getnextword(Pchar s, Pchar u, int j)
|
int getnextword(char * s, char * u, int j)
|
||||||
Begin
|
{
|
||||||
int ls,k;
|
int ls,k;
|
||||||
ls= length(s);
|
ls= length(s);
|
||||||
k=j;
|
k=j;
|
||||||
While (j<ls) And (s[j] > ' ') Do Inc(j) Done /* skip current word */
|
while ( (j<ls) && (s[j] > ' ') ) { Inc(j) ;} /* skip current word */
|
||||||
pscopy(u, s, k+1, j-k);
|
pscopy(u, s, k+1, j-k);
|
||||||
While (j<ls) And (s[j] <= ' ') Do Inc(j) Done
|
while ( (j<ls) && (s[j] <= ' ') ) { Inc(j) ;}
|
||||||
return j
|
return j;
|
||||||
EndFunc
|
}
|
||||||
|
|
||||||
Func int inwordlist(Pchar u, Pchar wl)
|
int inwordlist(char * u, char * wl)
|
||||||
/* suppose wl is single-space separated, plus 1 space at start and end. */
|
/* suppose wl is single-space separated, plus 1 space at start and end. */
|
||||||
Begin
|
{
|
||||||
int n,p,k;
|
int n,p,k;
|
||||||
Str(80,t);
|
Str(80,t);
|
||||||
n=0;
|
n=0;
|
||||||
ccopy(t,' '); sadd(t,u); cadd(t,' ');
|
ccopy(t,' '); sadd(t,u); cadd(t,' ');
|
||||||
p= spos(t,wl);
|
p= spos(t,wl);
|
||||||
If p>0 Then
|
if ( p>0 ) {
|
||||||
For k=0; k<p; Inc(k) Do
|
for ( k=0; k<p; Inc(k) ) {
|
||||||
If wl[k] <= ' ' Then Inc(n) EndIf
|
if ( wl[k] <= ' ' ) { Inc(n) ;}
|
||||||
Done
|
}
|
||||||
EndIf
|
}
|
||||||
return n
|
return n;
|
||||||
EndFunc
|
}
|
||||||
|
|
||||||
Proc takewordlist(Pchar u, int k, Pchar wl)
|
void takewordlist(char * u, int k, char * wl)
|
||||||
Begin
|
{
|
||||||
int i,j,lwl;
|
int i,j,lwl;
|
||||||
lwl= length(wl);
|
lwl= length(wl);
|
||||||
i=0; j=0;
|
i=0; j=0;
|
||||||
scopy(u,"");
|
scopy(u,"");
|
||||||
While (i<lwl) And (j<k ) Do
|
while ( (i<lwl) && (j<k ) ) {
|
||||||
If wl[i] <= ' ' Then Inc(j) EndIf
|
if ( wl[i] <= ' ' ) { Inc(j) ;}
|
||||||
Inc(i)
|
Inc(i);
|
||||||
Done
|
}
|
||||||
If j==k Then /* word has been found and starts at i */
|
if ( j==k ) { /* word has been found and starts at i */
|
||||||
While wl[i]>' ' Do
|
while ( wl[i]>' ' ) {
|
||||||
cadd(u,wl[i]); Inc(i)
|
cadd(u,wl[i]); Inc(i);
|
||||||
Done
|
}
|
||||||
EndIf
|
}
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Pchar deviceletter= "RLCVIBSGETOUWFHDQKJZM";
|
char * deviceletter= "RLCVIBSGETOUWFHDQKJZM";
|
||||||
Pchar nbofnodes = "222222444443222240334";
|
char * nbofnodes = "222222444443222240334";
|
||||||
Pchar nbsubdevice = "000000000000111002000";
|
char * nbsubdevice = "000000000000111002000";
|
||||||
|
|
||||||
Proc prefixing(Pchar s, Pchar p, Pchar formals, Pchar actuals,
|
void prefixing(char * s, char * p, char * formals, char * actuals,
|
||||||
char categ, tdico *dic)
|
char categ, tdico *dic)
|
||||||
/* s is a line in expanded subcircuit.
|
/* s is a line in expanded subcircuit.
|
||||||
p is the prefix to be glued anywhere .
|
p is the prefix to be glued anywhere .
|
||||||
|
|
@ -267,188 +267,189 @@ Reminder on Numparam symbols:
|
||||||
naming convention: subckt,model,numparam and node names must be unique.
|
naming convention: subckt,model,numparam and node names must be unique.
|
||||||
cannot re-use a model name as a param name elsewhere, for example.
|
cannot re-use a model name as a param name elsewhere, for example.
|
||||||
*/
|
*/
|
||||||
Begin
|
{
|
||||||
int i,j,k,ls, jnext, dsize;
|
int i,j,k,ls, jnext, dsize;
|
||||||
int dtype, nodes, subdv;
|
int dtype, nodes, subdv;
|
||||||
Bool done;
|
unsigned char done;
|
||||||
char leadchar;
|
char leadchar;
|
||||||
Str(80,u); Str(80,v); Str(80,pfx);
|
Str(80,u); Str(80,v); Str(80,pfx);
|
||||||
i=0; ls=length(s);
|
i=0; ls=length(s);
|
||||||
While (i<ls) And (s[i]<=' ') Do Inc(i) Done
|
while ( (i<ls) && (s[i]<=' ') ) { Inc(i) ;}
|
||||||
If alfa(s[i]) Or (categ=='X') Then /* splice in the prefix and nodelist */
|
if ( alfa(s[i]) || (categ=='X') ) { /* splice in the prefix and nodelist */
|
||||||
wordinsert(s,p, i+1);
|
wordinsert(s,p, i+1);
|
||||||
j= getnextword(s,u,i);
|
j= getnextword(s,u,i);
|
||||||
done=False;
|
done=0;
|
||||||
If p[0]== pfxsep Then
|
if ( p[0]== pfxsep ) {
|
||||||
pscopy(pfx,p, 2, length(p))
|
pscopy(pfx,p, 2, length(p));
|
||||||
Else
|
} else {
|
||||||
scopy(pfx,p)
|
scopy(pfx,p);
|
||||||
EndIf
|
}
|
||||||
leadchar=upcase(s[i]);
|
leadchar=upcase(s[i]);
|
||||||
dtype= cpos( leadchar, deviceletter) -1 ;
|
dtype= cpos( leadchar, deviceletter) -1 ;
|
||||||
If dtype >= 0 Then
|
if ( dtype >= 0 ) {
|
||||||
nodes= nbofnodes[dtype] - '0';
|
nodes= nbofnodes[dtype] - '0';
|
||||||
subdv= nbsubdevice[dtype] - '0';
|
subdv= nbsubdevice[dtype] - '0';
|
||||||
Else
|
} else {
|
||||||
nodes=999; subdv=0;
|
nodes=999; subdv=0;
|
||||||
EndIf
|
}
|
||||||
While Not done Do
|
while ( ! done ) {
|
||||||
jnext= getnextword(s,u,j);
|
jnext= getnextword(s,u,j);
|
||||||
done=(jnext >= length(s)); /* was the last one, do not transform */
|
done=(jnext >= length(s)); /* was the last one, do not transform */
|
||||||
/* bug: are there semilocal nodes ? in nested subckt declarations ? */
|
/* bug: are there semilocal nodes ? in nested subckt declarations ? */
|
||||||
If (leadchar=='Q') And (Not done) Then /* BJT: watch non-node name */
|
if ( (leadchar=='Q') && (! done) ) { /* BJT: watch non-node name */
|
||||||
scopy(v,u); stupcase(v);
|
scopy(v,u); stupcase(v);
|
||||||
done= getidtype(dic, v) == 'O'; /* a model name stops the node list */
|
done= getidtype(dic, v) == 'O'; /* a model name stops the node list */;
|
||||||
EndIf
|
}
|
||||||
If (Not done) And (nodes>0) Then /* transform a node name */
|
if ( (! done) && (nodes>0) ) { /* transform a node name */
|
||||||
k= inwordlist(u, formals);
|
k= inwordlist(u, formals);
|
||||||
If (k>0) Then /* parameter node */
|
if ( (k>0) ) { /* parameter node */
|
||||||
dsize= - worddelete(s,j);
|
dsize= - worddelete(s,j);
|
||||||
takewordlist(u,k, actuals);
|
takewordlist(u,k, actuals);
|
||||||
wordinsert(s,u,j);
|
wordinsert(s,u,j);
|
||||||
dsize= dsize + length(u);
|
dsize= dsize + length(u);
|
||||||
ElsIf stne(u,"0") Then /* local node */
|
} else if ( stne(u,"0") ) { /* local node */
|
||||||
wordinsert(s,pfx,j);
|
wordinsert(s,pfx,j);
|
||||||
dsize= length(pfx);
|
dsize= length(pfx);
|
||||||
Else dsize=0 EndIf
|
} else { dsize=0 ;}
|
||||||
ElsIf (Not done) And (subdv >0) Then /* splice a subdevice name */
|
} else if ( (! done) && (subdv >0) ) { /* splice a subdevice name */
|
||||||
wordinsert(s,p,j+1);
|
wordinsert(s,p,j+1);
|
||||||
dsize= length(p);
|
dsize= length(p);
|
||||||
EndIf
|
}
|
||||||
j= jnext + dsize; /* jnext did shift ...*/
|
j= jnext + dsize; /* jnext did shift ...*/
|
||||||
If nodes >0 Then Dec(nodes)
|
if ( nodes >0 ) { Dec(nodes);
|
||||||
ElsIf subdv >0 Then Dec(subdv)
|
} else if ( subdv >0 ) { Dec(subdv);
|
||||||
EndIf
|
}
|
||||||
done= done Or (Zero(nodes) And Zero(subdv));
|
done= done || (Zero(nodes) && Zero(subdv));
|
||||||
Done
|
}
|
||||||
EndIf
|
}
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Proc getnodelist(Pchar form, Pchar act, Pchar s, tdico *dic, int k)
|
void getnodelist(char * form, char * act, char * s, tdico *dic, int k)
|
||||||
/* the line s contains the actual node parameters, between 1st & last word */
|
/* the line s contains the actual node parameters, between 1st & last word */
|
||||||
Begin
|
{
|
||||||
int j,ls, idef;
|
int j,ls, idef;
|
||||||
Str(80,u); Strbig(Llen,t);
|
Str(80,u); Strbig(Llen,t);
|
||||||
ccopy(act,' '); ccopy(form,' ');
|
ccopy(act,' '); ccopy(form,' ');
|
||||||
j=0; ls= length(s);
|
j=0; ls= length(s);
|
||||||
j= getnextword(s,u,j);
|
j= getnextword(s,u,j);
|
||||||
While j<ls Do
|
while ( j<ls ) {
|
||||||
j= getnextword(s,u,j);
|
j= getnextword(s,u,j);
|
||||||
If j<ls Then sadd(act,u); cadd(act,' ') EndIf
|
if ( j<ls ) { sadd(act,u); cadd(act,' ') ;}
|
||||||
Done
|
}
|
||||||
/* now u already holds the subckt name if all is ok ? */
|
/* now u already holds the subckt name if all is ok ? */
|
||||||
idef = findsubckt( dic, buf2[k], u);
|
idef = findsubckt( dic, buf2[k], u);
|
||||||
/* line buf2[idef] contains: .subckt name < formal list > */
|
/* line buf2[idef] contains: .subckt name < formal list > */
|
||||||
If idef>0 Then
|
if ( idef>0 ) {
|
||||||
scopy(t, buf2[idef])
|
scopy(t, buf2[idef]);
|
||||||
Else
|
} else {
|
||||||
ws("Subckt call error: "); ws(s); wln();
|
ws("Subckt call error: "); ws(s); wln();
|
||||||
EndIf
|
}
|
||||||
j=0; ls= length(t);
|
j=0; ls= length(t);
|
||||||
j= getnextword(t,u,j);
|
j= getnextword(t,u,j);
|
||||||
j= getnextword(t,u,j);
|
j= getnextword(t,u,j);
|
||||||
While j<ls Do
|
while ( j<ls ) {
|
||||||
j= getnextword(t,u,j);
|
j= getnextword(t,u,j);
|
||||||
sadd(form,u); cadd(form,' ');
|
sadd(form,u); cadd(form,' ');
|
||||||
Done
|
}
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Proc nupa_test(Pchar fname, char mode)
|
void nupa_test(char * fname, char mode)
|
||||||
/* debugging circuit expansion run. mode='w': write ouput file */
|
/* debugging circuit expansion run. mode='w': write ouput file */
|
||||||
/* bugs in nupa_eval(), and for nested subckt definitions !?! */
|
/* bugs in nupa_eval(), and for nested subckt definitions !?! */
|
||||||
Begin
|
{
|
||||||
Pfile tf, fout;
|
FILE * tf, fout;
|
||||||
tdico * dic; /* dictionary data pointer */
|
tdico * dic; /* dictionary data pointer */
|
||||||
Strbig(Llen,s);
|
Strbig(Llen,s);
|
||||||
Str(80, prefix);
|
Str(80, prefix);
|
||||||
/* Strbig(Llen, formals); Strbig(Llen,actuals); */
|
/* Strbig(Llen, formals); Strbig(Llen,actuals); */
|
||||||
Darray(formals, Pchar, 10)
|
Darray(formals, char *, 10)
|
||||||
Darray(actuals, Pchar, 10)
|
Darray(actuals, char *, 10)
|
||||||
int i, j, k, nline, parstack;
|
int i, j, k, nline, parstack;
|
||||||
For i=0; i<Maxline; Inc(i) Do /* allocate string storage */
|
for ( i=0; i<Maxline; Inc(i) ) { /* allocate string storage */
|
||||||
buff[i]= newstring(80);
|
buff[i]= newstring(80);
|
||||||
buf2[i]= Null;
|
buf2[i]= NULL;
|
||||||
pxbuf[i]= Null
|
pxbuf[i]= NULL;
|
||||||
Done
|
}
|
||||||
For i=0; i<10; Inc(i) Do
|
for ( i=0; i<10; Inc(i) ) {
|
||||||
formals[i]= newstring(250);
|
formals[i]= newstring(250);
|
||||||
actuals[i]= newstring(250);
|
actuals[i]= newstring(250);
|
||||||
Done
|
}
|
||||||
i=0; parstack=0;
|
i=0; parstack=0;
|
||||||
tf=fopen( fname, "r");
|
tf=fopen( fname, "r");
|
||||||
If tf != Null Then
|
if ( tf != NULL ) {
|
||||||
While (Not feof(tf)) And ((i+1) < Maxline) Do
|
while ( (! feof(tf)) && ((i+1) < Maxline) ) {
|
||||||
Inc(i);
|
Inc(i);
|
||||||
freadln(tf, buff[i], 80); /* original data */
|
freadln(tf, buff[i], 80); /* original data */;
|
||||||
Done
|
}
|
||||||
fclose(tf);
|
fclose(tf);
|
||||||
Else
|
} else {
|
||||||
ws("Cannot find "); ws(fname); wln();
|
ws("Cannot find "); ws(fname); wln();
|
||||||
EndIf
|
}
|
||||||
/* continuation lines are glued at this stage, so they can be ignored
|
/* continuation lines are glued at this stage, so they can be ignored
|
||||||
in all the subsequent manipulations.
|
in all the subsequent manipulations.
|
||||||
*/
|
*/
|
||||||
gluepluslines(i); /* must re-allocate certain buff[i] */
|
gluepluslines(i); /* must re-allocate certain buff[i] */
|
||||||
nupa_signal(NUPADECKCOPY, fname);
|
nupa_signal(NUPADECKCOPY, fname);
|
||||||
dic= nupa_fetchinstance(); /* bug: should have a task handle as arg */
|
dic= nupa_fetchinstance(); /* bug: should have a task handle as arg */
|
||||||
For j=1; j<=i; Inc(j) Do
|
for ( j=1; j<=i; Inc(j) ) {
|
||||||
buf2[j]= nupa_copy(buff[j], j); /* transformed data */
|
buf2[j]= nupa_copy(buff[j], j); /* transformed data */;
|
||||||
Done
|
}
|
||||||
nupa_signal(NUPASUBDONE, Null);
|
nupa_signal(NUPASUBDONE, NULL);
|
||||||
nline= runscript(dic, "", 1,i, 20); /* our own subckt expansion */
|
nline= runscript(dic, "", 1,i, 20); /* our own subckt expansion */
|
||||||
/* putlogfile(' ',nline," expanded lines"); */
|
/* putlogfile(' ',nline," expanded lines"); */
|
||||||
If mode=='w' Then
|
if ( mode=='w' ) {
|
||||||
i= cpos('.', fname);
|
i= cpos('.', fname);
|
||||||
pscopy(s, fname, 1, i);
|
pscopy(s, fname, 1, i);
|
||||||
sadd(s,"out");
|
sadd(s,"out");
|
||||||
fout= fopen(s, "w");
|
fout= fopen(s, "w");
|
||||||
Else
|
} else {
|
||||||
fout= Null
|
fout= NULL;
|
||||||
EndIf
|
}
|
||||||
For j=0; j<irunbuf; Inc(j) Do
|
for ( j=0; j<irunbuf; Inc(j) ) {
|
||||||
k= runbuf[j];
|
k= runbuf[j];
|
||||||
If buf2[k] != Null Then
|
if ( buf2[k] != NULL ) {
|
||||||
scopy(s, buf2[k]);
|
scopy(s, buf2[k]);
|
||||||
nupa_eval(s, k);
|
nupa_eval(s, k);
|
||||||
scopy(prefix,pxbuf[pindex[j]]);
|
scopy(prefix,pxbuf[pindex[j]]);
|
||||||
If NotZ(prefix[0]) Then cadd(prefix, pfxsep) EndIf
|
if ( NotZ(prefix[0]) ) { cadd(prefix, pfxsep) ;}
|
||||||
prefixing(s, prefix, formals[parstack], actuals[parstack],
|
prefixing(s, prefix, formals[parstack], actuals[parstack],
|
||||||
dic->category[k], dic);
|
dic->category[k], dic);
|
||||||
If dic->category[k] == 'X' Then
|
if ( dic->category[k] == 'X' ) {
|
||||||
If parstack< (10-1) Then Inc(parstack) EndIf
|
if ( parstack< (10-1) ) { Inc(parstack) ;}
|
||||||
getnodelist(formals[parstack], actuals[parstack], s, dic,k);
|
getnodelist(formals[parstack], actuals[parstack], s, dic,k);
|
||||||
/*dbg: ws("Form: "); ws(formals[parstack] ); wln(); */
|
/*dbg: ws("Form: "); ws(formals[parstack] ); wln(); */
|
||||||
/*dbg: ws("Actu: "); ws(actuals[parstack]); wln(); */
|
/*dbg: ws("Actu: "); ws(actuals[parstack]); wln(); */;
|
||||||
ElsIf dic->category[k]=='U' Then /* return from subckt */
|
} else if ( dic->category[k]=='U' ) { /* return from subckt */
|
||||||
If parstack>0 Then Dec(parstack) EndIf
|
if ( parstack>0 ) { Dec(parstack) ;}
|
||||||
EndIf
|
}
|
||||||
If fout != Null Then
|
if ( fout != NULL ) {
|
||||||
fwrites(fout, s); fwriteln(fout)
|
fwrites(fout, s); fwriteln(fout);
|
||||||
EndIf
|
}
|
||||||
EndIf
|
}
|
||||||
Done
|
}
|
||||||
If fout != Null Then fclose(fout) EndIf
|
if ( fout != NULL ) { fclose(fout) ;}
|
||||||
nupa_signal(NUPAEVALDONE, Null); /* frees the buff[i] */
|
nupa_signal(NUPAEVALDONE, NULL); /* frees the buff[i] */
|
||||||
For i= 10-1; i>=0; Dec(i) Do
|
for ( i= 10-1; i>=0; Dec(i) ) {
|
||||||
Dispose(actuals[i]);
|
Dispose(actuals[i]);
|
||||||
Dispose(formals[i]);
|
Dispose(formals[i]);
|
||||||
Done
|
}
|
||||||
For i= Maxline -1; i>=0; Dec(i) Do
|
for ( i= Maxline -1; i>=0; Dec(i) ) {
|
||||||
Dispose(pxbuf[i]);
|
Dispose(pxbuf[i]);
|
||||||
Dispose(buf2[i]);
|
Dispose(buf2[i]);
|
||||||
/* Dispose(buff[i]) done elsewhere */
|
/* Dispose(buff[i]) done elsewhere */;
|
||||||
Done
|
}
|
||||||
EndProc
|
}
|
||||||
|
|
||||||
Func int main(int argc, Pchar argv[])
|
int main(int argc, char * argv[])
|
||||||
Begin
|
{
|
||||||
Str(80,fname);
|
Str(80,fname);
|
||||||
If argc>1 Then
|
if ( argc>1 ) {
|
||||||
scopy(fname, argv[1])
|
scopy(fname, argv[1]);
|
||||||
Else
|
} else {
|
||||||
scopy(fname,"testfile.nup")
|
scopy(fname,"testfile.nup");
|
||||||
EndIf
|
}
|
||||||
nupa_test(fname, 'w');
|
nupa_test(fname, 'w');
|
||||||
return 0
|
return 0;
|
||||||
EndFunc
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -49,7 +49,7 @@ Format of substitution rules:
|
||||||
|
|
||||||
#include <stdio.h> /* NULL FILE fopen feof fgets fclose fputs fputc gets */
|
#include <stdio.h> /* NULL FILE fopen feof fgets fclose fputs fputc gets */
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
Cconst(Llen, 15000)
|
||||||
Cconst(nsub, 100+1) /*max nbr of substitution rules */
|
Cconst(nsub, 100+1) /*max nbr of substitution rules */
|
||||||
Cconst(nargs, 11) /*max number of macro args + 1*/
|
Cconst(nargs, 11) /*max number of macro args + 1*/
|
||||||
Cconst(wild,'æ') /* wildcard character in patterns */
|
Cconst(wild,'æ') /* wildcard character in patterns */
|
||||||
|
|
@ -254,18 +254,18 @@ Begin
|
||||||
return ok
|
return ok
|
||||||
EndFunc
|
EndFunc
|
||||||
|
|
||||||
Func int posi(Pchar sub, Pchar s)
|
/* Func int posi(Pchar sub, Pchar s)
|
||||||
Begin /*re-defines Turbo Pos, result Pascal compatible */
|
Begin re-defines Turbo Pos, result Pascal compatible
|
||||||
int a,b,k;
|
int a,b,k;
|
||||||
Bool ok;
|
Bool ok;
|
||||||
/*-StartProc-*/
|
-StartProc-
|
||||||
ok=False;
|
ok=False;
|
||||||
a=length(sub);
|
a=length(sub);
|
||||||
b=(int)(length(s)-a);
|
b=(int)(length(s)-a);
|
||||||
k=0;
|
k=0;
|
||||||
If a>0 Then /*Else return 0*/
|
If a>0 Then Else return 0
|
||||||
While (k<=b) And (Not ok) Do
|
While (k<=b) And (Not ok) Do
|
||||||
ok=match(sub,s, a,k); /*remark we must start at k=0 ! */
|
ok=match(sub,s, a,k); remark we must start at k=0 !
|
||||||
Inc(k);
|
Inc(k);
|
||||||
Done
|
Done
|
||||||
EndIf
|
EndIf
|
||||||
|
|
@ -274,7 +274,7 @@ Begin /*re-defines Turbo Pos, result Pascal compatible */
|
||||||
Else
|
Else
|
||||||
return 0
|
return 0
|
||||||
EndIf
|
EndIf
|
||||||
EndFunc
|
EndFunc */
|
||||||
|
|
||||||
Func int matchwhite(Pchar s, Pchar t, int n, int tstart)
|
Func int matchwhite(Pchar s, Pchar t, int n, int tstart)
|
||||||
Begin
|
Begin
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue