Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/planix-v0/sys/src/cmd/eqn/lookup.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "e.h"
2
#include "y.tab.h"
3
 
4
tbl	*keytbl[TBLSIZE];	/* key words */
5
tbl	*restbl[TBLSIZE];	/* reserved words */
6
tbl	*deftbl[TBLSIZE];	/* user-defined names */
7
 
8
struct keyword {
9
	char	*key;
10
	int	keyval;
11
} keyword[]	={
12
	"sub", 		SUB, 
13
	"sup", 		SUP, 
14
	".EN", 		DOTEN,
15
	".EQ",		DOTEQ, 
16
	"from", 	FROM, 
17
	"to", 		TO, 
18
	"sum", 		SUM, 
19
	"hat", 		HAT, 
20
	"vec", 		VEC, 
21
	"dyad", 	DYAD, 
22
	"dot", 		DOT, 
23
	"dotdot", 	DOTDOT, 
24
	"bar", 		BAR,
25
	"lowbar",	LOWBAR,
26
	"highbar",	HIGHBAR, 
27
	"tilde", 	TILDE, 
28
	"utilde", 	UTILDE, 
29
	"under", 	UNDER, 
30
	"prod", 	PROD, 
31
	"int", 		INT, 
32
	"integral", 	INT, 
33
	"union", 	UNION, 
34
	"inter", 	INTER, 
35
	"matrix", 	MATRIX, 
36
	"col", 		COL, 
37
	"lcol", 	LCOL, 
38
	"ccol", 	CCOL, 
39
	"rcol", 	RCOL, 
40
	"pile", 	COL,	/* synonyms ... */ 
41
	"lpile", 	LCOL, 
42
	"cpile", 	CCOL, 
43
	"rpile", 	RCOL, 
44
	"over", 	OVER, 
45
	"sqrt", 	SQRT, 
46
	"above", 	ABOVE, 
47
	"size", 	SIZE, 
48
	"font", 	FONT, 
49
	"fat", 		FAT, 
50
	"roman", 	ROMAN, 
51
	"italic", 	ITALIC, 
52
	"bold", 	BOLD, 
53
	"left", 	LEFT, 
54
	"right", 	RIGHT, 
55
	"delim", 	DELIM, 
56
	"define", 	DEFINE, 
57
	"tdefine", 	DEFINE, 
58
	"ndefine", 	NDEFINE, 
59
	"ifdef",	IFDEF,
60
	"gsize", 	GSIZE, 
61
	".gsize", 	GSIZE, 
62
	"gfont", 	GFONT, 
63
	"include", 	INCLUDE, 
64
	"copy", 	INCLUDE, 
65
	"space",	SPACE,
66
	"up", 		UP, 
67
	"down", 	DOWN, 
68
	"fwd", 		FWD, 
69
	"back", 	BACK, 
70
	"mark", 	MARK, 
71
	"lineup", 	LINEUP, 
72
	0, 	0
73
};
74
 
