diff options
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | README | 22 | ||||
-rw-r--r-- | array.lua | 15 | ||||
-rw-r--r-- | fixed/iolib.c | 402 | ||||
-rw-r--r-- | fixed/lex_yy.c | 923 | ||||
-rw-r--r-- | fixed/lua.c | 55 | ||||
-rw-r--r-- | floatingpoint.h | 1 | ||||
-rw-r--r-- | globals.lua | 5 | ||||
-rw-r--r-- | save.lua | 47 | ||||
-rw-r--r-- | sort.lua | 56 | ||||
-rw-r--r-- | test.lua | 15 | ||||
-rw-r--r-- | type.lua | 35 |
12 files changed, 1605 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..8ed18bb5 --- /dev/null +++ b/Makefile | |||
@@ -0,0 +1,29 @@ | |||
1 | OBJS= hash.o inout.o lex_yy.o opcode.o table.o y_tab.o lua.o iolib.o mathlib.o strlib.o | ||
2 | |||
3 | CFLAGS= -O2 -I. | ||
4 | |||
5 | T= lua | ||
6 | |||
7 | all: $T | ||
8 | |||
9 | $T: $(OBJS) | ||
10 | $(CC) -o $@ $(OBJS) -lm | ||
11 | |||
12 | A=-------------------------------------------------------------------------- | ||
13 | test: $T | ||
14 | @echo "$A" | ||
15 | ./$T sort.lua main | ||
16 | @echo "$A" | ||
17 | ./$T globals.lua | sort | column | ||
18 | @echo "$A" | ||
19 | ./$T array.lua | ||
20 | @echo "$A" | ||
21 | ./$T save.lua | ||
22 | @echo "$A" | ||
23 | ./$T test.lua retorno_multiplo norma | ||
24 | |||
25 | clean: | ||
26 | rm -f $T $(OBJS) core core.* | ||
27 | |||
28 | diff: | ||
29 | diff . fixed | grep -v ^Only | ||
@@ -0,0 +1,22 @@ | |||
1 | This is Lua 1.0. It was never publicly released. This code is a snapshot of | ||
2 | the status of Lua on 28 Jul 1993. It is distributed for historical curiosity | ||
3 | to celebrate 10 years of Lua and is hereby placed in the public domain. | ||
4 | |||
5 | There is no documentation, except the test programs. The manual for Lua 1.1 | ||
6 | probably works for this version as well. | ||
7 | |||
8 | The source files for the lexer and parser have been lost: all that is left is | ||
9 | the output of lex and yacc. A grammar can be found inside y_tab.c in yyreds. | ||
10 | |||
11 | The code compiles and runs in RedHat 5.2 with gcc 2.7.2.3. It may not run in | ||
12 | newer systems, because it assumes that stdin and stdout are constants, though | ||
13 | ANSI C does not promise they are. If make fails, try using the fixed modules | ||
14 | provided in the "fixed" directory. To see the differences (which are really | ||
15 | quite minor), do "make diff". | ||
16 | |||
17 | To see Lua 1.0 in action, do "make test". (The last test raises an error on | ||
18 | purpose.) | ||
19 | |||
20 | Enjoy! | ||
21 | |||
22 | -- The Lua team, lua@tecgraf.puc-rio.br | ||
diff --git a/array.lua b/array.lua new file mode 100644 index 00000000..349fb818 --- /dev/null +++ b/array.lua | |||
@@ -0,0 +1,15 @@ | |||
1 | $debug | ||
2 | |||
3 | a = @() | ||
4 | |||
5 | i=0 | ||
6 | while i<10 do | ||
7 | a[i] = i*i | ||
8 | i=i+1 | ||
9 | end | ||
10 | |||
11 | r,v = next(a,nil) | ||
12 | while r ~= nil do | ||
13 | print ("array["..r.."] = "..v) | ||
14 | r,v = next(a,r) | ||
15 | end | ||
diff --git a/fixed/iolib.c b/fixed/iolib.c new file mode 100644 index 00000000..dce91f9d --- /dev/null +++ b/fixed/iolib.c | |||
@@ -0,0 +1,402 @@ | |||
1 | /* | ||
2 | ** iolib.c | ||
3 | ** Input/output library to LUA | ||
4 | ** | ||
5 | ** Waldemar Celes Filho | ||
6 | ** TeCGraf - PUC-Rio | ||
7 | ** 19 May 93 | ||
8 | */ | ||
9 | |||
10 | #include <stdlib.h> | ||
11 | #include <string.h> | ||
12 | #include <stdio.h> | ||
13 | #include <ctype.h> | ||
14 | #ifdef __GNUC__ | ||
15 | #include <floatingpoint.h> | ||
16 | #endif | ||
17 | |||
18 | #include "lua.h" | ||
19 | |||
20 | static FILE *in=NULL, *out=NULL; | ||
21 | |||
22 | /* | ||
23 | ** Open a file to read. | ||
24 | ** LUA interface: | ||
25 | ** status = readfrom (filename) | ||
26 | ** where: | ||
27 | ** status = 1 -> success | ||
28 | ** status = 0 -> error | ||
29 | */ | ||
30 | static void io_readfrom (void) | ||
31 | { | ||
32 | lua_Object o = lua_getparam (1); | ||
33 | if (o == NULL) /* restore standart input */ | ||
34 | { | ||
35 | if (in != stdin) | ||
36 | { | ||
37 | fclose (in); | ||
38 | in = stdin; | ||
39 | } | ||
40 | lua_pushnumber (1); | ||
41 | } | ||
42 | else | ||
43 | { | ||
44 | if (!lua_isstring (o)) | ||
45 | { | ||
46 | lua_error ("incorrect argument to function 'readfrom`"); | ||
47 | lua_pushnumber (0); | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | FILE *fp = fopen (lua_getstring(o),"r"); | ||
52 | if (fp == NULL) | ||
53 | { | ||
54 | lua_pushnumber (0); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | if (in != stdin) fclose (in); | ||
59 | in = fp; | ||
60 | lua_pushnumber (1); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | |||
66 | |||
67 | /* | ||
68 | ** Open a file to write. | ||
69 | ** LUA interface: | ||
70 | ** status = writeto (filename) | ||
71 | ** where: | ||
72 | ** status = 1 -> success | ||
73 | ** status = 0 -> error | ||
74 | */ | ||
75 | static void io_writeto (void) | ||
76 | { | ||
77 | lua_Object o = lua_getparam (1); | ||
78 | if (o == NULL) /* restore standart output */ | ||
79 | { | ||
80 | if (out != stdout) | ||
81 | { | ||
82 | fclose (out); | ||
83 | out = stdout; | ||
84 | } | ||
85 | lua_pushnumber (1); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | if (!lua_isstring (o)) | ||
90 | { | ||
91 | lua_error ("incorrect argument to function 'writeto`"); | ||
92 | lua_pushnumber (0); | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | FILE *fp = fopen (lua_getstring(o),"w"); | ||
97 | if (fp == NULL) | ||
98 | { | ||
99 | lua_pushnumber (0); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | if (out != stdout) fclose (out); | ||
104 | out = fp; | ||
105 | lua_pushnumber (1); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | |||
112 | /* | ||
113 | ** Read a variable. On error put nil on stack. | ||
114 | ** LUA interface: | ||
115 | ** variable = read ([format]) | ||
116 | ** | ||
117 | ** O formato pode ter um dos seguintes especificadores: | ||
118 | ** | ||
119 | ** s ou S -> para string | ||
120 | ** f ou F, g ou G, e ou E -> para reais | ||
121 | ** i ou I -> para inteiros | ||
122 | ** | ||
123 | ** Estes especificadores podem vir seguidos de numero que representa | ||
124 | ** o numero de campos a serem lidos. | ||
125 | */ | ||
126 | static void io_read (void) | ||
127 | { | ||
128 | lua_Object o = lua_getparam (1); | ||
129 | if (o == NULL) /* free format */ | ||
130 | { | ||
131 | int c; | ||
132 | char s[256]; | ||
133 | while (isspace(c=fgetc(in))) | ||
134 | ; | ||
135 | if (c == '\"') | ||
136 | { | ||
137 | if (fscanf (in, "%[^\"]\"", s) != 1) | ||
138 | { | ||
139 | lua_pushnil (); | ||
140 | return; | ||
141 | } | ||
142 | } | ||
143 | else if (c == '\'') | ||
144 | { | ||
145 | if (fscanf (in, "%[^\']\'", s) != 1) | ||
146 | { | ||
147 | lua_pushnil (); | ||
148 | return; | ||
149 | } | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | char *ptr; | ||
154 | double d; | ||
155 | ungetc (c, in); | ||
156 | if (fscanf (in, "%s", s) != 1) | ||
157 | { | ||
158 | lua_pushnil (); | ||
159 | return; | ||
160 | } | ||
161 | d = strtod (s, &ptr); | ||
162 | if (!(*ptr)) | ||
163 | { | ||
164 | lua_pushnumber (d); | ||
165 | return; | ||
166 | } | ||
167 | } | ||
168 | lua_pushstring (s); | ||
169 | return; | ||
170 | } | ||
171 | else /* formatted */ | ||
172 | { | ||
173 | char *e = lua_getstring(o); | ||
174 | char t; | ||
175 | int m=0; | ||
176 | while (isspace(*e)) e++; | ||
177 | t = *e++; | ||
178 | while (isdigit(*e)) | ||
179 | m = m*10 + (*e++ - '0'); | ||
180 | |||
181 | if (m > 0) | ||
182 | { | ||
183 | char f[80]; | ||
184 | char s[256]; | ||
185 | sprintf (f, "%%%ds", m); | ||
186 | fscanf (in, f, s); | ||
187 | switch (tolower(t)) | ||
188 | { | ||
189 | case 'i': | ||
190 | { | ||
191 | long int l; | ||
192 | sscanf (s, "%ld", &l); | ||
193 | lua_pushnumber(l); | ||
194 | } | ||
195 | break; | ||
196 | case 'f': case 'g': case 'e': | ||
197 | { | ||
198 | float f; | ||
199 | sscanf (s, "%f", &f); | ||
200 | lua_pushnumber(f); | ||
201 | } | ||
202 | break; | ||
203 | default: | ||
204 | lua_pushstring(s); | ||
205 | break; | ||
206 | } | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | switch (tolower(t)) | ||
211 | { | ||
212 | case 'i': | ||
213 | { | ||
214 | long int l; | ||
215 | fscanf (in, "%ld", &l); | ||
216 | lua_pushnumber(l); | ||
217 | } | ||
218 | break; | ||
219 | case 'f': case 'g': case 'e': | ||
220 | { | ||
221 | float f; | ||
222 | fscanf (in, "%f", &f); | ||
223 | lua_pushnumber(f); | ||
224 | } | ||
225 | break; | ||
226 | default: | ||
227 | { | ||
228 | char s[256]; | ||
229 | fscanf (in, "%s", s); | ||
230 | lua_pushstring(s); | ||
231 | } | ||
232 | break; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
238 | |||
239 | /* | ||
240 | ** Write a variable. On error put 0 on stack, otherwise put 1. | ||
241 | ** LUA interface: | ||
242 | ** status = write (variable [,format]) | ||
243 | ** | ||
244 | ** O formato pode ter um dos seguintes especificadores: | ||
245 | ** | ||
246 | ** s ou S -> para string | ||
247 | ** f ou F, g ou G, e ou E -> para reais | ||
248 | ** i ou I -> para inteiros | ||
249 | ** | ||
250 | ** Estes especificadores podem vir seguidos de: | ||
251 | ** | ||
252 | ** [?][m][.n] | ||
253 | ** | ||
254 | ** onde: | ||
255 | ** ? -> indica justificacao | ||
256 | ** < = esquerda | ||
257 | ** | = centro | ||
258 | ** > = direita (default) | ||
259 | ** m -> numero maximo de campos (se exceder estoura) | ||
260 | ** n -> indica precisao para | ||
261 | ** reais -> numero de casas decimais | ||
262 | ** inteiros -> numero minimo de digitos | ||
263 | ** string -> nao se aplica | ||
264 | */ | ||
265 | static char *buildformat (char *e, lua_Object o) | ||
266 | { | ||
267 | static char buffer[512]; | ||
268 | static char f[80]; | ||
269 | char *string = &buffer[255]; | ||
270 | char t, j='r'; | ||
271 | int m=0, n=0, l; | ||
272 | while (isspace(*e)) e++; | ||
273 | t = *e++; | ||
274 | if (*e == '<' || *e == '|' || *e == '>') j = *e++; | ||
275 | while (isdigit(*e)) | ||
276 | m = m*10 + (*e++ - '0'); | ||
277 | e++; /* skip point */ | ||
278 | while (isdigit(*e)) | ||
279 | n = n*10 + (*e++ - '0'); | ||
280 | |||
281 | sprintf(f,"%%"); | ||
282 | if (j == '<' || j == '|') sprintf(strchr(f,0),"-"); | ||
283 | if (m != 0) sprintf(strchr(f,0),"%d", m); | ||
284 | if (n != 0) sprintf(strchr(f,0),".%d", n); | ||
285 | sprintf(strchr(f,0), "%c", t); | ||
286 | switch (tolower(t)) | ||
287 | { | ||
288 | case 'i': t = 'i'; | ||
289 | sprintf (string, f, (long int)lua_getnumber(o)); | ||
290 | break; | ||
291 | case 'f': case 'g': case 'e': t = 'f'; | ||
292 | sprintf (string, f, (float)lua_getnumber(o)); | ||
293 | break; | ||
294 | case 's': t = 's'; | ||
295 | sprintf (string, f, lua_getstring(o)); | ||
296 | break; | ||
297 | default: return ""; | ||
298 | } | ||
299 | l = strlen(string); | ||
300 | if (m!=0 && l>m) | ||
301 | { | ||
302 | int i; | ||
303 | for (i=0; i<m; i++) | ||
304 | string[i] = '*'; | ||
305 | string[i] = 0; | ||
306 | } | ||
307 | else if (m!=0 && j=='|') | ||
308 | { | ||
309 | int i=l-1; | ||
310 | while (isspace(string[i])) i--; | ||
311 | string -= (m-i) / 2; | ||
312 | i=0; | ||
313 | while (string[i]==0) string[i++] = ' '; | ||
314 | string[l] = 0; | ||
315 | } | ||
316 | return string; | ||
317 | } | ||
318 | static void io_write (void) | ||
319 | { | ||
320 | lua_Object o1 = lua_getparam (1); | ||
321 | lua_Object o2 = lua_getparam (2); | ||
322 | if (o1 == NULL) /* new line */ | ||
323 | { | ||
324 | fprintf (out, "\n"); | ||
325 | lua_pushnumber(1); | ||
326 | } | ||
327 | else if (o2 == NULL) /* free format */ | ||
328 | { | ||
329 | int status=0; | ||
330 | if (lua_isnumber(o1)) | ||
331 | status = fprintf (out, "%g", lua_getnumber(o1)); | ||
332 | else if (lua_isstring(o1)) | ||
333 | status = fprintf (out, "%s", lua_getstring(o1)); | ||
334 | lua_pushnumber(status); | ||
335 | } | ||
336 | else /* formated */ | ||
337 | { | ||
338 | if (!lua_isstring(o2)) | ||
339 | { | ||
340 | lua_error ("incorrect format to function `write'"); | ||
341 | lua_pushnumber(0); | ||
342 | return; | ||
343 | } | ||
344 | lua_pushnumber(fprintf (out, "%s", buildformat(lua_getstring(o2),o1))); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | /* | ||
349 | ** Execute a executable program using "sustem". | ||
350 | ** On error put 0 on stack, otherwise put 1. | ||
351 | */ | ||
352 | void io_execute (void) | ||
353 | { | ||
354 | lua_Object o = lua_getparam (1); | ||
355 | if (o == NULL || !lua_isstring (o)) | ||
356 | { | ||
357 | lua_error ("incorrect argument to function 'execute`"); | ||
358 | lua_pushnumber (0); | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | system(lua_getstring(o)); | ||
363 | lua_pushnumber (1); | ||
364 | } | ||
365 | return; | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | ** Remove a file. | ||
370 | ** On error put 0 on stack, otherwise put 1. | ||
371 | */ | ||
372 | void io_remove (void) | ||
373 | { | ||
374 | lua_Object o = lua_getparam (1); | ||
375 | if (o == NULL || !lua_isstring (o)) | ||
376 | { | ||
377 | lua_error ("incorrect argument to function 'execute`"); | ||
378 | lua_pushnumber (0); | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | if (remove(lua_getstring(o)) == 0) | ||
383 | lua_pushnumber (1); | ||
384 | else | ||
385 | lua_pushnumber (0); | ||
386 | } | ||
387 | return; | ||
388 | } | ||
389 | |||
390 | /* | ||
391 | ** Open io library | ||
392 | */ | ||
393 | void iolib_open (void) | ||
394 | { | ||
395 | in=stdin; out=stdout; | ||
396 | lua_register ("readfrom", io_readfrom); | ||
397 | lua_register ("writeto", io_writeto); | ||
398 | lua_register ("read", io_read); | ||
399 | lua_register ("write", io_write); | ||
400 | lua_register ("execute", io_execute); | ||
401 | lua_register ("remove", io_remove); | ||
402 | } | ||
diff --git a/fixed/lex_yy.c b/fixed/lex_yy.c new file mode 100644 index 00000000..ab73ea6c --- /dev/null +++ b/fixed/lex_yy.c | |||
@@ -0,0 +1,923 @@ | |||
1 | # include "stdio.h" | ||
2 | # define U(x) x | ||
3 | # define NLSTATE yyprevious=YYNEWLINE | ||
4 | # define BEGIN yybgin = yysvec + 1 + | ||
5 | # define INITIAL 0 | ||
6 | # define YYLERR yysvec | ||
7 | # define YYSTATE (yyestate-yysvec-1) | ||
8 | # define YYOPTIM 1 | ||
9 | # define YYLMAX BUFSIZ | ||
10 | # define output(c) putc(c,yyout) | ||
11 | # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) | ||
12 | # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} | ||
13 | # define yymore() (yymorfg=1) | ||
14 | # define ECHO fprintf(yyout, "%s",yytext) | ||
15 | # define REJECT { nstr = yyreject(); goto yyfussy;} | ||
16 | int yyleng; extern char yytext[]; | ||
17 | int yymorfg; | ||
18 | extern char *yysptr, yysbuf[]; | ||
19 | int yytchar; | ||
20 | FILE *yyin = {NULL}, *yyout = {NULL}; | ||
21 | extern int yylineno; | ||
22 | struct yysvf { | ||
23 | struct yywork *yystoff; | ||
24 | struct yysvf *yyother; | ||
25 | int *yystops;}; | ||
26 | struct yysvf *yyestate; | ||
27 | extern struct yysvf yysvec[], *yybgin; | ||
28 | #include <stdlib.h> | ||
29 | #include <string.h> | ||
30 | |||
31 | #include "opcode.h" | ||
32 | #include "hash.h" | ||
33 | #include "inout.h" | ||
34 | #include "table.h" | ||
35 | #include "y_tab.h" | ||
36 | |||
37 | #undef input | ||
38 | #undef unput | ||
39 | |||
40 | static Input input; | ||
41 | static Unput unput; | ||
42 | |||
43 | void lua_setinput (Input fn) | ||
44 | { | ||
45 | input = fn; | ||
46 | } | ||
47 | |||
48 | void lua_setunput (Unput fn) | ||
49 | { | ||
50 | unput = fn; | ||
51 | } | ||
52 | |||
53 | char *lua_lasttext (void) | ||
54 | { | ||
55 | return yytext; | ||
56 | } | ||
57 | |||
58 | # define YYNEWLINE 10 | ||
59 | yylex(){ | ||
60 | int nstr; extern int yyprevious; | ||
61 | while((nstr = yylook()) >= 0) | ||
62 | yyfussy: switch(nstr){ | ||
63 | case 0: | ||
64 | if(yywrap()) return(0); break; | ||
65 | case 1: | ||
66 | ; | ||
67 | break; | ||
68 | case 2: | ||
69 | {yylval.vInt = 1; return DEBUG;} | ||
70 | break; | ||
71 | case 3: | ||
72 | {yylval.vInt = 0; return DEBUG;} | ||
73 | break; | ||
74 | case 4: | ||
75 | lua_linenumber++; | ||
76 | break; | ||
77 | case 5: | ||
78 | ; | ||
79 | break; | ||
80 | case 6: | ||
81 | return LOCAL; | ||
82 | break; | ||
83 | case 7: | ||
84 | return IF; | ||
85 | break; | ||
86 | case 8: | ||
87 | return THEN; | ||
88 | break; | ||
89 | case 9: | ||
90 | return ELSE; | ||
91 | break; | ||
92 | case 10: | ||
93 | return ELSEIF; | ||
94 | break; | ||
95 | case 11: | ||
96 | return WHILE; | ||
97 | break; | ||
98 | case 12: | ||
99 | return DO; | ||
100 | break; | ||
101 | case 13: | ||
102 | return REPEAT; | ||
103 | break; | ||
104 | case 14: | ||
105 | return UNTIL; | ||
106 | break; | ||
107 | case 15: | ||
108 | { | ||
109 | yylval.vWord = lua_nfile-1; | ||
110 | return FUNCTION; | ||
111 | } | ||
112 | break; | ||
113 | case 16: | ||
114 | return END; | ||
115 | break; | ||
116 | case 17: | ||
117 | return RETURN; | ||
118 | break; | ||
119 | case 18: | ||
120 | return LOCAL; | ||
121 | break; | ||
122 | case 19: | ||
123 | return NIL; | ||
124 | break; | ||
125 | case 20: | ||
126 | return AND; | ||
127 | break; | ||
128 | case 21: | ||
129 | return OR; | ||
130 | break; | ||
131 | case 22: | ||
132 | return NOT; | ||
133 | break; | ||
134 | case 23: | ||
135 | return NE; | ||
136 | break; | ||
137 | case 24: | ||
138 | return LE; | ||
139 | break; | ||
140 | case 25: | ||
141 | return GE; | ||
142 | break; | ||
143 | case 26: | ||
144 | return CONC; | ||
145 | break; | ||
146 | case 27: | ||
147 | case 28: | ||
148 | { | ||
149 | yylval.vWord = lua_findenclosedconstant (yytext); | ||
150 | return STRING; | ||
151 | } | ||
152 | break; | ||
153 | case 29: | ||
154 | case 30: | ||
155 | case 31: | ||
156 | case 32: | ||
157 | { | ||
158 | yylval.vFloat = atof(yytext); | ||
159 | return NUMBER; | ||
160 | } | ||
161 | break; | ||
162 | case 33: | ||
163 | { | ||
164 | yylval.vWord = lua_findsymbol (yytext); | ||
165 | return NAME; | ||
166 | } | ||
167 | break; | ||
168 | case 34: | ||
169 | return *yytext; | ||
170 | break; | ||
171 | case -1: | ||
172 | break; | ||
173 | default: | ||
174 | fprintf(yyout,"bad switch yylook %d",nstr); | ||
175 | } return(0); } | ||
176 | /* end of yylex */ | ||
177 | int yyvstop[] = { | ||
178 | 0, | ||
179 | |||
180 | 1, | ||
181 | 0, | ||
182 | |||
183 | 1, | ||
184 | 0, | ||
185 | |||
186 | 34, | ||
187 | 0, | ||
188 | |||
189 | 1, | ||
190 | 34, | ||
191 | 0, | ||
192 | |||
193 | 4, | ||
194 | 0, | ||
195 | |||
196 | 34, | ||
197 | 0, | ||
198 | |||
199 | 34, | ||
200 | 0, | ||
201 | |||
202 | 34, | ||
203 | 0, | ||
204 | |||
205 | 34, | ||
206 | 0, | ||
207 | |||
208 | 29, | ||
209 | 34, | ||
210 | 0, | ||
211 | |||
212 | 34, | ||
213 | 0, | ||
214 | |||
215 | 34, | ||
216 | 0, | ||
217 | |||
218 | 33, | ||
219 | 34, | ||
220 | 0, | ||
221 | |||
222 | 33, | ||
223 | 34, | ||
224 | 0, | ||
225 | |||
226 | 33, | ||
227 | 34, | ||
228 | 0, | ||
229 | |||
230 | 33, | ||
231 | 34, | ||
232 | 0, | ||
233 | |||
234 | 33, | ||
235 | 34, | ||
236 | 0, | ||
237 | |||
238 | 33, | ||
239 | 34, | ||
240 | 0, | ||
241 | |||
242 | 33, | ||
243 | 34, | ||
244 | 0, | ||
245 | |||
246 | 33, | ||
247 | 34, | ||
248 | 0, | ||
249 | |||
250 | 33, | ||
251 | 34, | ||
252 | 0, | ||
253 | |||
254 | 33, | ||
255 | 34, | ||
256 | 0, | ||
257 | |||
258 | 33, | ||
259 | 34, | ||
260 | 0, | ||
261 | |||
262 | 33, | ||
263 | 34, | ||
264 | 0, | ||
265 | |||
266 | 33, | ||
267 | 34, | ||
268 | 0, | ||
269 | |||
270 | 34, | ||
271 | 0, | ||
272 | |||
273 | 34, | ||
274 | 0, | ||
275 | |||
276 | 1, | ||
277 | 0, | ||
278 | |||
279 | 27, | ||
280 | 0, | ||
281 | |||
282 | 28, | ||
283 | 0, | ||
284 | |||
285 | 5, | ||
286 | 0, | ||
287 | |||
288 | 26, | ||
289 | 0, | ||
290 | |||
291 | 30, | ||
292 | 0, | ||
293 | |||
294 | 29, | ||
295 | 0, | ||
296 | |||
297 | 29, | ||
298 | 0, | ||
299 | |||
300 | 24, | ||
301 | 0, | ||
302 | |||
303 | 25, | ||
304 | 0, | ||
305 | |||
306 | 33, | ||
307 | 0, | ||
308 | |||
309 | 33, | ||
310 | 0, | ||
311 | |||
312 | 12, | ||
313 | 33, | ||
314 | 0, | ||
315 | |||
316 | 33, | ||
317 | 0, | ||
318 | |||
319 | 33, | ||
320 | 0, | ||
321 | |||
322 | 33, | ||
323 | 0, | ||
324 | |||
325 | 7, | ||
326 | 33, | ||
327 | 0, | ||
328 | |||
329 | 33, | ||
330 | 0, | ||
331 | |||
332 | 33, | ||
333 | 0, | ||
334 | |||
335 | 33, | ||
336 | 0, | ||
337 | |||
338 | 21, | ||
339 | 33, | ||
340 | 0, | ||
341 | |||
342 | 33, | ||
343 | 0, | ||
344 | |||
345 | 33, | ||
346 | 0, | ||
347 | |||
348 | 33, | ||
349 | 0, | ||
350 | |||
351 | 33, | ||
352 | 0, | ||
353 | |||
354 | 23, | ||
355 | 0, | ||
356 | |||
357 | 29, | ||
358 | 30, | ||
359 | 0, | ||
360 | |||
361 | 31, | ||
362 | 0, | ||
363 | |||
364 | 20, | ||
365 | 33, | ||
366 | 0, | ||
367 | |||
368 | 33, | ||
369 | 0, | ||
370 | |||
371 | 16, | ||
372 | 33, | ||
373 | 0, | ||
374 | |||
375 | 33, | ||
376 | 0, | ||
377 | |||
378 | 33, | ||
379 | 0, | ||
380 | |||
381 | 19, | ||
382 | 33, | ||
383 | 0, | ||
384 | |||
385 | 22, | ||
386 | 33, | ||
387 | 0, | ||
388 | |||
389 | 33, | ||
390 | 0, | ||
391 | |||
392 | 33, | ||
393 | 0, | ||
394 | |||
395 | 33, | ||
396 | 0, | ||
397 | |||
398 | 33, | ||
399 | 0, | ||
400 | |||
401 | 33, | ||
402 | 0, | ||
403 | |||
404 | 32, | ||
405 | 0, | ||
406 | |||
407 | 9, | ||
408 | 33, | ||
409 | 0, | ||
410 | |||
411 | 33, | ||
412 | 0, | ||
413 | |||
414 | 33, | ||
415 | 0, | ||
416 | |||
417 | 33, | ||
418 | 0, | ||
419 | |||
420 | 33, | ||
421 | 0, | ||
422 | |||
423 | 8, | ||
424 | 33, | ||
425 | 0, | ||
426 | |||
427 | 33, | ||
428 | 0, | ||
429 | |||
430 | 33, | ||
431 | 0, | ||
432 | |||
433 | 31, | ||
434 | 32, | ||
435 | 0, | ||
436 | |||
437 | 33, | ||
438 | 0, | ||
439 | |||
440 | 33, | ||
441 | 0, | ||
442 | |||
443 | 6, | ||
444 | 18, | ||
445 | 33, | ||
446 | 0, | ||
447 | |||
448 | 33, | ||
449 | 0, | ||
450 | |||
451 | 33, | ||
452 | 0, | ||
453 | |||
454 | 14, | ||
455 | 33, | ||
456 | 0, | ||
457 | |||
458 | 11, | ||
459 | 33, | ||
460 | 0, | ||
461 | |||
462 | 10, | ||
463 | 33, | ||
464 | 0, | ||
465 | |||
466 | 33, | ||
467 | 0, | ||
468 | |||
469 | 13, | ||
470 | 33, | ||
471 | 0, | ||
472 | |||
473 | 17, | ||
474 | 33, | ||
475 | 0, | ||
476 | |||
477 | 2, | ||
478 | 0, | ||
479 | |||
480 | 33, | ||
481 | 0, | ||
482 | |||
483 | 15, | ||
484 | 33, | ||
485 | 0, | ||
486 | |||
487 | 3, | ||
488 | 0, | ||
489 | 0}; | ||
490 | # define YYTYPE char | ||
491 | struct yywork { YYTYPE verify, advance; } yycrank[] = { | ||
492 | 0,0, 0,0, 1,3, 0,0, | ||
493 | 0,0, 0,0, 0,0, 0,0, | ||
494 | 0,0, 0,0, 1,4, 1,5, | ||
495 | 6,29, 4,28, 0,0, 0,0, | ||
496 | 0,0, 0,0, 7,31, 0,0, | ||
497 | 6,29, 6,29, 0,0, 0,0, | ||
498 | 0,0, 0,0, 7,31, 7,31, | ||
499 | 0,0, 0,0, 0,0, 0,0, | ||
500 | 0,0, 0,0, 0,0, 1,6, | ||
501 | 4,28, 0,0, 0,0, 0,0, | ||
502 | 1,7, 0,0, 0,0, 0,0, | ||
503 | 1,3, 6,30, 1,8, 1,9, | ||
504 | 0,0, 1,10, 6,29, 7,31, | ||
505 | 8,33, 0,0, 6,29, 0,0, | ||
506 | 7,32, 0,0, 0,0, 6,29, | ||
507 | 7,31, 1,11, 0,0, 1,12, | ||
508 | 2,27, 7,31, 1,13, 11,39, | ||
509 | 12,40, 1,13, 26,56, 0,0, | ||
510 | 0,0, 2,8, 2,9, 0,0, | ||
511 | 6,29, 0,0, 0,0, 6,29, | ||
512 | 0,0, 0,0, 7,31, 0,0, | ||
513 | 0,0, 7,31, 0,0, 0,0, | ||
514 | 2,11, 0,0, 2,12, 0,0, | ||
515 | 0,0, 0,0, 0,0, 0,0, | ||
516 | 0,0, 0,0, 1,14, 0,0, | ||
517 | 0,0, 1,15, 1,16, 1,17, | ||
518 | 0,0, 22,52, 1,18, 18,47, | ||
519 | 23,53, 1,19, 42,63, 1,20, | ||
520 | 1,21, 25,55, 14,42, 1,22, | ||
521 | 15,43, 1,23, 1,24, 16,44, | ||
522 | 1,25, 16,45, 17,46, 19,48, | ||
523 | 21,51, 2,14, 20,49, 1,26, | ||
524 | 2,15, 2,16, 2,17, 24,54, | ||
525 | 20,50, 2,18, 44,64, 45,65, | ||
526 | 2,19, 46,66, 2,20, 2,21, | ||
527 | 27,57, 48,67, 2,22, 49,68, | ||
528 | 2,23, 2,24, 50,69, 2,25, | ||
529 | 52,70, 53,72, 27,58, 54,73, | ||
530 | 52,71, 9,34, 2,26, 9,35, | ||
531 | 9,35, 9,35, 9,35, 9,35, | ||
532 | 9,35, 9,35, 9,35, 9,35, | ||
533 | 9,35, 10,36, 55,74, 10,37, | ||
534 | 10,37, 10,37, 10,37, 10,37, | ||
535 | 10,37, 10,37, 10,37, 10,37, | ||
536 | 10,37, 57,75, 58,76, 64,80, | ||
537 | 66,81, 67,82, 70,83, 71,84, | ||
538 | 72,85, 73,86, 74,87, 10,38, | ||
539 | 10,38, 38,61, 10,38, 38,61, | ||
540 | 75,88, 76,89, 38,62, 38,62, | ||
541 | 38,62, 38,62, 38,62, 38,62, | ||
542 | 38,62, 38,62, 38,62, 38,62, | ||
543 | 80,92, 81,93, 13,41, 13,41, | ||
544 | 13,41, 13,41, 13,41, 13,41, | ||
545 | 13,41, 13,41, 13,41, 13,41, | ||
546 | 82,94, 83,95, 84,96, 10,38, | ||
547 | 10,38, 86,97, 10,38, 13,41, | ||
548 | 13,41, 13,41, 13,41, 13,41, | ||
549 | 13,41, 13,41, 13,41, 13,41, | ||
550 | 13,41, 13,41, 13,41, 13,41, | ||
551 | 13,41, 13,41, 13,41, 13,41, | ||
552 | 13,41, 13,41, 13,41, 13,41, | ||
553 | 13,41, 13,41, 13,41, 13,41, | ||
554 | 13,41, 87,98, 88,99, 60,79, | ||
555 | 60,79, 13,41, 60,79, 13,41, | ||
556 | 13,41, 13,41, 13,41, 13,41, | ||
557 | 13,41, 13,41, 13,41, 13,41, | ||
558 | 13,41, 13,41, 13,41, 13,41, | ||
559 | 13,41, 13,41, 13,41, 13,41, | ||
560 | 13,41, 13,41, 13,41, 13,41, | ||
561 | 13,41, 13,41, 13,41, 13,41, | ||
562 | 13,41, 33,33, 89,100, 60,79, | ||
563 | 60,79, 92,101, 60,79, 93,102, | ||
564 | 95,103, 33,33, 33,0, 96,104, | ||
565 | 99,105, 100,106, 102,107, 106,108, | ||
566 | 107,109, 35,35, 35,35, 35,35, | ||
567 | 35,35, 35,35, 35,35, 35,35, | ||
568 | 35,35, 35,35, 35,35, 108,110, | ||
569 | 0,0, 0,0, 0,0, 0,0, | ||
570 | 0,0, 0,0, 33,33, 0,0, | ||
571 | 0,0, 35,59, 35,59, 33,33, | ||
572 | 35,59, 0,0, 0,0, 33,33, | ||
573 | 0,0, 0,0, 0,0, 0,0, | ||
574 | 33,33, 0,0, 0,0, 0,0, | ||
575 | 0,0, 36,60, 36,60, 36,60, | ||
576 | 36,60, 36,60, 36,60, 36,60, | ||
577 | 36,60, 36,60, 36,60, 0,0, | ||
578 | 0,0, 33,33, 0,0, 0,0, | ||
579 | 33,33, 35,59, 35,59, 0,0, | ||
580 | 35,59, 36,38, 36,38, 59,77, | ||
581 | 36,38, 59,77, 0,0, 0,0, | ||
582 | 59,78, 59,78, 59,78, 59,78, | ||
583 | 59,78, 59,78, 59,78, 59,78, | ||
584 | 59,78, 59,78, 61,62, 61,62, | ||
585 | 61,62, 61,62, 61,62, 61,62, | ||
586 | 61,62, 61,62, 61,62, 61,62, | ||
587 | 0,0, 0,0, 0,0, 0,0, | ||
588 | 0,0, 36,38, 36,38, 0,0, | ||
589 | 36,38, 77,78, 77,78, 77,78, | ||
590 | 77,78, 77,78, 77,78, 77,78, | ||
591 | 77,78, 77,78, 77,78, 79,90, | ||
592 | 0,0, 79,90, 0,0, 0,0, | ||
593 | 79,91, 79,91, 79,91, 79,91, | ||
594 | 79,91, 79,91, 79,91, 79,91, | ||
595 | 79,91, 79,91, 90,91, 90,91, | ||
596 | 90,91, 90,91, 90,91, 90,91, | ||
597 | 90,91, 90,91, 90,91, 90,91, | ||
598 | 0,0}; | ||
599 | struct yysvf yysvec[] = { | ||
600 | 0, 0, 0, | ||
601 | yycrank+-1, 0, yyvstop+1, | ||
602 | yycrank+-28, yysvec+1, yyvstop+3, | ||
603 | yycrank+0, 0, yyvstop+5, | ||
604 | yycrank+4, 0, yyvstop+7, | ||
605 | yycrank+0, 0, yyvstop+10, | ||
606 | yycrank+-11, 0, yyvstop+12, | ||
607 | yycrank+-17, 0, yyvstop+14, | ||
608 | yycrank+7, 0, yyvstop+16, | ||
609 | yycrank+107, 0, yyvstop+18, | ||
610 | yycrank+119, 0, yyvstop+20, | ||
611 | yycrank+6, 0, yyvstop+23, | ||
612 | yycrank+7, 0, yyvstop+25, | ||
613 | yycrank+158, 0, yyvstop+27, | ||
614 | yycrank+4, yysvec+13, yyvstop+30, | ||
615 | yycrank+5, yysvec+13, yyvstop+33, | ||
616 | yycrank+11, yysvec+13, yyvstop+36, | ||
617 | yycrank+5, yysvec+13, yyvstop+39, | ||
618 | yycrank+5, yysvec+13, yyvstop+42, | ||
619 | yycrank+12, yysvec+13, yyvstop+45, | ||
620 | yycrank+21, yysvec+13, yyvstop+48, | ||
621 | yycrank+10, yysvec+13, yyvstop+51, | ||
622 | yycrank+4, yysvec+13, yyvstop+54, | ||
623 | yycrank+4, yysvec+13, yyvstop+57, | ||
624 | yycrank+21, yysvec+13, yyvstop+60, | ||
625 | yycrank+9, yysvec+13, yyvstop+63, | ||
626 | yycrank+9, 0, yyvstop+66, | ||
627 | yycrank+40, 0, yyvstop+68, | ||
628 | yycrank+0, yysvec+4, yyvstop+70, | ||
629 | yycrank+0, yysvec+6, 0, | ||
630 | yycrank+0, 0, yyvstop+72, | ||
631 | yycrank+0, yysvec+7, 0, | ||
632 | yycrank+0, 0, yyvstop+74, | ||
633 | yycrank+-280, 0, yyvstop+76, | ||
634 | yycrank+0, 0, yyvstop+78, | ||
635 | yycrank+249, 0, yyvstop+80, | ||
636 | yycrank+285, 0, yyvstop+82, | ||
637 | yycrank+0, yysvec+10, yyvstop+84, | ||
638 | yycrank+146, 0, 0, | ||
639 | yycrank+0, 0, yyvstop+86, | ||
640 | yycrank+0, 0, yyvstop+88, | ||
641 | yycrank+0, yysvec+13, yyvstop+90, | ||
642 | yycrank+10, yysvec+13, yyvstop+92, | ||
643 | yycrank+0, yysvec+13, yyvstop+94, | ||
644 | yycrank+19, yysvec+13, yyvstop+97, | ||
645 | yycrank+35, yysvec+13, yyvstop+99, | ||
646 | yycrank+27, yysvec+13, yyvstop+101, | ||
647 | yycrank+0, yysvec+13, yyvstop+103, | ||
648 | yycrank+42, yysvec+13, yyvstop+106, | ||
649 | yycrank+35, yysvec+13, yyvstop+108, | ||
650 | yycrank+30, yysvec+13, yyvstop+110, | ||
651 | yycrank+0, yysvec+13, yyvstop+112, | ||
652 | yycrank+36, yysvec+13, yyvstop+115, | ||
653 | yycrank+48, yysvec+13, yyvstop+117, | ||
654 | yycrank+35, yysvec+13, yyvstop+119, | ||
655 | yycrank+61, yysvec+13, yyvstop+121, | ||
656 | yycrank+0, 0, yyvstop+123, | ||
657 | yycrank+76, 0, 0, | ||
658 | yycrank+67, 0, 0, | ||
659 | yycrank+312, 0, 0, | ||
660 | yycrank+183, yysvec+36, yyvstop+125, | ||
661 | yycrank+322, 0, 0, | ||
662 | yycrank+0, yysvec+61, yyvstop+128, | ||
663 | yycrank+0, yysvec+13, yyvstop+130, | ||
664 | yycrank+78, yysvec+13, yyvstop+133, | ||
665 | yycrank+0, yysvec+13, yyvstop+135, | ||
666 | yycrank+81, yysvec+13, yyvstop+138, | ||
667 | yycrank+84, yysvec+13, yyvstop+140, | ||
668 | yycrank+0, yysvec+13, yyvstop+142, | ||
669 | yycrank+0, yysvec+13, yyvstop+145, | ||
670 | yycrank+81, yysvec+13, yyvstop+148, | ||
671 | yycrank+66, yysvec+13, yyvstop+150, | ||
672 | yycrank+74, yysvec+13, yyvstop+152, | ||
673 | yycrank+80, yysvec+13, yyvstop+154, | ||
674 | yycrank+78, yysvec+13, yyvstop+156, | ||
675 | yycrank+94, 0, 0, | ||
676 | yycrank+93, 0, 0, | ||
677 | yycrank+341, 0, 0, | ||
678 | yycrank+0, yysvec+77, yyvstop+158, | ||
679 | yycrank+356, 0, 0, | ||
680 | yycrank+99, yysvec+13, yyvstop+160, | ||
681 | yycrank+89, yysvec+13, yyvstop+163, | ||
682 | yycrank+108, yysvec+13, yyvstop+165, | ||
683 | yycrank+120, yysvec+13, yyvstop+167, | ||
684 | yycrank+104, yysvec+13, yyvstop+169, | ||
685 | yycrank+0, yysvec+13, yyvstop+171, | ||
686 | yycrank+113, yysvec+13, yyvstop+174, | ||
687 | yycrank+148, yysvec+13, yyvstop+176, | ||
688 | yycrank+133, 0, 0, | ||
689 | yycrank+181, 0, 0, | ||
690 | yycrank+366, 0, 0, | ||
691 | yycrank+0, yysvec+90, yyvstop+178, | ||
692 | yycrank+183, yysvec+13, yyvstop+181, | ||
693 | yycrank+182, yysvec+13, yyvstop+183, | ||
694 | yycrank+0, yysvec+13, yyvstop+185, | ||
695 | yycrank+172, yysvec+13, yyvstop+189, | ||
696 | yycrank+181, yysvec+13, yyvstop+191, | ||
697 | yycrank+0, yysvec+13, yyvstop+193, | ||
698 | yycrank+0, yysvec+13, yyvstop+196, | ||
699 | yycrank+189, 0, 0, | ||
700 | yycrank+195, 0, 0, | ||
701 | yycrank+0, yysvec+13, yyvstop+199, | ||
702 | yycrank+183, yysvec+13, yyvstop+202, | ||
703 | yycrank+0, yysvec+13, yyvstop+204, | ||
704 | yycrank+0, yysvec+13, yyvstop+207, | ||
705 | yycrank+0, 0, yyvstop+210, | ||
706 | yycrank+178, 0, 0, | ||
707 | yycrank+186, yysvec+13, yyvstop+212, | ||
708 | yycrank+204, 0, 0, | ||
709 | yycrank+0, yysvec+13, yyvstop+214, | ||
710 | yycrank+0, 0, yyvstop+217, | ||
711 | 0, 0, 0}; | ||
712 | struct yywork *yytop = yycrank+423; | ||
713 | struct yysvf *yybgin = yysvec+1; | ||
714 | char yymatch[] = { | ||
715 | 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , | ||
716 | 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , | ||
717 | 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , | ||
718 | 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , | ||
719 | 011 ,01 ,'"' ,01 ,01 ,01 ,01 ,047 , | ||
720 | 01 ,01 ,01 ,'+' ,01 ,'+' ,01 ,01 , | ||
721 | '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' , | ||
722 | '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 , | ||
723 | 01 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'D' , | ||
724 | 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , | ||
725 | 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , | ||
726 | 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,'A' , | ||
727 | 01 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'D' , | ||
728 | 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , | ||
729 | 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' , | ||
730 | 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 , | ||
731 | 0}; | ||
732 | char yyextra[] = { | ||
733 | 0,0,0,0,0,0,0,0, | ||
734 | 0,0,0,0,0,0,0,0, | ||
735 | 0,0,0,0,0,0,0,0, | ||
736 | 0,0,0,0,0,0,0,0, | ||
737 | 0,0,0,0,0,0,0,0, | ||
738 | 0}; | ||
739 | #ifndef lint | ||
740 | static char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */ | ||
741 | #endif | ||
742 | |||
743 | int yylineno =1; | ||
744 | # define YYU(x) x | ||
745 | # define NLSTATE yyprevious=YYNEWLINE | ||
746 | char yytext[YYLMAX]; | ||
747 | struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; | ||
748 | char yysbuf[YYLMAX]; | ||
749 | char *yysptr = yysbuf; | ||
750 | int *yyfnd; | ||
751 | extern struct yysvf *yyestate; | ||
752 | int yyprevious = YYNEWLINE; | ||
753 | yylook(){ | ||
754 | register struct yysvf *yystate, **lsp; | ||
755 | register struct yywork *yyt; | ||
756 | struct yysvf *yyz; | ||
757 | int yych, yyfirst; | ||
758 | struct yywork *yyr; | ||
759 | # ifdef LEXDEBUG | ||
760 | int debug; | ||
761 | # endif | ||
762 | char *yylastch; | ||
763 | /* start off machines */ | ||
764 | # ifdef LEXDEBUG | ||
765 | debug = 0; | ||
766 | # endif | ||
767 | yyfirst=1; | ||
768 | if (!yymorfg) | ||
769 | yylastch = yytext; | ||
770 | else { | ||
771 | yymorfg=0; | ||
772 | yylastch = yytext+yyleng; | ||
773 | } | ||
774 | for(;;){ | ||
775 | lsp = yylstate; | ||
776 | yyestate = yystate = yybgin; | ||
777 | if (yyprevious==YYNEWLINE) yystate++; | ||
778 | for (;;){ | ||
779 | # ifdef LEXDEBUG | ||
780 | if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); | ||
781 | # endif | ||
782 | yyt = yystate->yystoff; | ||
783 | if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ | ||
784 | yyz = yystate->yyother; | ||
785 | if(yyz == 0)break; | ||
786 | if(yyz->yystoff == yycrank)break; | ||
787 | } | ||
788 | *yylastch++ = yych = input(); | ||
789 | yyfirst=0; | ||
790 | tryagain: | ||
791 | # ifdef LEXDEBUG | ||
792 | if(debug){ | ||
793 | fprintf(yyout,"char "); | ||
794 | allprint(yych); | ||
795 | putchar('\n'); | ||
796 | } | ||
797 | # endif | ||
798 | yyr = yyt; | ||
799 | if ( (int)yyt > (int)yycrank){ | ||
800 | yyt = yyr + yych; | ||
801 | if (yyt <= yytop && yyt->verify+yysvec == yystate){ | ||
802 | if(yyt->advance+yysvec == YYLERR) /* error transitions */ | ||
803 | {unput(*--yylastch);break;} | ||
804 | *lsp++ = yystate = yyt->advance+yysvec; | ||
805 | goto contin; | ||
806 | } | ||
807 | } | ||
808 | # ifdef YYOPTIM | ||
809 | else if((int)yyt < (int)yycrank) { /* r < yycrank */ | ||
810 | yyt = yyr = yycrank+(yycrank-yyt); | ||
811 | # ifdef LEXDEBUG | ||
812 | if(debug)fprintf(yyout,"compressed state\n"); | ||
813 | # endif | ||
814 | yyt = yyt + yych; | ||
815 | if(yyt <= yytop && yyt->verify+yysvec == yystate){ | ||
816 | if(yyt->advance+yysvec == YYLERR) /* error transitions */ | ||
817 | {unput(*--yylastch);break;} | ||
818 | *lsp++ = yystate = yyt->advance+yysvec; | ||
819 | goto contin; | ||
820 | } | ||
821 | yyt = yyr + YYU(yymatch[yych]); | ||
822 | # ifdef LEXDEBUG | ||
823 | if(debug){ | ||
824 | fprintf(yyout,"try fall back character "); | ||
825 | allprint(YYU(yymatch[yych])); | ||
826 | putchar('\n'); | ||
827 | } | ||
828 | # endif | ||
829 | if(yyt <= yytop && yyt->verify+yysvec == yystate){ | ||
830 | if(yyt->advance+yysvec == YYLERR) /* error transition */ | ||
831 | {unput(*--yylastch);break;} | ||
832 | *lsp++ = yystate = yyt->advance+yysvec; | ||
833 | goto contin; | ||
834 | } | ||
835 | } | ||
836 | if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ | ||
837 | # ifdef LEXDEBUG | ||
838 | if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); | ||
839 | # endif | ||
840 | goto tryagain; | ||
841 | } | ||
842 | # endif | ||
843 | else | ||
844 | {unput(*--yylastch);break;} | ||
845 | contin: | ||
846 | # ifdef LEXDEBUG | ||
847 | if(debug){ | ||
848 | fprintf(yyout,"state %d char ",yystate-yysvec-1); | ||
849 | allprint(yych); | ||
850 | putchar('\n'); | ||
851 | } | ||
852 | # endif | ||
853 | ; | ||
854 | } | ||
855 | # ifdef LEXDEBUG | ||
856 | if(debug){ | ||
857 | fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); | ||
858 | allprint(yych); | ||
859 | putchar('\n'); | ||
860 | } | ||
861 | # endif | ||
862 | while (lsp-- > yylstate){ | ||
863 | *yylastch-- = 0; | ||
864 | if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ | ||
865 | yyolsp = lsp; | ||
866 | if(yyextra[*yyfnd]){ /* must backup */ | ||
867 | while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ | ||
868 | lsp--; | ||
869 | unput(*yylastch--); | ||
870 | } | ||
871 | } | ||
872 | yyprevious = YYU(*yylastch); | ||
873 | yylsp = lsp; | ||
874 | yyleng = yylastch-yytext+1; | ||
875 | yytext[yyleng] = 0; | ||
876 | # ifdef LEXDEBUG | ||
877 | if(debug){ | ||
878 | fprintf(yyout,"\nmatch "); | ||
879 | sprint(yytext); | ||
880 | fprintf(yyout," action %d\n",*yyfnd); | ||
881 | } | ||
882 | # endif | ||
883 | return(*yyfnd++); | ||
884 | } | ||
885 | unput(*yylastch); | ||
886 | } | ||
887 | if (yytext[0] == 0 /* && feof(yyin) */) | ||
888 | { | ||
889 | yysptr=yysbuf; | ||
890 | return(0); | ||
891 | } | ||
892 | yyprevious = yytext[0] = input(); | ||
893 | if (yyprevious>0) | ||
894 | output(yyprevious); | ||
895 | yylastch=yytext; | ||
896 | # ifdef LEXDEBUG | ||
897 | if(debug)putchar('\n'); | ||
898 | # endif | ||
899 | } | ||
900 | } | ||
901 | yyback(p, m) | ||
902 | int *p; | ||
903 | { | ||
904 | if (p==0) return(0); | ||
905 | while (*p) | ||
906 | { | ||
907 | if (*p++ == m) | ||
908 | return(1); | ||
909 | } | ||
910 | return(0); | ||
911 | } | ||
912 | /* the following are only used in the lex library */ | ||
913 | yyinput(){ | ||
914 | return(input()); | ||
915 | } | ||
916 | yyoutput(c) | ||
917 | int c; { | ||
918 | output(c); | ||
919 | } | ||
920 | yyunput(c) | ||
921 | int c; { | ||
922 | unput(c); | ||
923 | } | ||
diff --git a/fixed/lua.c b/fixed/lua.c new file mode 100644 index 00000000..f2cfc0b6 --- /dev/null +++ b/fixed/lua.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | ** lua.c | ||
3 | ** Linguagem para Usuarios de Aplicacao | ||
4 | ** TeCGraf - PUC-Rio | ||
5 | ** 28 Apr 93 | ||
6 | */ | ||
7 | |||
8 | #include <stdio.h> | ||
9 | |||
10 | #include "lua.h" | ||
11 | #include "lualib.h" | ||
12 | |||
13 | |||
14 | void test (void) | ||
15 | { | ||
16 | lua_pushobject(lua_getparam(1)); | ||
17 | lua_call ("c", 1); | ||
18 | } | ||
19 | |||
20 | |||
21 | static void callfunc (void) | ||
22 | { | ||
23 | lua_Object obj = lua_getparam (1); | ||
24 | if (lua_isstring(obj)) lua_call(lua_getstring(obj),0); | ||
25 | } | ||
26 | |||
27 | static void execstr (void) | ||
28 | { | ||
29 | lua_Object obj = lua_getparam (1); | ||
30 | if (lua_isstring(obj)) lua_dostring(lua_getstring(obj)); | ||
31 | } | ||
32 | |||
33 | int main (int argc, char *argv[]) | ||
34 | { | ||
35 | int i; | ||
36 | if (argc < 2) | ||
37 | { | ||
38 | puts ("usage: lua filename [functionnames]"); | ||
39 | return; | ||
40 | } | ||
41 | lua_register ("callfunc", callfunc); | ||
42 | lua_register ("execstr", execstr); | ||
43 | lua_register ("test", test); | ||
44 | iolib_open (); | ||
45 | strlib_open (); | ||
46 | mathlib_open (); | ||
47 | lua_dofile (argv[1]); | ||
48 | for (i=2; i<argc; i++) | ||
49 | { | ||
50 | lua_call (argv[i],0); | ||
51 | } | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | |||
diff --git a/floatingpoint.h b/floatingpoint.h new file mode 100644 index 00000000..347d2047 --- /dev/null +++ b/floatingpoint.h | |||
@@ -0,0 +1 @@ | |||
/* empty file to please silly code in iolib.c and opcode.c */ | |||
diff --git a/globals.lua b/globals.lua new file mode 100644 index 00000000..f204a9d5 --- /dev/null +++ b/globals.lua | |||
@@ -0,0 +1,5 @@ | |||
1 | k,v=nextvar(k) | ||
2 | while k do | ||
3 | print(k) | ||
4 | k,v=nextvar(k) | ||
5 | end | ||
diff --git a/save.lua b/save.lua new file mode 100644 index 00000000..1a4ba04d --- /dev/null +++ b/save.lua | |||
@@ -0,0 +1,47 @@ | |||
1 | $debug | ||
2 | |||
3 | |||
4 | function savevar (n,v) | ||
5 | if v = nil then return end; | ||
6 | if type(v) = "number" then print(n.."="..v) return end | ||
7 | if type(v) = "string" then print(n.."='"..v.."'") return end | ||
8 | if type(v) = "table" then | ||
9 | if v.__visited__ ~= nil then | ||
10 | print(n .. "=" .. v.__visited__); | ||
11 | else | ||
12 | print(n.."=@()") | ||
13 | v.__visited__ = n; | ||
14 | local r,f; | ||
15 | r,f = next(v,nil); | ||
16 | while r ~= nil do | ||
17 | if r ~= "__visited__" then | ||
18 | if type(r) = 'string' then | ||
19 | savevar(n.."['"..r.."']",f) | ||
20 | else | ||
21 | savevar(n.."["..r.."]",f) | ||
22 | end | ||
23 | end | ||
24 | r,f = next(v,r) | ||
25 | end | ||
26 | end | ||
27 | end | ||
28 | end | ||
29 | |||
30 | function save () | ||
31 | local n,v | ||
32 | n,v = nextvar(nil) | ||
33 | while n ~= nil do | ||
34 | savevar(n,v); | ||
35 | n,v = nextvar(n) | ||
36 | end | ||
37 | end | ||
38 | |||
39 | a = 3 | ||
40 | x = @{a = 4, b = "name", l=@[4,5,67]} | ||
41 | |||
42 | b = @{t=5} | ||
43 | x.next = b | ||
44 | |||
45 | |||
46 | save() | ||
47 | |||
diff --git a/sort.lua b/sort.lua new file mode 100644 index 00000000..f749c122 --- /dev/null +++ b/sort.lua | |||
@@ -0,0 +1,56 @@ | |||
1 | $debug | ||
2 | |||
3 | function quicksort(r,s) | ||
4 | if s<=r then return end -- caso basico da recursao | ||
5 | local v=x[r] | ||
6 | local i=r | ||
7 | local j=s+1 | ||
8 | i=i+1; while x[i]<v do i=i+1 end | ||
9 | j=j-1; while x[j]>v do j=j-1 end | ||
10 | x[i],x[j]=x[j],x[i] | ||
11 | while j>i do -- separacao | ||
12 | i=i+1; while x[i]<v do i=i+1 end | ||
13 | j=j-1; while x[j]>v do j=j-1 end | ||
14 | x[i],x[j]=x[j],x[i] | ||
15 | end | ||
16 | x[i],x[j]=x[j],x[i] -- undo last swap | ||
17 | x[j],x[r]=x[r],x[j] | ||
18 | quicksort(r,j-1) -- recursao | ||
19 | quicksort(j+1,s) | ||
20 | end | ||
21 | |||
22 | function sort(a,n) -- selection sort | ||
23 | local i=1 | ||
24 | while i<=n do | ||
25 | local m=i | ||
26 | local j=i+1 | ||
27 | while j<=n do | ||
28 | if a[j]<a[m] then m=j end | ||
29 | j=j+1 | ||
30 | end | ||
31 | a[i],a[m]=a[m],a[i] -- swap a[i] and a[m] | ||
32 | i=i+1 | ||
33 | end | ||
34 | end | ||
35 | |||
36 | function main() | ||
37 | x=@() | ||
38 | n=-1 | ||
39 | n=n+1; x[n]="a" | ||
40 | n=n+1; x[n]="waldemar" | ||
41 | n=n+1; x[n]="luiz" | ||
42 | n=n+1; x[n]="lula" | ||
43 | n=n+1; x[n]="peter" | ||
44 | n=n+1; x[n]="raquel" | ||
45 | n=n+1; x[n]="camilo" | ||
46 | n=n+1; x[n]="andre" | ||
47 | n=n+1; x[n]="marcelo" | ||
48 | n=n+1; x[n]="sedrez" | ||
49 | n=n+1; x[n]="z" | ||
50 | -- quicksort(1,n-1) | ||
51 | print(x[0]..","..x[1]..","..x[2]..","..x[3]..","..x[4]..","..x[5]..","..x[6]..","..x[7]..","..x[8]..","..x[9]..","..x[10]) | ||
52 | sort (x, n-1) | ||
53 | print(x[0]..","..x[1]..","..x[2]..","..x[3]..","..x[4]..","..x[5]..","..x[6]..","..x[7]..","..x[8]..","..x[9]..","..x[10]) | ||
54 | end | ||
55 | |||
56 | |||
diff --git a/test.lua b/test.lua new file mode 100644 index 00000000..c0a2eb42 --- /dev/null +++ b/test.lua | |||
@@ -0,0 +1,15 @@ | |||
1 | $debug | ||
2 | |||
3 | |||
4 | function somaP (x1,y1,x2,y2) | ||
5 | return x1+x2, y1+y2 | ||
6 | end | ||
7 | |||
8 | function norma (x,y) | ||
9 | return x*x+y*y | ||
10 | end | ||
11 | |||
12 | function retorno_multiplo () | ||
13 | print (norma(somaP(2,3,4,5))) | ||
14 | end | ||
15 | |||
diff --git a/type.lua b/type.lua new file mode 100644 index 00000000..26dc162f --- /dev/null +++ b/type.lua | |||
@@ -0,0 +1,35 @@ | |||
1 | $debug | ||
2 | |||
3 | function check (object, class) | ||
4 | local v = next(object,nil); | ||
5 | while v ~= nil do | ||
6 | if class[v] = nil then print("unknown field: " .. v) | ||
7 | elseif type(object[v]) ~= class[v].type | ||
8 | then print("wrong type for field " .. v) | ||
9 | end | ||
10 | v = next(object,v); | ||
11 | end | ||
12 | v = next(class,nil); | ||
13 | while v ~= nil do | ||
14 | if object[v] = nil then | ||
15 | if class[v].default ~= nil then | ||
16 | object[v] = class[v].default | ||
17 | else print("field "..v.." not initialized") | ||
18 | end | ||
19 | end | ||
20 | v = next(class,v); | ||
21 | end | ||
22 | end | ||
23 | |||
24 | typetrilha = @{x = @{default = 0, type = "number"}, | ||
25 | y = @{default = 0, type = "number"}, | ||
26 | name = @{type = "string"} | ||
27 | } | ||
28 | |||
29 | function trilha (t) check(t,typetrilha) end | ||
30 | |||
31 | t1 = @trilha{ x = 4, name = "3"} | ||
32 | |||
33 | a = "na".."me" | ||
34 | |||
35 | \ No newline at end of file | ||