Jspice3
tfprse.c File Reference
#include "spice.h"
#include "ftedefs.h"
#include "inpdefs.h"
#include "inpmacs.h"
#include "misc.h"
Include dependency graph for tfprse.c:

Go to the source code of this file.

Functions

int TFparse (GENERIC *ckt, INPtables *tab, int which, GENERIC *currentp, char **line, GENERIC *task, GENERIC *gnode)
 

Function Documentation

int TFparse ( GENERIC ckt,
INPtables tab,
int  which,
GENERIC currentp,
char **  line,
GENERIC task,
GENERIC gnode 
)

Definition at line 17 of file tfprse.c.

31 {
32  char *token; /* a token from the line */
33  char *nname1; /* the first node's name */
34  char *nname2; /* the second node's name */
35  GENERIC *node; /* node pointer */
36  GENERIC *foo; /* pointer to analysis */
37  IFvalue ptemp; /* a value structure to package stuff into */
38  IFvalue *parm; /* a pointer to a value struct for function returns */
39  int error; /* error code temporary */
40  card *current = (card *)currentp;
41 
42  IFC(newAnalysis,(ckt,which,"Transfer Function",&foo,task))
43 
44  INPgetTok(line,&token,0);
45  /* token is now either V or I or a serious error */
46  if (*token == 'v' && strlen(token) == 1) {
47  txfree(token);
48  if (**line != '(' /* match) */ ) {
49  LITERR("Syntax error: '(' expected after 'v'");
50  return (0);
51  }
52  INPgetTok(line,&nname1,0);
53  INPtermInsert(ckt,&nname1,tab,&node);
54  ptemp.nValue = node;
55  GCA(INPapName,(ckt,which,foo,"outpos",&ptemp))
56 
57  if (**line != ')') {
58  INPgetTok(line,&nname2,1);
59  INPtermInsert(ckt,&nname2,tab,&node);
60  ptemp.nValue = node;
61  GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
62 
63  ptemp.sValue = (char *)
64  tmalloc(sizeof(char)*(5+strlen(nname1)+strlen(nname2)));
65  (void)sprintf(ptemp.sValue,"v(%s,%s)",nname1,nname2);
66  GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
67  }
68  else {
69  ptemp.nValue = gnode;
70  GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
71 
72  ptemp.sValue = (char *)tmalloc(sizeof(char)*(4+strlen(nname1)));
73  (void)sprintf(ptemp.sValue,"v(%s)",nname1);
74  GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
75  }
76  }
77  else {
78  INPgetTok(line,&token,1);
79  strtolower(token);
80  INPinsert(&token,tab);
81  ptemp.uValue = token;
82  GCA(INPapName,(ckt,which,foo,"outsrc",&ptemp))
83  }
84  INPgetTok(line,&token,1);
85  strtolower(token);
86  INPinsert(&token,tab);
87  ptemp.uValue = token;
88  GCA(INPapName,(ckt,which,foo,"insrc",&ptemp))
89  if (**line) {
90  INPgetTok(line,&token,1);
91  strtolower(token);
92  if (!strcmp(token,"ac")) {
93  GCA(ParseAC,(ckt,line,current,which,foo,tab))
94  }
95  else if (!strcmp(token,"dc")) {
96  GCA(ParseDC,(ckt,line,current,which,foo,tab,1))
97  if (**line) {
98  GCA(ParseDC,(ckt,line,current,which,foo,tab,2))
99  }
100  return (0);
101  }
102  else {
103  LITERR("Syntax error: 'ac' or 'dc' expected.")
104  }
105  txfree(token);
106  }
107  if (**line) {
108  INPgetTok(line,&token,1);
109  strtolower(token);
110  if (!strcmp(token,"dc")) {
111  GCA(ParseDC,(ckt,line,current,which,foo,tab,1))
112  if (**line) {
113  GCA(ParseDC,(ckt,line,current,which,foo,tab,2))
114  }
115  }
116  else {
117  LITERR("Syntax error: 'dc' expected.")
118  }
119  txfree(token);
120  }
121  return (0);
122 }
int INPtermInsert()
Definition: cddefs.h:119
if(TDesc==NULL)
Definition: cd.c:1326
Definition: inpdefs.h:62
#define LITERR(text)
Definition: inpmacs.h:35
int INPinsert()
char * tmalloc()
Definition: fteinp.h:14
void txfree()
void strtolower()
IFnode nValue
Definition: ifsim.h:237
#define GCA(func, args)
Definition: inpmacs.h:27
#define IFC(func, args)
Definition: inpmacs.h:19
int ParseDC()
int INPapName()
int ParseAC()
char GENERIC
Definition: ifsim.h:27
IFuid uValue
Definition: ifsim.h:236
int INPgetTok()