Jspice3
fteparse.h
Go to the documentation of this file.
1 /**********
2 Copyright 1990 Regents of the University of California. All rights reserved.
3 Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
4 **********/
5 
6 /*
7  * Stuff for parsing -- used by the parser and in ft_evaluate().
8  */
9 
10 #ifndef FTEPARSE
11 #define FTEPARSE
12 
13 
14 #include "ftedata.h"
15 
16 struct pnode {
17  char *pn_name; /* If non-NULL, the name. */
18  struct dvec *pn_value; /* Non-NULL in a terminal node. */
19  struct func *pn_func; /* Non-NULL is a function. */
20  struct op *pn_op; /* Operation if the above two NULL. */
21  struct pnode *pn_left; /* Left branch or function argument. */
22  struct pnode *pn_right; /* Right branch. */
23  struct pnode *pn_next; /* For expression lists. */
24 } ;
25 
26 /* Operations. These should really be considered functions. */
27 
28 struct op {
29  int op_num; /* From parser #defines. */
30  char *op_name; /* Printing name. */
31  char op_arity; /* One or two. */
32  struct dvec *(*op_func)(); /* The function to do the work. */
33 } ;
34 
35 /* The functions that are available. */
36 
37 struct func {
38  char *fu_name; /* The print name of the function. */
39  char *(*fu_func)(); /* The function. */
40 } ;
41 
42 /* User-definable functions. The idea of ud_name is that the args are
43  * kept in strings after the name, all seperated by '\0's. There
44  * will be ud_arity of them.
45  */
46 
47 struct udfunc {
48  char *ud_name; /* The name. */
49  int ud_arity; /* The arity of the function. */
50  struct pnode *ud_text; /* The definition. */
51  struct udfunc *ud_next; /* Link pointer. */
52 } ;
53 
54 #define MAXARITY 32
55 
56 /* Parser elements. */
57 
58 struct element {
59  int e_token; /* One of the below. */
60  int e_type; /* If the token is VALUE. */
61  union {
62  char *un_string;
63  double un_double;
64  struct pnode *un_pnode;
65  } e_un;
66 #define e_string e_un.un_string
67 #define e_double e_un.un_double
68 #define e_indices e_un.un_indices
69 #define e_pnode e_un.un_pnode
70 };
71 
72 /* See the table in parse.c */
73 
74 #define END 0
75 #define PLUS 1
76 #define MINUS 2
77 #define TIMES 3
78 #define MOD 4
79 #define DIVIDE 5
80 #define POWER 6
81 #define UMINUS 7
82 #define LPAREN 8
83 #define RPAREN 9
84 #define COMMA 10
85 #define VALUE 11
86 #define EQ 12
87 #define GT 13
88 #define LT 14
89 #define GE 15
90 #define LE 16
91 #define NE 17
92 #define AND 18
93 #define OR 19
94 #define NOT 20
95 #define INDX 21
96 #define RANGE 22
97 
98 #define NUM 1
99 #define STRING 2
100 #define PNODE 3
101 
102 #endif /* FTEPARSE */
int e_token
Definition: fteparse.h:59
struct func * pn_func
Definition: fteparse.h:19
char * un_string
Definition: fteparse.h:62
char * fu_name
Definition: fteparse.h:38
double un_double
Definition: fteparse.h:63
char * pn_name
Definition: fteparse.h:17
struct pnode * ud_text
Definition: fteparse.h:50
int op_num
Definition: fteparse.h:29
struct pnode * pn_next
Definition: fteparse.h:23
struct op * pn_op
Definition: fteparse.h:20
Definition: ftedata.h:24
Definition: fteparse.h:28
Definition: fteparse.h:37
struct dvec * pn_value
Definition: fteparse.h:18
char * op_name
Definition: fteparse.h:30
struct udfunc * ud_next
Definition: fteparse.h:51
struct pnode * un_pnode
Definition: fteparse.h:64
char * ud_name
Definition: fteparse.h:48
char op_arity
Definition: fteparse.h:31
int ud_arity
Definition: fteparse.h:49
struct pnode * pn_right
Definition: fteparse.h:22
struct pnode * pn_left
Definition: fteparse.h:21
int e_type
Definition: fteparse.h:60
Definition: fteparse.h:16