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  *
8  * Stuff for parsing -- used by the parser and in ft_evaluate().
9  */
10 
11 #ifndef ngspice_FTEPARSE_H
12 #define ngspice_FTEPARSE_H
13 
14 
15 #include "ngspice/cpstd.h"
16 #include "ngspice/dvec.h"
17 #include "ngspice/plot.h"
18 
19 /* FIXME: Split this file and adjust all callers. */
20 #if 0
21 #warning "Please use a more specific header than fteparse.h"
22 #endif
23 #include "ngspice/pnode.h"
24 
25 /* Operations. These should really be considered functions. */
26 
27 struct op {
28     int op_num;			/* From parser #defines. */
29     char *op_name;		/* Printing name. */
30     char op_arity;		/* One or two. */
31     union {
32         void (*anonymous)(void);
33         struct dvec *(*unary)(struct pnode *);
34         struct dvec *(*binary)(struct pnode *, struct pnode *);
35     } op_func;  /* The function to do the work. */
36 } ;
37 
38 /* The functions that are available. */
39 
40 struct func {
41     /* The print name of the function. */
42     char *fu_name;
43 
44     /* The function. */
45     void *(*fu_func)(void *data, short int type, int length,
46 		     int *newlength, short int *newtype);
47 } ;
48 
49 /* User-definable functions. The idea of ud_name is that the args are
50  * kept in strings after the name, all seperated by '\0's. There
51  * will be ud_arity of them.
52  */
53 
54 struct udfunc {
55     char *ud_name;		/* The name. */
56     int ud_arity;		/* The arity of the function. */
57     struct pnode *ud_text;	/* The definition. */
58     struct udfunc *ud_next;	/* Link pointer. */
59 } ;
60 
61 
62 /* Parser elements. */
63 
64 struct element {
65     int e_token;		/* One of the below. */
66     int e_type;			/* If the token is VALUE. */
67     union  {
68         char *un_string;
69         double un_double;
70         struct pnode *un_pnode;
71     } e_un;
72 #define e_string    e_un.un_string
73 #define e_double    e_un.un_double
74 #define e_indices   e_un.un_indices
75 #define e_pnode     e_un.un_pnode
76 };
77 
78 /* See the table in parse.c */
79 
80 #define PT_OP_END      0
81 #define PT_OP_PLUS     1
82 #define PT_OP_MINUS    2
83 #define PT_OP_TIMES    3
84 #define PT_OP_MOD      4
85 #define PT_OP_DIVIDE   5
86 #define PT_OP_POWER    6
87 #define PT_OP_UMINUS   7
88 #define PT_OP_LPAREN   8
89 #define PT_OP_RPAREN   9
90 #define PT_OP_COMMA    10
91 #define PT_OP_VALUE    11
92 #define PT_OP_EQ       12
93 #define PT_OP_GT       13
94 #define PT_OP_LT       14
95 #define PT_OP_GE       15
96 #define PT_OP_LE       16
97 #define PT_OP_NE       17
98 #define PT_OP_AND      18
99 #define PT_OP_OR       19
100 #define PT_OP_NOT      20
101 #define PT_OP_INDX     21
102 #define PT_OP_RANGE    22
103 #define PT_OP_TERNARY  23
104 
105 
106 #endif
107