File grammar.y changed (mode: 100644) (index ccb2c09..a3277eb) |
11 |
11 |
|
|
12 |
12 |
#define YYMAXDEPTH 100000 |
#define YYMAXDEPTH 100000 |
13 |
13 |
|
|
14 |
|
int yyerrorline (int errorlevel, int line, char *s) |
|
|
14 |
|
void yyerrorline (int errorlevel, int line, char *s) |
15 |
15 |
{ |
{ |
16 |
16 |
if (showerrorlevel[errorlevel]) { |
if (showerrorlevel[errorlevel]) { |
17 |
17 |
haderrors++; |
haderrors++; |
18 |
18 |
printf ("%s:%d: %s\n", curfile, line, s); |
printf ("%s:%d: %s\n", curfile, line, s); |
19 |
|
return 0; |
|
20 |
19 |
} |
} |
21 |
20 |
else |
else |
22 |
21 |
ignorederrors++; |
ignorederrors++; |
23 |
22 |
} |
} |
24 |
23 |
|
|
25 |
|
int yyerrorex (int errorlevel, char *s) |
|
|
24 |
|
void yyerrorex (int errorlevel, char *s) |
26 |
25 |
{ |
{ |
27 |
26 |
if (showerrorlevel[errorlevel]) { |
if (showerrorlevel[errorlevel]) { |
28 |
27 |
haderrors++; |
haderrors++; |
29 |
28 |
printf ("%s:%d: %s\n", curfile, lineno, s); |
printf ("%s:%d: %s\n", curfile, lineno, s); |
30 |
|
return 0; |
|
31 |
29 |
} |
} |
32 |
30 |
else |
else |
33 |
31 |
ignorederrors++; |
ignorederrors++; |
File misc.c changed (mode: 100644) (index c28bbbe..8447f57) |
... |
... |
int inloop; |
35 |
35 |
int afterendglobals; |
int afterendglobals; |
36 |
36 |
int *showerrorlevel; |
int *showerrorlevel; |
37 |
37 |
|
|
38 |
|
uint32_t hashfunc(const char *name, int size); |
|
|
38 |
|
uint32_t hashfunc(const char *name); |
|
39 |
|
void inittable(struct hashtable*, int); |
39 |
40 |
struct hashtable functions, globals, locals, params, types, initialized; |
struct hashtable functions, globals, locals, params, types, initialized; |
40 |
41 |
struct hashtable *curtab; |
struct hashtable *curtab; |
41 |
42 |
struct typenode *retval, *retcheck; |
struct typenode *retval, *retcheck; |
|
... |
... |
void showfuncdecl(struct funcdecl *fd) |
360 |
361 |
} |
} |
361 |
362 |
|
|
362 |
363 |
|
|
363 |
|
uint32_t hashfunc(const char *key, int size) { |
|
|
364 |
|
uint32_t hashfunc(const char *key) { |
364 |
365 |
//murmur3_32 |
//murmur3_32 |
365 |
366 |
static const uint32_t c1 = 0xcc9e2d51; |
static const uint32_t c1 = 0xcc9e2d51; |
366 |
367 |
static const uint32_t c2 = 0x1b873593; |
static const uint32_t c2 = 0x1b873593; |
|
... |
... |
void inittable(struct hashtable *h, int size){ |
420 |
421 |
|
|
421 |
422 |
void *lookup(struct hashtable *h, const char *name) |
void *lookup(struct hashtable *h, const char *name) |
422 |
423 |
{ |
{ |
423 |
|
int start = hashfunc(name, h->size); |
|
|
424 |
|
int start = hashfunc(name); |
424 |
425 |
int idx = (start + 1) % h->size; |
int idx = (start + 1) % h->size; |
425 |
426 |
for(; idx != start; idx = (idx + 1) % h->size){ |
for(; idx != start; idx = (idx + 1) % h->size){ |
426 |
427 |
if(h->bucket[idx].name){ |
if(h->bucket[idx].name){ |
|
... |
... |
void put(struct hashtable *h, const char *name, void *val) |
459 |
460 |
return; |
return; |
460 |
461 |
} |
} |
461 |
462 |
|
|
462 |
|
int start = hashfunc(name, h->size); |
|
|
463 |
|
int start = hashfunc(name); |
463 |
464 |
int idx = (start + 1) % h->size; |
int idx = (start + 1) % h->size; |
464 |
465 |
for(; /*idx != start*/; idx = (idx + 1) % h->size){ |
for(; /*idx != start*/; idx = (idx + 1) % h->size){ |
465 |
466 |
if(!h->bucket[idx].name){ |
if(!h->bucket[idx].name){ |
File misc.h changed (mode: 100644) (index f190fc7..8fa8b32) |
... |
... |
int canconvert(const struct typenode *from, const struct typenode *to, const int |
75 |
75 |
int canconvertreturn(const struct typenode *from, const struct typenode *to, const int linemod); |
int canconvertreturn(const struct typenode *from, const struct typenode *to, const int linemod); |
76 |
76 |
struct typenode* mkretty(struct typenode *ty, int ret); |
struct typenode* mkretty(struct typenode *ty, int ret); |
77 |
77 |
struct typenode* getTypePtr(struct typenode *ty); |
struct typenode* getTypePtr(struct typenode *ty); |
78 |
|
getTypeTag(struct typenode *ty); |
|
|
78 |
|
int getTypeTag(struct typenode *ty); |
79 |
79 |
int typeeq(struct typenode*, struct typenode*); |
int typeeq(struct typenode*, struct typenode*); |
80 |
80 |
struct typenode *combinetype(struct typenode *n1, struct typenode *n2); |
struct typenode *combinetype(struct typenode *n1, struct typenode *n2); |
81 |
81 |
void checkParameters(const struct paramlist *func, const struct paramlist *inp); |
void checkParameters(const struct paramlist *func, const struct paramlist *inp); |
File token.l changed (mode: 100644) (index 22ec4a6..a59add3) |
... |
... |
int yywrap() |
13 |
13 |
return 1; |
return 1; |
14 |
14 |
} |
} |
15 |
15 |
|
|
|
16 |
|
int rawcodelen; |
|
17 |
|
int rawcodespecial; |
|
18 |
|
int rawcodestartline; |
|
19 |
|
|
16 |
20 |
#include "grammar.tab.h" |
#include "grammar.tab.h" |
17 |
21 |
#include "misc.h" |
#include "misc.h" |
18 |
22 |
|
|
|
... |
... |
ID [a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? |
27 |
31 |
SPACE [ \t] |
SPACE [ \t] |
28 |
32 |
TABS [\x01-\x09\x0B\x0C\x0E-\x1F] |
TABS [\x01-\x09\x0B\x0C\x0E-\x1F] |
29 |
33 |
STRINGSTART ["] |
STRINGSTART ["] |
30 |
|
RAWCODESTART ['] |
|
|
34 |
|
|
|
35 |
|
%x RAWCODE |
31 |
36 |
|
|
32 |
37 |
%% |
%% |
33 |
38 |
|
|
|
... |
... |
RAWCODESTART ['] |
40 |
45 |
return NEWLINE; |
return NEWLINE; |
41 |
46 |
} |
} |
42 |
47 |
|
|
43 |
|
{RAWCODESTART} { |
|
44 |
|
int prevChar = 0; |
|
45 |
|
int curChar = input(); |
|
46 |
|
int special = 0; |
|
47 |
|
int count = 0; |
|
48 |
|
for(;;){ |
|
49 |
|
if (prevChar == '\r' && curChar != '\r') { |
|
50 |
|
lineno++; |
|
51 |
|
} |
|
52 |
|
if(curChar == EOF){ |
|
53 |
|
break; |
|
54 |
|
}else if (prevChar == '\\'){ |
|
55 |
|
if(count != 1){ |
|
56 |
|
yyerrorline(3, lineno, "Escaped chars are only allowed if they are the only char in the rawcode."); |
|
57 |
|
}else{ |
|
58 |
|
if (curChar != 'b' && curChar != 't' && curChar != 'r' && curChar != 'n' && curChar != 'f' && curChar != '\'' && curChar != '\\') |
|
59 |
|
yyerrorline(3, lineno, "Invalid escape character sequence"); |
|
60 |
|
curChar = 0; |
|
61 |
|
special = 1; |
|
62 |
|
} |
|
63 |
|
}else if (curChar == '\''){ |
|
64 |
|
if(count != 4 && count - special != 1){ |
|
65 |
|
yyerrorline(3, lineno, "Rawcodes must be 1 or 4 characters."); |
|
66 |
|
} |
|
67 |
|
break; |
|
|
48 |
|
[']\\[btrnf"\\]['] { return UNITTYPEINT; } |
|
49 |
|
[']\\.['] { |
|
50 |
|
yyerrorline(3, lineno, "Invalid escape character sequence"); |
|
51 |
|
return UNITTYPEINT; |
|
52 |
|
} |
|
53 |
|
|
|
54 |
|
['] { |
|
55 |
|
BEGIN(RAWCODE); |
|
56 |
|
rawcodelen = 0; |
|
57 |
|
rawcodestartline = lineno; |
|
58 |
|
} |
|
59 |
|
<RAWCODE>['] { |
|
60 |
|
if(rawcodelen != 4 && rawcodelen != 1){ |
|
61 |
|
yyerrorline(3, rawcodestartline, "Rawcodes must consist of 1 or 4 characters"); |
68 |
62 |
} |
} |
69 |
|
count++; |
|
70 |
|
prevChar = curChar; |
|
71 |
|
curChar = input(); |
|
|
63 |
|
BEGIN(INITIAL); |
|
64 |
|
return UNITTYPEINT; |
72 |
65 |
} |
} |
73 |
|
return UNITTYPEINT; |
|
74 |
|
} |
|
|
66 |
|
|
|
67 |
|
<RAWCODE>\\[btrnf"\\] { |
|
68 |
|
rawcodelen++; |
|
69 |
|
yyerrorline(3, rawcodestartline, "Escaped chars are only allowed if they are the only char in the rawcode."); |
|
70 |
|
} |
|
71 |
|
<RAWCODE>\\. { |
|
72 |
|
yyerrorline(3, lineno, "Invalid escape character sequence"); |
|
73 |
|
rawcodelen++; |
|
74 |
|
} |
|
75 |
|
<RAWCODE>\r*\n { lineno++; isconstant = 0; rawcodelen += strlen(yytext) ;} |
|
76 |
|
<RAWCODE>. { rawcodelen++; } |
|
77 |
|
|
75 |
78 |
|
|
76 |
79 |
{STRINGSTART} { int prevChar = 0; |
{STRINGSTART} { int prevChar = 0; |
77 |
80 |
int curChar = input(); |
int curChar = input(); |