75
struct resword {
76
	char	*res;
77
	char	*resval;
78
} resword[]	={
79
	">=",		"\\(>=",
80
	"<=",		"\\(<=",
81
	"==",		"\\(==",
82
	"!=",		"\\(!=",
83
	"+-",		"\\(+-",
84
	"->",		"\\(->",
85
	"<-",		"\\(<-",
86
	"inf",		"\\(if",
87
	"infinity",	"\\(if",
88
	"partial",	"\\(pd",
89
	"half",		"\\f1\\(12\\fP",
90
	"prime",	"\\f1\\v'.5m'\\s+3\\(fm\\s-3\\v'-.5m'\\fP",
91
	"dollar",	"\\f1$\\fP",
92
	"nothing",	"",
93
	"times",	"\\(mu",
94
	"del",		"\\(gr",
95
	"grad",		"\\(gr",
96
	"approx",	"\\v'-.2m'\\z\\(ap\\v'.25m'\\(ap\\v'-.05m'",
97
	"cdot",		"\\v'-.3m'.\\v'.3m'",
98
	"...",		"\\v'-.25m'\\ .\\ .\\ .\\ \\v'.25m'",
99
	",...,",	"\\f1,\\fP\\ .\\ .\\ .\\ \\f1,\\fP\\|",
100
	"alpha",	"α",
101
	"ALPHA",	"Α",
102
	"beta",		"β",
103
	"BETA",		"Β",
104
	"gamma",	"γ",
105
	"GAMMA",	"Γ",
106
	"delta",	"δ",
107
	"DELTA",	"Δ",
108
	"epsilon",	"ε",
109
	"EPSILON",	"Ε",
110
	"omega",	"ω",
111
	"OMEGA",	"Ω",
112
	"lambda",	"λ",
113
	"LAMBDA",	"Λ",
114
	"mu",		"μ",
115
	"MU",		"Μ",
116
	"nu",		"ν",
117
	"NU",		"Ν",
118
	"theta",	"θ",
119
	"THETA",	"Θ",
120
	"phi",		"φ",
121
	"PHI",		"Φ",
122
	"pi",		"π",
123
	"PI",		"Π",
124
	"sigma",	"σ",
125
	"SIGMA",	"Σ",
126
	"xi",		"ξ",
127
	"XI",		"Ξ",
128
	"zeta",		"ζ",
129
	"ZETA",		"Ζ",
130
	"iota",		"ι",
131
	"IOTA",		"Ι",
132
	"eta",		"η",
133
	"ETA",		"Η",
134
	"kappa",	"κ",
135
	"KAPPA",	"Κ",
136
	"rho",		"ρ",
137
	"RHO",		"Ρ",
138
	"tau",		"τ",
139
	"TAU",		"Τ",
140
	"omicron",	"ο",
141
	"OMICRON",	"Ο",
142
	"upsilon",	"υ",
143
	"UPSILON",	"Υ",
144
	"psi",		"ψ",
145
	"PSI",		"Ψ",
146
	"chi",		"χ",
147
	"CHI",		"Χ",
148
	"and",		"\\f1and\\fP",
149
	"for",		"\\f1for\\fP",
150
	"if",		"\\f1if\\fP",
151
	"Re",		"\\f1Re\\fP",
152
	"Im",		"\\f1Im\\fP",
153
	"sin",		"\\f1sin\\fP",
154
	"cos",		"\\f1cos\\fP",
155
	"tan",		"\\f1tan\\fP",
156
	"arc",		"\\f1arc\\fP",
157
	"sinh",		"\\f1sinh\\fP",
158
	"coth",		"\\f1coth\\fP",
159
	"tanh",		"\\f1tanh\\fP",
160
	"cosh",		"\\f1cosh\\fP",
161
	"lim",		"\\f1lim\\fP",
162
	"log",		"\\f1log\\fP",
163
	"ln",		"\\f1ln\\fP",
164
	"max",		"\\f1max\\fP",
165
	"min",		"\\f1min\\fP",
166
	"exp",		"\\f1exp\\fP",
167
	"det",		"\\f1det\\fP",
168
	0,	0
169
};
170
 
171
int hash(char *s)
172
{
173
	register unsigned int h;
174
 
175
	for (h = 0; *s != '\0'; )
176
		h += *s++;
177
	h %= TBLSIZE;
178
	return h;
179
}
180
 
181
tbl *lookup(tbl **tblp, char *name)	/* find name in tbl */
182
{
183
	register tbl *p;
184
 
185
	for (p = tblp[hash(name)]; p != NULL; p = p->next)
186
		if (strcmp(name, p->name) == 0)
187
			return(p);
188
	return(NULL);
189
}
190
 
191
void install(tbl **tblp, char *name, char *cval, int ival)	/* install name, vals in tblp */
192
{
193
	register tbl *p;
194
	int h;
195
 
196
	if ((p = lookup(tblp, name)) == NULL) {
197
		p = (tbl *) malloc(sizeof(tbl));
198
		if (p == NULL)
199
			ERROR "out of space in install" FATAL;
200
		h = hash(name);	/* bad visibility here */
201
		p->name = name;
202
		p->next = tblp[h];
203
		tblp[h] = p;
204
	}
205
	p->cval = cval;
206
	p->ival = ival;
207
}
208
 
209
void init_tbl(void)	/* initialize tables */
210
{
211
	int i;
212
	extern int init_tune(void);
213
 
214
	for (i = 0; keyword[i].key != NULL; i++)
215
		install(keytbl, keyword[i].key, (char *) 0, keyword[i].keyval);
216
	for (i = 0; resword[i].res != NULL; i++)
217
		install(restbl, resword[i].res, resword[i].resval, 0);
218
	init_tune();	/* tuning table done in tuning.c */
219
}