File grammar.y changed (mode: 100644) (index 839455d..a2c1f9b) |
76 |
76 |
%token INTLIT |
%token INTLIT |
77 |
77 |
%token REALLIT |
%token REALLIT |
78 |
78 |
%token UNITTYPEINT |
%token UNITTYPEINT |
79 |
|
%token RETURNBUG |
|
|
79 |
|
%token ANNOTATION |
80 |
80 |
|
|
81 |
81 |
%right EQUALS |
%right EQUALS |
82 |
82 |
%left AND |
%left AND |
|
... |
... |
expr: intexpr { $$.ty = gInteger; } |
155 |
155 |
snprintf(ebuf, 1024, "Function %s must not take any arguments when used as code", $2.str); |
snprintf(ebuf, 1024, "Function %s must not take any arguments when used as code", $2.str); |
156 |
156 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
157 |
157 |
} |
} |
158 |
|
$$.ty = gCode; |
|
|
158 |
|
if( fd->ret == gBoolean) { |
|
159 |
|
$$.ty = gCodeReturnsBoolean; |
|
160 |
|
} else { |
|
161 |
|
$$.ty = gCodeReturnsNoBoolean; |
|
162 |
|
} |
159 |
163 |
} |
} |
160 |
164 |
} |
} |
161 |
165 |
| TNULL { $$.ty = gNull; } |
| TNULL { $$.ty = gNull; } |
|
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
247 |
251 |
} |
} |
248 |
252 |
if (fd == fCurrent && fCurrent) |
if (fd == fCurrent && fCurrent) |
249 |
253 |
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
250 |
|
checkParameters(fd->p, $3.pl); |
|
|
254 |
|
checkParameters(fd->p, $3.pl, fd == fFilter || fd == fCondition); |
251 |
255 |
$$.ty = fd->ret; |
$$.ty = fd->ret; |
252 |
256 |
} |
} |
253 |
257 |
} |
} |
|
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
268 |
272 |
} else { |
} else { |
269 |
273 |
if (fd == fCurrent && fCurrent) |
if (fd == fCurrent && fCurrent) |
270 |
274 |
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
271 |
|
checkParameters(fd->p, $3.pl); |
|
|
275 |
|
checkParameters(fd->p, $3.pl, fd == fCondition || fd == fFilter); |
272 |
276 |
$$.ty = fd->ret; |
$$.ty = fd->ret; |
273 |
277 |
} |
} |
274 |
278 |
} |
} |
|
... |
... |
funcdecl: nativefuncdecl { $$.fd = $1.fd; } |
308 |
312 |
|
|
309 |
313 |
nativefuncdecl: NATIVE rid TAKES optparam_list RETURNS opttype |
nativefuncdecl: NATIVE rid TAKES optparam_list RETURNS opttype |
310 |
314 |
{ |
{ |
311 |
|
if (ht_lookup(&locals, $2.str) || ht_lookup(¶ms, $2.str) || ht_lookup(&globals, $2.str)) { |
|
312 |
|
char buf[1024]; |
|
313 |
|
snprintf(buf, 1024, "%s already defined as variable", $2.str); |
|
314 |
|
yyerrorex(3, buf); |
|
315 |
|
} else if (ht_lookup(&types, $2.str)) { |
|
316 |
|
char buf[1024]; |
|
317 |
|
snprintf(buf, 1024, "%s already defined as type", $2.str); |
|
318 |
|
yyerrorex(3, buf); |
|
319 |
|
} |
|
320 |
|
$$.fd = newfuncdecl(); |
|
321 |
|
$$.fd->name = strdup($2.str); |
|
322 |
|
$$.fd->p = $4.pl; |
|
323 |
|
$$.fd->ret = $6.ty; |
|
324 |
|
//printf("***** %s = %s\n", $2.str, $$.fd->ret->typename); |
|
325 |
|
$$.fd->isconst = isconstant; |
|
326 |
|
put(&functions, $$.fd->name, $$.fd); |
|
327 |
|
//showfuncdecl($$.fd); |
|
|
315 |
|
if (ht_lookup(&locals, $2.str) || ht_lookup(¶ms, $2.str) || ht_lookup(&globals, $2.str)) { |
|
316 |
|
char buf[1024]; |
|
317 |
|
snprintf(buf, 1024, "%s already defined as variable", $2.str); |
|
318 |
|
yyerrorex(3, buf); |
|
319 |
|
} else if (ht_lookup(&types, $2.str)) { |
|
320 |
|
char buf[1024]; |
|
321 |
|
snprintf(buf, 1024, "%s already defined as type", $2.str); |
|
322 |
|
yyerrorex(3, buf); |
|
323 |
|
} |
|
324 |
|
$$.fd = newfuncdecl(); |
|
325 |
|
$$.fd->name = strdup($2.str); |
|
326 |
|
$$.fd->p = $4.pl; |
|
327 |
|
$$.fd->ret = $6.ty; |
|
328 |
|
$$.fd->isconst = isconstant; |
|
329 |
|
|
|
330 |
|
put(&functions, $$.fd->name, $$.fd); |
|
331 |
|
|
|
332 |
|
if( !strcmp("Filter", $$.fd->name) ){ |
|
333 |
|
fFilter = $$.fd; |
|
334 |
|
}else if( !strcmp("Condition", $$.fd->name) ){ |
|
335 |
|
fCondition = $$.fd; |
|
336 |
|
} |
|
337 |
|
|
328 |
338 |
} |
} |
329 |
339 |
; |
; |
330 |
340 |
|
|
|
... |
... |
funcdefncore: funcbegin localblock codeblock funcend { |
337 |
347 |
if(retval != gNothing) { |
if(retval != gNothing) { |
338 |
348 |
if(!getTypeTag($3.ty)) |
if(!getTypeTag($3.ty)) |
339 |
349 |
yyerrorline(1, lineno - 1, "Missing return"); |
yyerrorline(1, lineno - 1, "Missing return"); |
340 |
|
else if (returnbug || fnhasrbannotation) |
|
|
350 |
|
else if ((pjass_flags & flag_rb) || (fnannotations & flag_rb)) |
341 |
351 |
canconvertreturn($3.ty, retval, -1); |
canconvertreturn($3.ty, retval, -1); |
342 |
352 |
} |
} |
343 |
|
fnhasrbannotation = 0; |
|
|
353 |
|
fnannotations = 0; |
344 |
354 |
} |
} |
345 |
|
| funcbegin localblock codeblock {yyerrorex(0, "Missing endfunction"); ht_clear(¶ms); ht_clear(&locals); ht_clear(&initialized); curtab = &globals; fnhasrbannotation = 0;} |
|
|
355 |
|
| funcbegin localblock codeblock {yyerrorex(0, "Missing endfunction"); ht_clear(¶ms); ht_clear(&locals); ht_clear(&initialized); curtab = &globals; fnannotations = 0;} |
346 |
356 |
; |
; |
347 |
357 |
|
|
348 |
358 |
funcend: ENDFUNCTION { ht_clear(¶ms); ht_clear(&locals); ht_clear(&initialized); curtab = &globals; inblock = 0; inconstant = 0; infunction = 0; } |
funcend: ENDFUNCTION { ht_clear(¶ms); ht_clear(&locals); ht_clear(&initialized); curtab = &globals; inblock = 0; inconstant = 0; infunction = 0; } |
|
... |
... |
funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype { |
388 |
398 |
} |
} |
389 |
399 |
} |
} |
390 |
400 |
retval = $$.fd->ret; |
retval = $$.fd->ret; |
391 |
|
fnhasrbannotation = rbannotated; |
|
|
401 |
|
fnannotations = annotations; |
392 |
402 |
inblock = 1; |
inblock = 1; |
393 |
403 |
inloop = 0; |
inloop = 0; |
394 |
404 |
//showfuncdecl($$.fd); |
//showfuncdecl($$.fd); |
|
... |
... |
statement: newline { $$.ty = gEmpty; } |
489 |
499 |
$$.ty = mkretty($2.ty, 1); |
$$.ty = mkretty($2.ty, 1); |
490 |
500 |
if(retval == gNothing) |
if(retval == gNothing) |
491 |
501 |
yyerrorline(1, lineno - 1, "Cannot return value from function that returns nothing"); |
yyerrorline(1, lineno - 1, "Cannot return value from function that returns nothing"); |
492 |
|
else if (!returnbug && !fnhasrbannotation) |
|
|
502 |
|
else if (!(pjass_flags & flag_rb) && !(fnannotations & flag_rb)) |
493 |
503 |
canconvertreturn($2.ty, retval, 0); |
canconvertreturn($2.ty, retval, 0); |
494 |
504 |
} |
} |
495 |
505 |
| RETURN newline { |
| RETURN newline { |
|
... |
... |
primtype: HANDLE { $$.ty = ht_lookup(&types, yytext); } |
794 |
804 |
| CODE { $$.ty = ht_lookup(&types, yytext); } |
| CODE { $$.ty = ht_lookup(&types, yytext); } |
795 |
805 |
; |
; |
796 |
806 |
|
|
797 |
|
newline: NEWLINE { rbannotated = 0; } |
|
798 |
|
| RETURNBUG { rbannotated = 1; } |
|
|
807 |
|
newline: NEWLINE { annotations = 0; } |
|
808 |
|
| ANNOTATION { annotations = updateannotation(annotations, yytext); } |
799 |
809 |
; |
; |
File main.c changed (mode: 100644) (index 32d1254..b8a962b) |
6 |
6 |
#ifndef VERSIONSTR |
#ifndef VERSIONSTR |
7 |
7 |
#define VERSIONSTR "1.0-git" |
#define VERSIONSTR "1.0-git" |
8 |
8 |
#endif |
#endif |
9 |
|
#define ERRORLEVELNUM 4 |
|
10 |
9 |
|
|
11 |
|
static struct typenode* addPrimitiveType(const char *name) { |
|
12 |
|
struct typenode *new = newtypenode(name, NULL); |
|
13 |
|
put(&types, name, new); |
|
14 |
|
return new; |
|
|
10 |
|
static struct typenode* addPrimitiveType(const char *name) |
|
11 |
|
{ |
|
12 |
|
struct typenode *newty= newtypenode(name, NULL); |
|
13 |
|
put(&types, name, newty); |
|
14 |
|
return newty; |
15 |
15 |
} |
} |
16 |
16 |
|
|
17 |
17 |
|
|
18 |
|
static void init() { |
|
|
18 |
|
static void init() |
|
19 |
|
{ |
19 |
20 |
ht_init(&functions, 8191); |
ht_init(&functions, 8191); |
20 |
21 |
ht_init(&globals, 8191); |
ht_init(&globals, 8191); |
21 |
22 |
ht_init(&locals, 23); |
ht_init(&locals, 23); |
|
... |
... |
static void init() { |
30 |
31 |
gString = addPrimitiveType("string"); |
gString = addPrimitiveType("string"); |
31 |
32 |
gCode = addPrimitiveType("code"); |
gCode = addPrimitiveType("code"); |
32 |
33 |
|
|
|
34 |
|
gCodeReturnsBoolean = newtypenode("codereturnsboolean", gCode); |
|
35 |
|
gCodeReturnsNoBoolean = newtypenode("codereturnsboolean", gCode); |
|
36 |
|
|
33 |
37 |
gNothing = newtypenode("nothing", NULL); |
gNothing = newtypenode("nothing", NULL); |
34 |
38 |
gNull = newtypenode("null", NULL); |
gNull = newtypenode("null", NULL); |
35 |
39 |
|
|
|
... |
... |
static void init() { |
38 |
42 |
gEmpty = newtypenode("empty", NULL); |
gEmpty = newtypenode("empty", NULL); |
39 |
43 |
|
|
40 |
44 |
curtab = &globals; |
curtab = &globals; |
|
45 |
|
|
|
46 |
|
pjass_flags = 0; |
|
47 |
|
|
41 |
48 |
fno = 0; |
fno = 0; |
42 |
49 |
strict = 0; |
strict = 0; |
43 |
50 |
returnbug = 0; |
returnbug = 0; |
44 |
|
fnhasrbannotation = 0; |
|
45 |
|
rbannotated = 0; |
|
|
51 |
|
fnannotations = 0; |
|
52 |
|
annotations = 0; |
46 |
53 |
haderrors = 0; |
haderrors = 0; |
47 |
54 |
ignorederrors = 0; |
ignorederrors = 0; |
48 |
55 |
islinebreak = 1; |
islinebreak = 1; |
|
... |
... |
static void init() { |
50 |
57 |
isconstant = 0; |
isconstant = 0; |
51 |
58 |
inconstant = 0; |
inconstant = 0; |
52 |
59 |
infunction = 0; |
infunction = 0; |
53 |
|
fCurrent = 0; |
|
|
60 |
|
|
|
61 |
|
fCurrent = NULL; |
|
62 |
|
fFilter = NULL; |
|
63 |
|
fCondition = NULL; |
54 |
64 |
} |
} |
55 |
65 |
|
|
56 |
|
static void dofile(FILE *fp, const char *name) { |
|
|
66 |
|
static void dofile(FILE *fp, const char *name) |
|
67 |
|
{ |
57 |
68 |
lineno = 1; |
lineno = 1; |
58 |
69 |
islinebreak = 1; |
islinebreak = 1; |
59 |
70 |
isconstant = 0; |
isconstant = 0; |
|
... |
... |
static void dofile(FILE *fp, const char *name) { |
75 |
86 |
fno++; |
fno++; |
76 |
87 |
} |
} |
77 |
88 |
|
|
78 |
|
static void printversion() { |
|
|
89 |
|
static void printversion() |
|
90 |
|
{ |
79 |
91 |
printf("Pjass version %s by Rudi Cilibrasi, modified by AIAndy, PitzerMike, Deaod and lep\n", VERSIONSTR); |
printf("Pjass version %s by Rudi Cilibrasi, modified by AIAndy, PitzerMike, Deaod and lep\n", VERSIONSTR); |
80 |
92 |
} |
} |
81 |
93 |
|
|
82 |
|
static void doparse(int argc, char **argv) { |
|
|
94 |
|
static void doparse(int argc, char **argv) |
|
95 |
|
{ |
83 |
96 |
int i; |
int i; |
84 |
97 |
for (i = 1; i < argc; ++i) { |
for (i = 1; i < argc; ++i) { |
85 |
98 |
if (argv[i][0] == '-' && argv[i][1] == 0) { |
if (argv[i][0] == '-' && argv[i][1] == 0) { |
|
... |
... |
printf( |
114 |
127 |
exit(0); |
exit(0); |
115 |
128 |
} |
} |
116 |
129 |
if (strcmp(argv[i], "+s") == 0) { |
if (strcmp(argv[i], "+s") == 0) { |
117 |
|
strict = 1; |
|
|
130 |
|
pjass_flags |= flag_strict; |
118 |
131 |
continue; |
continue; |
119 |
132 |
} |
} |
120 |
133 |
if (strcmp(argv[i], "-s") == 0) { |
if (strcmp(argv[i], "-s") == 0) { |
121 |
|
strict = 0; |
|
|
134 |
|
pjass_flags &= ~flag_strict; |
122 |
135 |
continue; |
continue; |
123 |
136 |
} |
} |
124 |
137 |
if (strcmp(argv[i], "+rb") == 0) { |
if (strcmp(argv[i], "+rb") == 0) { |
125 |
|
returnbug = 1; |
|
|
138 |
|
pjass_flags |= flag_rb; |
126 |
139 |
continue; |
continue; |
127 |
140 |
} |
} |
128 |
141 |
if (strcmp(argv[i], "-rb") == 0) { |
if (strcmp(argv[i], "-rb") == 0) { |
129 |
|
returnbug = 0; |
|
|
142 |
|
pjass_flags &= ~flag_rb; |
130 |
143 |
continue; |
continue; |
131 |
144 |
} |
} |
132 |
145 |
|
|
|
... |
... |
printf( |
149 |
162 |
} |
} |
150 |
163 |
int main(int argc, char **argv) |
int main(int argc, char **argv) |
151 |
164 |
{ |
{ |
152 |
|
init(); |
|
153 |
|
doparse(argc, argv); |
|
154 |
|
|
|
155 |
|
if (!haderrors && didparse) { |
|
156 |
|
printf("Parse successful: %8d lines: %s\n", totlines, "<total>"); |
|
157 |
|
if (ignorederrors) |
|
158 |
|
printf("%d errors ignored", ignorederrors); |
|
159 |
|
|
|
160 |
|
return 0; |
|
161 |
|
} |
|
162 |
|
else { |
|
163 |
|
if (haderrors) |
|
164 |
|
printf("Parse failed: %d error%s total\n", haderrors, haderrors == 1 ? "" : "s"); |
|
165 |
|
else |
|
166 |
|
printf("Parse failed\n"); |
|
167 |
|
if (ignorederrors) |
|
168 |
|
printf("%d errors ignored", ignorederrors); |
|
169 |
|
return 1; |
|
170 |
|
} |
|
|
165 |
|
init(); |
|
166 |
|
doparse(argc, argv); |
|
167 |
|
|
|
168 |
|
if (!haderrors && didparse) { |
|
169 |
|
printf("Parse successful: %8d lines: %s\n", totlines, "<total>"); |
|
170 |
|
if (ignorederrors) { |
|
171 |
|
printf("%d errors ignored", ignorederrors); |
|
172 |
|
} |
|
173 |
|
|
|
174 |
|
return 0; |
|
175 |
|
} else { |
|
176 |
|
if (haderrors) { |
|
177 |
|
printf("Parse failed: %d error%s total\n", haderrors, haderrors == 1 ? "" : "s"); |
|
178 |
|
} else { |
|
179 |
|
printf("Parse failed\n"); |
|
180 |
|
} |
|
181 |
|
if (ignorederrors) { |
|
182 |
|
printf("%d errors ignored", ignorederrors); |
|
183 |
|
} |
|
184 |
|
return 1; |
|
185 |
|
} |
171 |
186 |
} |
} |
File misc.c changed (mode: 100644) (index 3c449d2..f4721e4) |
12 |
12 |
|
|
13 |
13 |
#include "misc.h" |
#include "misc.h" |
14 |
14 |
|
|
|
15 |
|
int pjass_flags; |
15 |
16 |
|
|
16 |
17 |
int fno; |
int fno; |
17 |
18 |
int lineno; |
int lineno; |
|
... |
... |
int infunction; |
25 |
26 |
int inblock; |
int inblock; |
26 |
27 |
int strict; |
int strict; |
27 |
28 |
int returnbug; |
int returnbug; |
28 |
|
int fnhasrbannotation; |
|
29 |
|
int rbannotated; |
|
|
29 |
|
int fnannotations; |
|
30 |
|
int annotations; |
30 |
31 |
int didparse; |
int didparse; |
31 |
32 |
int inloop; |
int inloop; |
32 |
33 |
int afterendglobals; |
int afterendglobals; |
|
... |
... |
struct hashtable *curtab; |
44 |
45 |
const struct typenode *retval; |
const struct typenode *retval; |
45 |
46 |
const char *curfile; |
const char *curfile; |
46 |
47 |
struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gEmpty; |
struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gEmpty; |
|
48 |
|
struct typenode *gCodeReturnsNoBoolean, *gCodeReturnsBoolean; |
47 |
49 |
struct typenode *gEmpty; |
struct typenode *gEmpty; |
48 |
50 |
struct funcdecl *fCurrent; |
struct funcdecl *fCurrent; |
|
51 |
|
struct funcdecl *fFilter, *fCondition; |
49 |
52 |
|
|
50 |
53 |
|
|
51 |
54 |
void yyerrorline (int errorlevel, int line, const char *s) |
void yyerrorline (int errorlevel, int line, const char *s) |
|
... |
... |
const struct typeandname *getVariable(const char *varname) |
222 |
225 |
{ |
{ |
223 |
226 |
char ebuf[1024]; |
char ebuf[1024]; |
224 |
227 |
struct typeandname *result; |
struct typeandname *result; |
|
228 |
|
|
225 |
229 |
result = ht_lookup(&locals, varname); |
result = ht_lookup(&locals, varname); |
226 |
230 |
if (result) return result; |
if (result) return result; |
|
231 |
|
|
227 |
232 |
result = ht_lookup(¶ms, varname); |
result = ht_lookup(¶ms, varname); |
228 |
233 |
if (result) return result; |
if (result) return result; |
|
234 |
|
|
229 |
235 |
result = ht_lookup(&globals, varname); |
result = ht_lookup(&globals, varname); |
230 |
236 |
if (result) return result; |
if (result) return result; |
|
237 |
|
|
231 |
238 |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
232 |
239 |
getsuggestions(varname, ebuf, 1024, 3, &locals, ¶ms, &globals); |
getsuggestions(varname, ebuf, 1024, 3, &locals, ¶ms, &globals); |
233 |
240 |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
|
241 |
|
|
234 |
242 |
// Store it as unidentified variable |
// Store it as unidentified variable |
235 |
243 |
const struct typeandname *newtan = newtypeandname(gAny, varname); |
const struct typeandname *newtan = newtypeandname(gAny, varname); |
236 |
244 |
put(curtab, varname, (void*)newtan); |
put(curtab, varname, (void*)newtan); |
|
... |
... |
const struct typeandname *getVariable(const char *varname) |
240 |
248 |
return newtan; |
return newtan; |
241 |
249 |
} |
} |
242 |
250 |
|
|
243 |
|
void validateGlobalAssignment(const char *varname) { |
|
|
251 |
|
void validateGlobalAssignment(const char *varname) |
|
252 |
|
{ |
244 |
253 |
char ebuf[1024]; |
char ebuf[1024]; |
245 |
254 |
struct typeandname *result; |
struct typeandname *result; |
246 |
255 |
result = ht_lookup(&globals, varname); |
result = ht_lookup(&globals, varname); |
|
... |
... |
void validateGlobalAssignment(const char *varname) { |
251 |
260 |
} |
} |
252 |
261 |
|
|
253 |
262 |
|
|
254 |
|
void checkParameters(const struct paramlist *func, const struct paramlist *inp) |
|
|
263 |
|
void checkParameters(const struct paramlist *func, const struct paramlist *inp, bool mustretbool) |
255 |
264 |
{ |
{ |
256 |
265 |
const struct typeandname *fi = func->head; |
const struct typeandname *fi = func->head; |
257 |
266 |
const struct typeandname *pi = inp->head; |
const struct typeandname *pi = inp->head; |
|
... |
... |
void checkParameters(const struct paramlist *func, const struct paramlist *inp) |
267 |
276 |
return; |
return; |
268 |
277 |
} |
} |
269 |
278 |
canconvert(pi->ty, fi->ty, 0); |
canconvert(pi->ty, fi->ty, 0); |
|
279 |
|
bool has_flag = (pjass_flags & flag_filter) || (fnannotations & flag_filter); |
|
280 |
|
if(has_flag && mustretbool && typeeq(pi->ty, gCodeReturnsNoBoolean)){ |
|
281 |
|
yyerrorex(semanticerror, "Function passed to Filter or Condition must return a boolean"); |
|
282 |
|
return; |
|
283 |
|
} |
270 |
284 |
pi = pi->next; |
pi = pi->next; |
271 |
285 |
fi = fi->next; |
fi = fi->next; |
272 |
286 |
} |
} |
|
... |
... |
const struct typenode *binop(const struct typenode *a, const struct typenode *b) |
290 |
304 |
const struct typenode *combinetype(const struct typenode *n1, const struct typenode *n2) |
const struct typenode *combinetype(const struct typenode *n1, const struct typenode *n2) |
291 |
305 |
{ |
{ |
292 |
306 |
uint8_t ret = getTypeTag(n1) & getTypeTag(n2); |
uint8_t ret = getTypeTag(n1) & getTypeTag(n2); |
293 |
|
if ((typeeq(n1, gNone)) || (typeeq(n2, gNone))) return mkretty(gNone, ret); |
|
294 |
|
if (typeeq(n1, n2)) return mkretty(n1, ret); |
|
|
307 |
|
if ((typeeq(n1, gNone)) || (typeeq(n2, gNone))) |
|
308 |
|
return mkretty(gNone, ret); |
|
309 |
|
if (typeeq(n1, n2)) |
|
310 |
|
return mkretty(n1, ret); |
295 |
311 |
if (typeeq(n1, gNull)) |
if (typeeq(n1, gNull)) |
296 |
312 |
return mkretty(n2, ret); |
return mkretty(n2, ret); |
297 |
313 |
if (typeeq(n2, gNull)) |
if (typeeq(n2, gNull)) |
298 |
314 |
return mkretty(n1, ret); |
return mkretty(n1, ret); |
|
315 |
|
|
299 |
316 |
n1 = getPrimitiveAncestor(n1); |
n1 = getPrimitiveAncestor(n1); |
300 |
317 |
n2 = getPrimitiveAncestor(n2); |
n2 = getPrimitiveAncestor(n2); |
301 |
|
if (typeeq(n1, n2)) return mkretty(n1, ret); |
|
|
318 |
|
|
|
319 |
|
if (typeeq(n1, n2)) |
|
320 |
|
return mkretty(n1, ret); |
302 |
321 |
if (typeeq(n1, gNull)) |
if (typeeq(n1, gNull)) |
303 |
322 |
return mkretty(n2, ret); |
return mkretty(n2, ret); |
304 |
323 |
if (typeeq(n2, gNull)) |
if (typeeq(n2, gNull)) |
|
... |
... |
void checkeqtest(const struct typenode *a, const struct typenode *b) |
439 |
458 |
} |
} |
440 |
459 |
|
|
441 |
460 |
|
|
|
461 |
|
int updateannotation(int cur, char *txt){ |
|
462 |
|
char sep[] = " \t\n"; |
|
463 |
|
char *ann; |
|
464 |
|
memset(txt, ' ', strlen("//#")); |
|
465 |
|
for(ann = strtok(txt, sep); ann; ann = strtok(NULL, sep)){ |
|
466 |
|
char *name = ann+1; |
|
467 |
|
char sgn = ann[0]; |
|
468 |
|
int flag = 0; |
|
469 |
|
|
|
470 |
|
if(! strcmp(name, "rb")){ |
|
471 |
|
flag = flag_rb; |
|
472 |
|
} else if(! strcmp(name, "filter") ){ |
|
473 |
|
flag = flag_filter; |
|
474 |
|
} |
|
475 |
|
|
|
476 |
|
if(sgn == '+') { |
|
477 |
|
cur |= flag; |
|
478 |
|
} else if(sgn == '-') { |
|
479 |
|
cur &= ~flag; |
|
480 |
|
} |
|
481 |
|
} |
|
482 |
|
return cur; |
|
483 |
|
} |
File misc.h changed (mode: 100644) (index 0e2c211..de71687) |
... |
... |
enum errortype { |
35 |
35 |
warning, |
warning, |
36 |
36 |
}; |
}; |
37 |
37 |
|
|
|
38 |
|
enum flags { |
|
39 |
|
flag_rb = 1 << 0, |
|
40 |
|
flag_strict = 1 << 1, |
|
41 |
|
flag_filter = 1 << 2, |
|
42 |
|
}; |
|
43 |
|
|
38 |
44 |
|
|
39 |
45 |
void yyerrorline (int errorlevel, int line, const char *s); |
void yyerrorline (int errorlevel, int line, const char *s); |
40 |
46 |
void yyerrorex (int errorlevel, const char *s); |
void yyerrorex (int errorlevel, const char *s); |
|
... |
... |
void getsuggestions(const char*, char*, size_t, int, ...); |
46 |
52 |
|
|
47 |
53 |
const struct typenode *binop(const struct typenode *a, const struct typenode *b); |
const struct typenode *binop(const struct typenode *a, const struct typenode *b); |
48 |
54 |
const struct typenode *combinetype(const struct typenode *n1, const struct typenode *n2); |
const struct typenode *combinetype(const struct typenode *n1, const struct typenode *n2); |
49 |
|
void checkParameters(const struct paramlist *func, const struct paramlist *inp); |
|
|
55 |
|
void checkParameters(const struct paramlist *func, const struct paramlist *inp, bool mustretbool); |
50 |
56 |
const struct typeandname *getVariable(const char *varname); |
const struct typeandname *getVariable(const char *varname); |
51 |
|
int canconvert(const struct typenode *ufrom, const struct typenode *uto, const int linemod); |
|
|
57 |
|
|
|
58 |
|
void canconvert(const struct typenode *ufrom, const struct typenode *uto, const int linemod); |
52 |
59 |
void canconvertreturn(const struct typenode *ufrom, const struct typenode *uto, const int linemod); |
void canconvertreturn(const struct typenode *ufrom, const struct typenode *uto, const int linemod); |
53 |
60 |
|
|
54 |
61 |
void validateGlobalAssignment(const char *varname); |
void validateGlobalAssignment(const char *varname); |
|
... |
... |
void checkcomparison(const struct typenode *a, const struct typenode *b); |
58 |
65 |
void checkcomparisonsimple(const struct typenode *a); |
void checkcomparisonsimple(const struct typenode *a); |
59 |
66 |
void checkeqtest(const struct typenode *a, const struct typenode *b); |
void checkeqtest(const struct typenode *a, const struct typenode *b); |
60 |
67 |
|
|
|
68 |
|
int updateannotation(int cur, char *txt); |
|
69 |
|
|
|
70 |
|
extern int pjass_flags; |
|
71 |
|
|
61 |
72 |
extern int fno, lineno, totlines, islinebreak, isconstant, inblock, inconstant, infunction; |
extern int fno, lineno, totlines, islinebreak, isconstant, inblock, inconstant, infunction; |
62 |
73 |
extern int haderrors; |
extern int haderrors; |
63 |
74 |
extern int ignorederrors; |
extern int ignorederrors; |
|
... |
... |
extern int didparse; |
65 |
76 |
extern int inloop; |
extern int inloop; |
66 |
77 |
extern int strict; |
extern int strict; |
67 |
78 |
extern int returnbug; |
extern int returnbug; |
68 |
|
extern int fnhasrbannotation; |
|
69 |
|
extern int rbannotated; |
|
|
79 |
|
extern int fnannotations; |
|
80 |
|
extern int annotations; |
70 |
81 |
extern int afterendglobals; |
extern int afterendglobals; |
71 |
82 |
extern int *showerrorlevel; |
extern int *showerrorlevel; |
72 |
83 |
extern char *yytext; |
extern char *yytext; |
|
... |
... |
extern int yydebug; |
75 |
86 |
int *showerrorlevel; |
int *showerrorlevel; |
76 |
87 |
extern struct hashtable functions, globals, locals, params, types, initialized, *curtab; |
extern struct hashtable functions, globals, locals, params, types, initialized, *curtab; |
77 |
88 |
extern struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gEmpty; |
extern struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gEmpty; |
|
89 |
|
extern struct typenode *gCodeReturnsNoBoolean, *gCodeReturnsBoolean; |
78 |
90 |
extern struct funcdecl *fCurrent; |
extern struct funcdecl *fCurrent; |
|
91 |
|
extern struct funcdecl *fFilter, *fCondition; |
79 |
92 |
extern const struct typenode *retval; |
extern const struct typenode *retval; |
80 |
93 |
|
|
81 |
94 |
#endif |
#endif |