Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Added \n, \r, \t in double-quotes. Added debug keyword handling. Now it parses everything in the Scripts directory except demo.ai, which looks like it could never work anyway. | a76d8de5a85768c58297ad05dcc3bd361e3c8d69 | cilibrar | 2003-06-08 10:12:17 |
Make downcasting bug a bit more restrictive to minimize future problems. | 3bef4ca2d62e1de3fe70986de71a3da2b68ff25f | cilibrar | 2003-06-08 09:52:03 |
Fixed segfault involving undeclared variables by assuming they are integer. | 76b34be901540214c21b8af681bcf42620ca0e21 | cilibrar | 2003-06-08 09:49:56 |
Fixed bug with string literal addition. Added unfortunate special case to canconvert to allow downcasts from base to derived. Waiting on Blizzard to fix this one. (such a cast appears in one place in Blizzard.j) | 1384b0771dd6db4c6cb548fef3331f518509c68e | cilibrar | 2003-06-08 09:40:28 |
Allow null to be converted to code, string, and appropriate comparisons. | a2a05f7938a46a6a873d0f3313af760900403c88 | cilibrar | 2003-06-08 07:50:23 |
lets begin | edb29fca55a82526251fd7c671302425ed97d9bd | cilibrar | 2003-06-08 07:47:56 |
File | Lines added | Lines deleted |
---|---|---|
src/grammar.y | 8 | 0 |
src/misc.c | 8 | 1 |
src/misc.h | 1 | 0 |
src/token.l | 2 | 2 |
File src/grammar.y changed (mode: 100644) (index 8832ccf..274ed5f) | |||
11 | 11 | ||
12 | 12 | int yyerror (char *s) /* Called by yyparse on error */ | int yyerror (char *s) /* Called by yyparse on error */ |
13 | 13 | { | { |
14 | haderrors++; | ||
14 | 15 | printf ("%d: %s\n", lineno, s); | printf ("%d: %s\n", lineno, s); |
15 | 16 | return 0; | return 0; |
16 | 17 | } | } |
... | ... | int main(int argc, char **argv) | |
31 | 32 | printf("Got result %d, %s\n", result, yytext); | printf("Got result %d, %s\n", result, yytext); |
32 | 33 | } | } |
33 | 34 | } | } |
35 | if (!haderrors) { | ||
36 | printf("Parse successful, no errors\n"); | ||
37 | return 0; | ||
38 | } | ||
39 | else | ||
40 | return 1; | ||
34 | 41 | } | } |
35 | 42 | ||
36 | 43 | #define YYSTYPE union node | #define YYSTYPE union node |
... | ... | statement: NEWLINE | |
288 | 295 | | LOOP loopbody ENDLOOP | | LOOP loopbody ENDLOOP |
289 | 296 | | RETURN expr { canconvert($2.ty, retval); } | | RETURN expr { canconvert($2.ty, retval); } |
290 | 297 | | RETURN { if (retval != gNothing) yyerror("Cannot return value from function that returns nothing"); } | | RETURN { if (retval != gNothing) yyerror("Cannot return value from function that returns nothing"); } |
298 | | DEBUG statement | ||
291 | 299 | | error | | error |
292 | 300 | ; | ; |
293 | 301 |
File src/misc.c changed (mode: 100644) (index 6cffeca..f9497e8) | |||
6 | 6 | #include "misc.h" | #include "misc.h" |
7 | 7 | ||
8 | 8 | int lineno = 1; | int lineno = 1; |
9 | int haderrors = 0; | ||
9 | 10 | ||
10 | 11 | int hashfunc(const char *name); | int hashfunc(const char *name); |
11 | 12 | struct hashtable functions, globals, locals, params, types; | struct hashtable functions, globals, locals, params, types; |
... | ... | void put(struct hashtable *h, const char *name, void *val) | |
181 | 182 | { | { |
182 | 183 | struct hashnode *hn; | struct hashnode *hn; |
183 | 184 | int hf; | int hf; |
184 | assert(lookup(h, name) == NULL); | ||
185 | |||
186 | if (lookup(h, name) != NULL) { | ||
187 | char ebuf[1024]; | ||
188 | sprintf(ebuf, "Symbol %s multiply defined", name); | ||
189 | yyerror(ebuf); | ||
190 | return; | ||
191 | } | ||
185 | 192 | hf = hashfunc(name); | hf = hashfunc(name); |
186 | 193 | hn = calloc(sizeof(struct hashnode), 1); | hn = calloc(sizeof(struct hashnode), 1); |
187 | 194 | hn->name = strdup(name); | hn->name = strdup(name); |
File src/misc.h changed (mode: 100644) (index 71f1959..80f791f) | |||
... | ... | int canconvert(const struct typenode *from, const struct typenode *to); | |
64 | 64 | void checkParameters(const struct paramlist *func, const struct paramlist *inp); | void checkParameters(const struct paramlist *func, const struct paramlist *inp); |
65 | 65 | ||
66 | 66 | extern int lineno; | extern int lineno; |
67 | extern int haderrors; | ||
67 | 68 | extern char *yytext; | extern char *yytext; |
68 | 69 | extern int yydebug; | extern int yydebug; |
69 | 70 | extern struct hashtable functions, globals, locals, params, types, *curtab; | extern struct hashtable functions, globals, locals, params, types, *curtab; |
File src/token.l changed (mode: 100644) (index 18ab9f1..80fb4ab) | |||
... | ... | CSTART [/][*] | |
16 | 16 | CEND [*][/] | CEND [*][/] |
17 | 17 | STRINGSTART ["] | STRINGSTART ["] |
18 | 18 | STILLSTRINGA [^"\\] | STILLSTRINGA [^"\\] |
19 | STILLSTRINGB [\\]["] | ||
19 | STILLSTRINGB [\\]["nrt] | ||
20 | 20 | STILLSTRINGC [\\][\\] | STILLSTRINGC [\\][\\] |
21 | 21 | STRINGDONE ["] | STRINGDONE ["] |
22 | 22 | UNITTYPEINT ['][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]['] | UNITTYPEINT ['][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]['] |
... | ... | UNITTYPEINT ['][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]['] | |
89 | 89 | {ID} return ID; | {ID} return ID; |
90 | 90 | {UNITTYPEINT} return UNITTYPEINT; | {UNITTYPEINT} return UNITTYPEINT; |
91 | 91 | ||
92 | "<"|">"|"!"|"["|"]"|"("|")"|"+"|"-"|"*"|"/"|"." return DEBUG; | ||
92 | "<"|">"|"!"|"["|"]"|"("|")"|"+"|"-"|"*"|"/"|"." return TNULL; | ||
93 | 93 | ||
94 | 94 | [ \t]+ /* eat up whitespace */ | [ \t]+ /* eat up whitespace */ |
95 | 95 |