Jspice3
inppas2.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include "inpdefs.h"
10 #include "iferrmsg.h"
11 #include "inpmacs.h"
12 
13 /* pass 2 - Scan through the lines. ".model" cards have been processed
14  * in pass1 and are ignored here.
15  */
16 
17 void
18 INPpas2(ckt,data,tab,task)
19 
20 GENERIC *ckt;
21 card *data;
22 INPtables *tab;
23 GENERIC *task;
24 {
25  card *current;
26  char c;
27  char *groundname = "0";
28  char *gname;
29  char *thisline;
30  GENERIC *gnode;
31  IFdevice *dev;
32  int i, j, error; /* used by the macros defined above */
33 
34  error = INPgetTok(&groundname,&gname,1);
35  if (error) data->error = INPerrCat(data->error,copy(
36  "can't read internal ground node name!\n"));
37 
38  error = INPgndInsert(ckt,&gname,tab,&gnode);
39  if (error && error != E_EXISTS)
40  data->error = INPerrCat(data->error,copy(
41  "can't insert internal ground node in symbol table!\n"));
42 
43  for (current = data; current != NULL; current = current->nextcard) {
44 
45  thisline = current->line;
46  while (*thisline && ((*thisline == ' ') || (*thisline == '\t')))
47  thisline++;
48  c = *thisline;
49 
50  if (isalpha(c)) {
51  if (isupper(c)) c = tolower(c);
52 
53  for (i = 0; i < ft_sim->numDevices; i++) {
54  dev = ft_sim->devices[i];
55  for (j = 0; j < *dev->numKeys; j++) {
56  if (dev->keys[j].key == c)
57  break;
58  }
59  if (j < *dev->numKeys) {
60  (*dev->parse)(i,ckt,tab,current);
61  break;
62  }
63  }
64  if (i == ft_sim->numDevices) {
65  LITERR("Unknown device type.")
66  }
67  continue;
68  }
69 
70  switch (c) {
71 
72  case '*': /* *<anything> - a comment - ignore */
73  case 0:
74  break;
75 
76  case '.': /* .<something> Many possibilities */
77  if (INP2dot(ckt,tab,current,task,gnode)) goto end;
78  break;
79 
80  default:
81  LITERR("Syntax error.")
82  break;
83  }
84  }
85 end:
86  INPtablFix(ckt);
87  return;
88 }
89 
IFkeys * keys
Definition: ifsim.h:297
IFsimulator * ft_sim
Definition: main.c:111
char * line
Definition: inpdefs.h:64
int INPgndInsert()
Definition: inpdefs.h:62
Definition: subckt.c:51
void INPtablFix()
#define E_EXISTS
Definition: iferrmsg.h:20
#define LITERR(text)
Definition: inpmacs.h:35
char * copy()
IFdevice ** devices
Definition: ifsim.h:461
struct card * nextcard
Definition: inpdefs.h:66
#define NULL
Definition: spdefs.h:121
char key
Definition: ifsim.h:268
int INP2dot()
static double c
Definition: vectors.c:16
char * error
Definition: inpdefs.h:65
int * numKeys
Definition: ifsim.h:296
int numDevices
Definition: ifsim.h:460
void(* parse)()
Definition: ifsim.h:309
void INPpas2(GENERIC *ckt, card *data, INPtables *tab, GENERIC *task)
Definition: inppas2.c:18
char GENERIC
Definition: ifsim.h:27
char * INPerrCat()
int INPgetTok()