vrtc / pjass (public) (License: BSD) (since 2023-08-03) (hash sha1)
pjass is a free Jass scripting language parser. This repository is a fork of lep/pjass. The goal is to add Debian packaging. As of the time of this writing, it works for current stable, that is Debian 12 (bookworm).
List of commits:
Subject Hash Author Date (UTC)
Changed sprintf to snprintf. 02d6efe2aed9186b2e6189b36a5fa50d2e0c2221 lep 2015-02-03 21:33:05
Wrapped typenode member accesses in getTypePtr. 372c1f9da68a65de9e14dff3881e1758d5e7114b lep 2015-02-03 21:05:11
Added ifdefs for memalign functionality. f005f5e8067994ebd76265e3289e6ab67283b96f lep 2015-02-03 20:06:20
Missing-return check in elseifs should work now. 4274d6166e2c92a4591c1e46a0d71f1579a57c7d lep 2015-02-03 19:35:39
Missing-return checks also checks elseifs. 889122b0fb788663c728127520d0e7124c2a040c lep 2015-02-03 15:18:12
Fixed some more warnings. a5ae36b5299ac419a91592b60b8fcb1dfd8f4374 lep 2015-02-03 13:24:56
Added early exit to editdistance function. 82e8d024392d357d56c833c6b7f7632ffd6830a8 lep 2015-02-02 16:13:40
Unidentified variables are now marked as initialized. f3ef715b90782bc22fbdd29e1c16d7c917f407a9 lep 2015-02-02 13:56:00
Fixed bug in editdistance. a786775b057fc5795db1b2b106b7b9e3c1df6c4c lep 2015-02-02 13:41:15
Added basic uninitialized variable check for locals. c8222a6f68e44a46624c1f9ee781f590522f45f6 lep 2015-02-02 12:41:25
Added git-versionstring. e13ce6d7d90bccd8e18de6d0b01a18ea4501862b lep 2015-02-01 14:56:01
Removed returnsbool-check for Filter/Condition. e26a973fe1fdc1af999633c8d1f29afcbae76f0b lep 2015-02-01 14:51:47
Fixed some bison warnings. aca6b13e73d95c41787a7a0fdcc33407247be3a8 lep 2015-02-01 14:49:55
Removed multiline comments. e6d3a1bb5099bbf6e3a4ef2501645b15908a1ce8 lep 2015-02-01 14:49:16
Removed unnecessary tokens. 4f37057dfd472c2a400d667a6f7a3762cac01dcd lep 2015-02-01 14:48:14
Comments now work with EOF in addition to newlines at the end. 5363d3ca429da30594f7afb9d351335912b03fbd lep 2015-02-01 14:46:09
pjass 10n 2b2d35bc58dc93bc68014711cda919cecff13b4a lep 2014-10-25 20:38:00
pjass 10m 265bac6343dfeb09e1fc0af5c06571c7dc172455 Deaod 2010-02-15 12:15:00
pjass 10l 0c9161120896904b55b3cdd7b2f7430dd97f82e9 PitzerMike 2009-06-15 21:30:00
pjass 10k 43c1a8a167cdf2982af2c47056beeafcd1840537 Zoxc 2009-04-03 21:23:00
Commit 02d6efe2aed9186b2e6189b36a5fa50d2e0c2221 - Changed sprintf to snprintf.
Author: lep
Author date (UTC): 2015-02-03 21:33
Committer name: lep
Committer date (UTC): 2015-02-03 21:33
Parent(s): 372c1f9da68a65de9e14dff3881e1758d5e7114b
Signer:
Signing key:
Signing status: N
Tree: 49364ab0f4f472e864c6870318039b47307daed8
File Lines added Lines deleted
grammar.y 39 39
misc.c 19 11
misc.h 1 1
File grammar.y changed (mode: 100644) (index de8db7b..ef9c482)
... ... expr: intexpr { $$.ty = gInteger; }
198 198 | FUNCTION rid { struct funcdecl *fd = lookup(&functions, $2.str); | FUNCTION rid { struct funcdecl *fd = lookup(&functions, $2.str);
199 199 if (fd == NULL) { if (fd == NULL) {
200 200 char ebuf[1024]; char ebuf[1024];
201 sprintf(ebuf, "Undefined function %s", $2.str);
202 getsuggestions($2.str, ebuf, 1, &functions);
201 snprintf(ebuf, 1024, "Undefined function %s", $2.str);
202 //getsuggestions($2.str, ebuf, 1, &functions);
203 203 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
204 204 $$.ty = gCode; $$.ty = gCode;
205 205 } else { } else {
206 206 if (fd->p->head != NULL) { if (fd->p->head != NULL) {
207 207 char ebuf[1024]; char ebuf[1024];
208 sprintf(ebuf, "Function %s must not take any arguments when used as code", $2.str);
208 snprintf(ebuf, 1024, "Function %s must not take any arguments when used as code", $2.str);
209 209 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
210 210 } }
211 211 $$.ty = gCode; $$.ty = gCode;
 
... ... expr: intexpr { $$.ty = gInteger; }
237 237 if (!typeeq(tan->ty, gAny)) { if (!typeeq(tan->ty, gAny)) {
238 238 if (!tan->isarray) { if (!tan->isarray) {
239 239 char ebuf[1024]; char ebuf[1024];
240 sprintf(ebuf, "%s not an array", $1.str);
240 snprintf(ebuf, 1024, "%s not an array", $1.str);
241 241 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
242 242 } }
243 243 else { else {
 
... ... expr: intexpr { $$.ty = gInteger; }
250 250 const struct typeandname *tan = getVariable($1.str); const struct typeandname *tan = getVariable($1.str);
251 251 if (tan->lineno == lineno && tan->fn == fno) { if (tan->lineno == lineno && tan->fn == fno) {
252 252 char ebuf[1024]; char ebuf[1024];
253 sprintf(ebuf, "Use of variable %s before its declaration", $1.str);
253 snprintf(ebuf, 1024, "Use of variable %s before its declaration", $1.str);
254 254 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
255 255 } else if (islinebreak && tan->lineno == lineno - 1 && tan->fn == fno) { } else if (islinebreak && tan->lineno == lineno - 1 && tan->fn == fno) {
256 256 char ebuf[1024]; char ebuf[1024];
257 sprintf(ebuf, "Use of variable %s before its declaration", $1.str);
257 snprintf(ebuf, 1024, "Use of variable %s before its declaration", $1.str);
258 258 yyerrorline(3, lineno - 1, ebuf); yyerrorline(3, lineno - 1, ebuf);
259 259 } else if (tan->isarray) { } else if (tan->isarray) {
260 260 char ebuf[1024]; char ebuf[1024];
261 sprintf(ebuf, "Index missing for array variable %s", $1.str);
261 snprintf(ebuf, 1024, "Index missing for array variable %s", $1.str);
262 262 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
263 263 } }
264 264 if(infunction && lookup(curtab, $1.str) && !lookup(&initialized, $1.str) ){ if(infunction && lookup(curtab, $1.str) && !lookup(&initialized, $1.str) ){
265 265 char ebuf[1024]; char ebuf[1024];
266 sprintf(ebuf, "Variable %s is uninitialized", $1.str);
266 snprintf(ebuf, 1024, "Variable %s is uninitialized", $1.str);
267 267 //yyerrorex(3, ebuf); //yyerrorex(3, ebuf);
268 268 yyerrorline(3, lineno - 1, ebuf); yyerrorline(3, lineno - 1, ebuf);
269 269 } }
 
... ... funccall: rid LPAREN exprlistcompl RPAREN {
288 288 struct funcdecl *fd = lookup(&functions, $1.str); struct funcdecl *fd = lookup(&functions, $1.str);
289 289 if (fd == NULL) { if (fd == NULL) {
290 290 char ebuf[1024]; char ebuf[1024];
291 sprintf(ebuf, "Undeclared function %s", $1.str);
292 getsuggestions($1.str, ebuf, 1, &functions);
291 snprintf(ebuf, 1024, "Undeclared function %s", $1.str);
292 //getsuggestions($1.str, ebuf, 1, &functions);
293 293 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
294 294 $$.ty = gAny; $$.ty = gAny;
295 295 } else { } else {
296 296 if (inconstant && !(fd->isconst)) { if (inconstant && !(fd->isconst)) {
297 297 char ebuf[1024]; char ebuf[1024];
298 sprintf(ebuf, "Call to non-constant function %s in constant function", $1.str);
298 snprintf(ebuf, 1024, "Call to non-constant function %s in constant function", $1.str);
299 299 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
300 300 } }
301 301 if (fd == fCurrent && fCurrent) if (fd == fCurrent && fCurrent)
 
... ... funccall: rid LPAREN exprlistcompl RPAREN {
309 309 struct funcdecl *fd = lookup(&functions, $1.str); struct funcdecl *fd = lookup(&functions, $1.str);
310 310 if (fd == NULL) { if (fd == NULL) {
311 311 char ebuf[1024]; char ebuf[1024];
312 sprintf(ebuf, "Undeclared function %s", $1.str);
313 getsuggestions($1.str, ebuf, 1, &functions);
312 snprintf(ebuf, 1024, "Undeclared function %s", $1.str);
313 //getsuggestions($1.str, ebuf, 1, &functions);
314 314 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
315 315 $$.ty = gAny; $$.ty = gAny;
316 316 } else if (inconstant && !(fd->isconst)) { } else if (inconstant && !(fd->isconst)) {
317 317 char ebuf[1024]; char ebuf[1024];
318 sprintf(ebuf, "Call to non-constant function %s in constant function", $1.str);
318 snprintf(ebuf, 1024, "Call to non-constant function %s in constant function", $1.str);
319 319 yyerrorex(3, ebuf); yyerrorex(3, ebuf);
320 320 $$.ty = gAny; $$.ty = gAny;
321 321 } else { } else {
 
... ... nativefuncdecl: NATIVE rid TAKES optparam_list RETURNS opttype
363 363 { {
364 364 if (lookup(&locals, $2.str) || lookup(&params, $2.str) || lookup(&globals, $2.str)) { if (lookup(&locals, $2.str) || lookup(&params, $2.str) || lookup(&globals, $2.str)) {
365 365 char buf[1024]; char buf[1024];
366 sprintf(buf, "%s already defined as variable", $2.str);
366 snprintf(buf, 1024, "%s already defined as variable", $2.str);
367 367 yyerrorex(3, buf); yyerrorex(3, buf);
368 368 } else if (lookup(&types, $2.str)) { } else if (lookup(&types, $2.str)) {
369 369 char buf[1024]; char buf[1024];
370 sprintf(buf, "%s already defined as type", $2.str);
370 snprintf(buf, 1024, "%s already defined as type", $2.str);
371 371 yyerrorex(3, buf); yyerrorex(3, buf);
372 372 } }
373 373 $$.fd = newfuncdecl(); $$.fd = newfuncdecl();
 
... ... returnorreturns: RETURNS
408 408 funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype { funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype {
409 409 if (lookup(&locals, $2.str) || lookup(&params, $2.str) || lookup(&globals, $2.str)) { if (lookup(&locals, $2.str) || lookup(&params, $2.str) || lookup(&globals, $2.str)) {
410 410 char buf[1024]; char buf[1024];
411 sprintf(buf, "%s already defined as variable", $2.str);
411 snprintf(buf, 1024, "%s already defined as variable", $2.str);
412 412 yyerrorex(3, buf); yyerrorex(3, buf);
413 413 } else if (lookup(&types, $2.str)) { } else if (lookup(&types, $2.str)) {
414 414 char buf[1024]; char buf[1024];
415 sprintf(buf, "%s already defined as type", $2.str);
415 snprintf(buf, 1024, "%s already defined as type", $2.str);
416 416 yyerrorex(3, buf); yyerrorex(3, buf);
417 417 } }
418 418 inconstant = 0; inconstant = 0;
 
... ... funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype {
432 432 put(&params, strdup(tan->name), newtypeandname(tan->ty, tan->name)); put(&params, strdup(tan->name), newtypeandname(tan->ty, tan->name));
433 433 if (lookup(&functions, tan->name)) { if (lookup(&functions, tan->name)) {
434 434 char buf[1024]; char buf[1024];
435 sprintf(buf, "%s already defined as function", tan->name);
435 snprintf(buf, 1024, "%s already defined as function", tan->name);
436 436 yyerrorex(3, buf); yyerrorex(3, buf);
437 437 } else if (lookup(&types, tan->name)) { } else if (lookup(&types, tan->name)) {
438 438 char buf[1024]; char buf[1024];
439 sprintf(buf, "%s already defined as type", tan->name);
439 snprintf(buf, 1024, "%s already defined as type", tan->name);
440 440 yyerrorex(3, buf); yyerrorex(3, buf);
441 441 } }
442 442 } }
 
... ... funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype {
448 448 | CONSTANT FUNCTION rid TAKES optparam_list returnorreturns opttype { | CONSTANT FUNCTION rid TAKES optparam_list returnorreturns opttype {
449 449 if (lookup(&locals, $3.str) || lookup(&params, $3.str) || lookup(&globals, $3.str)) { if (lookup(&locals, $3.str) || lookup(&params, $3.str) || lookup(&globals, $3.str)) {
450 450 char buf[1024]; char buf[1024];
451 sprintf(buf, "%s already defined as variable", $3.str);
451 snprintf(buf, 1024, "%s already defined as variable", $3.str);
452 452 yyerrorex(3, buf); yyerrorex(3, buf);
453 453 } else if (lookup(&types, $3.str)) { } else if (lookup(&types, $3.str)) {
454 454 char buf[1024]; char buf[1024];
455 sprintf(buf, "%s already defined as type", $3.str);
455 snprintf(buf, 1024, "%s already defined as type", $3.str);
456 456 yyerrorex(3, buf); yyerrorex(3, buf);
457 457 } }
458 458 inconstant = 1; inconstant = 1;
 
... ... funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype {
470 470 put(&params, strdup(tan->name), newtypeandname(tan->ty, tan->name)); put(&params, strdup(tan->name), newtypeandname(tan->ty, tan->name));
471 471 if (lookup(&functions, tan->name)) { if (lookup(&functions, tan->name)) {
472 472 char buf[1024]; char buf[1024];
473 sprintf(buf, "%s already defined as function", tan->name);
473 snprintf(buf, 1024, "%s already defined as function", tan->name);
474 474 yyerrorex(3, buf); yyerrorex(3, buf);
475 475 } else if (lookup(&types, tan->name)) { } else if (lookup(&types, tan->name)) {
476 476 char buf[1024]; char buf[1024];
477 sprintf(buf, "%s already defined as type", tan->name);
477 snprintf(buf, 1024, "%s already defined as type", tan->name);
478 478 yyerrorex(3, buf); yyerrorex(3, buf);
479 479 } }
480 480 } }
 
... ... statement: NEWLINE { $$.ty = gNone; }
503 503 } }
504 504 | SET rid EQUALS expr NEWLINE { if (getVariable($2.str)->isarray) { | SET rid EQUALS expr NEWLINE { if (getVariable($2.str)->isarray) {
505 505 char ebuf[1024]; char ebuf[1024];
506 sprintf(ebuf, "Index missing for array variable %s", $2.str);
506 snprintf(ebuf, 1024, "Index missing for array variable %s", $2.str);
507 507 yyerrorline(3, lineno - 1, ebuf); yyerrorline(3, lineno - 1, ebuf);
508 508 } }
509 509 canconvert($4.ty, getVariable($2.str)->ty, -1); canconvert($4.ty, getVariable($2.str)->ty, -1);
510 510 $$.ty = gNone; $$.ty = gNone;
511 511 if (getVariable($2.str)->isconst) { if (getVariable($2.str)->isconst) {
512 512 char ebuf[1024]; char ebuf[1024];
513 sprintf(ebuf, "Cannot assign to constant %s", $2.str);
513 snprintf(ebuf, 1024, "Cannot assign to constant %s", $2.str);
514 514 yyerrorline(3, lineno - 1, ebuf); yyerrorline(3, lineno - 1, ebuf);
515 515 } }
516 516 if (inconstant) if (inconstant)
 
... ... statement: NEWLINE { $$.ty = gNone; }
526 526 $$.ty = gNone; $$.ty = gNone;
527 527 if (!tan->isarray) { if (!tan->isarray) {
528 528 char ebuf[1024]; char ebuf[1024];
529 sprintf(ebuf, "%s is not an array", $2.str);
529 snprintf(ebuf, 1024, "%s is not an array", $2.str);
530 530 yyerrorline(3, lineno - 1, ebuf); yyerrorline(3, lineno - 1, ebuf);
531 531 } }
532 532 canconvert($7.ty, tan->ty, -1); canconvert($7.ty, tan->ty, -1);
 
... ... rid: ID
614 614 vartypedecl: type rid { vartypedecl: type rid {
615 615 if (lookup(&functions, $2.str)) { if (lookup(&functions, $2.str)) {
616 616 char buf[1024]; char buf[1024];
617 sprintf(buf, "Symbol %s already defined as function", $2.str);
617 snprintf(buf, 1024, "Symbol %s already defined as function", $2.str);
618 618 yyerrorex(3, buf); yyerrorex(3, buf);
619 619 } else if (lookup(&types, $2.str)) { } else if (lookup(&types, $2.str)) {
620 620 char buf[1024]; char buf[1024];
621 sprintf(buf, "Symbol %s already defined as type", $2.str);
621 snprintf(buf, 1024, "Symbol %s already defined as type", $2.str);
622 622 yyerrorex(3, buf); yyerrorex(3, buf);
623 623 } }
624 624 struct typeandname *tan = newtypeandname($1.ty, $2.str); struct typeandname *tan = newtypeandname($1.ty, $2.str);
 
... ... vartypedecl: type rid {
643 643 } }
644 644 if (lookup(&functions, $3.str)) { if (lookup(&functions, $3.str)) {
645 645 char buf[1024]; char buf[1024];
646 sprintf(buf, "Symbol %s already defined as function", $3.str);
646 snprintf(buf, 1024, "Symbol %s already defined as function", $3.str);
647 647 yyerrorex(3, buf); yyerrorex(3, buf);
648 648 } else if (lookup(&types, $3.str)) { } else if (lookup(&types, $3.str)) {
649 649 char buf[1024]; char buf[1024];
650 sprintf(buf, "Symbol %s already defined as type", $3.str);
650 snprintf(buf, 1024, "Symbol %s already defined as type", $3.str);
651 651 yyerrorex(3, buf); yyerrorex(3, buf);
652 652 } }
653 653 struct typeandname *tan = newtypeandname($2.ty, $3.str); struct typeandname *tan = newtypeandname($2.ty, $3.str);
 
... ... vartypedecl: type rid {
670 670 | type ARRAY rid { | type ARRAY rid {
671 671 if (lookup(&functions, $3.str)) { if (lookup(&functions, $3.str)) {
672 672 char buf[1024]; char buf[1024];
673 sprintf(buf, "Symbol %s already defined as function", $3.str);
673 snprintf(buf, 1024, "Symbol %s already defined as function", $3.str);
674 674 yyerrorex(3, buf); yyerrorex(3, buf);
675 675 } else if (lookup(&types, $3.str)) { } else if (lookup(&types, $3.str)) {
676 676 char buf[1024]; char buf[1024];
677 sprintf(buf, "Symbol %s already defined as type", $3.str);
677 snprintf(buf, 1024, "Symbol %s already defined as type", $3.str);
678 678 yyerrorex(3, buf); yyerrorex(3, buf);
679 679 } }
680 680 if (getPrimitiveAncestor($1.ty) == gCode) if (getPrimitiveAncestor($1.ty) == gCode)
 
... ... vartypedecl: type rid {
687 687 char buf[1024]; char buf[1024];
688 688 existing = lookup(&params, $3.str); existing = lookup(&params, $3.str);
689 689 if (afterendglobals && existing) { if (afterendglobals && existing) {
690 sprintf(buf, "Symbol %s already defined as function parameter", $3.str);
690 snprintf(buf, 1024, "Symbol %s already defined as function parameter", $3.str);
691 691 yyerrorex(3, buf); yyerrorex(3, buf);
692 692 } }
693 693 if (!existing) { if (!existing) {
694 694 existing = lookup(&globals, $3.str); existing = lookup(&globals, $3.str);
695 695 if (afterendglobals && existing) { if (afterendglobals && existing) {
696 sprintf(buf, "Symbol %s already defined as global variable", $3.str);
696 snprintf(buf, 1024, "Symbol %s already defined as global variable", $3.str);
697 697 yyerrorex(3, buf); yyerrorex(3, buf);
698 698 } }
699 699 } }
 
... ... vardecl: vartypedecl NEWLINE {
806 806 typedef: TYPE rid EXTENDS type { typedef: TYPE rid EXTENDS type {
807 807 if (lookup(&types, $2.str)) { if (lookup(&types, $2.str)) {
808 808 char buf[1024]; char buf[1024];
809 sprintf(buf, "Multiply defined type %s", $2.str);
809 snprintf(buf, 1024, "Multiply defined type %s", $2.str);
810 810 yyerrorex(3, buf); yyerrorex(3, buf);
811 811 } else if (lookup(&functions, $2.str)) { } else if (lookup(&functions, $2.str)) {
812 812 char buf[1024]; char buf[1024];
813 sprintf(buf, "%s already defined as function", $2.str);
813 snprintf(buf, 1024, "%s already defined as function", $2.str);
814 814 yyerrorex(3, buf); yyerrorex(3, buf);
815 815 } }
816 816 else else
 
... ... type: primtype { $$.ty = $1.ty; }
825 825 | rid { | rid {
826 826 if (lookup(&types, $1.str) == NULL) { if (lookup(&types, $1.str) == NULL) {
827 827 char buf[1024]; char buf[1024];
828 sprintf(buf, "Undefined type %s", $1.str);
829 getsuggestions($1.str, buf, 1, &types);
828 snprintf(buf, 1024, "Undefined type %s", $1.str);
829 //getsuggestions($1.str, buf, 1, &types);
830 830 yyerrorex(3, buf); yyerrorex(3, buf);
831 831 $$.ty = gAny; $$.ty = gAny;
832 832 } }
File misc.c changed (mode: 100644) (index 54f5583..2c63c5b)
... ... int editdistance(const char *s, const char *t, int cutoff){
156 156 free(v[i]); free(v[i]);
157 157 return d; return d;
158 158 } }
159
159 #if 0
160 160 void getsuggestions(const char *name, char *buff, int nTables, ...){ void getsuggestions(const char *name, char *buff, int nTables, ...){
161 return;
161 162 int i; int i;
162 163 va_list ap; va_list ap;
163 164
 
... ... void getsuggestions(const char *name, char *buff, int nTables, ...){
170 171 suggestions[i].distance = INT_MAX; suggestions[i].distance = INT_MAX;
171 172 suggestions[i].name = NULL; suggestions[i].name = NULL;
172 173 } }
173
174 /*
174 175 va_start(ap, nTables); va_start(ap, nTables);
175 176 for(i = 0; i != nTables; i++){ for(i = 0; i != nTables; i++){
176 177 struct hashtable *ht = va_arg(ap, struct hashtable*); struct hashtable *ht = va_arg(ap, struct hashtable*);
178
177 179 int x; int x;
178 180 for(x = 0; x != BUCKETS; x++){ for(x = 0; x != BUCKETS; x++){
179 181 struct hashnode *hn; struct hashnode *hn;
180 182 hn = ht->h[x]; hn = ht->h[x];
181 183 while (hn) { while (hn) {
182 int dist = editdistance(hn->name, name, cutoff);
184 int dist = 0;//editdistance(hn->name, name, cutoff);
183 185 if(dist <= cutoff){ if(dist <= cutoff){
186 //printf("Possible suggestion for %s: %s\n", name, hn->name);
187
184 188 count++; count++;
185 189 int j; int j;
186 190 for(j = 0; j != 3; j++){ for(j = 0; j != 3; j++){
 
... ... void getsuggestions(const char *name, char *buff, int nTables, ...){
197 201 break; break;
198 202 } }
199 203 } }
204
200 205 } }
201 206 hn = hn->next; hn = hn->next;
202 207 } }
203 208 } }
209
204 210 } }
205 211 va_end(ap); va_end(ap);
212 */
206 213
207 214 if(count==0) if(count==0)
208 215 return; return;
209 216 else if(count == 1){ else if(count == 1){
210 217 char hbuff[1024]; char hbuff[1024];
211 sprintf(hbuff, ". Maybe you meant %s", suggestions[0].name);
218 snprintf(hbuff, 1024, ". Maybe you meant %s", suggestions[0].name);
212 219 strcat(buff, hbuff); strcat(buff, hbuff);
213 220 }else{ }else{
214 221 strcat(buff, ". Maybe you meant "); strcat(buff, ". Maybe you meant ");
 
... ... void getsuggestions(const char *name, char *buff, int nTables, ...){
219 226 } }
220 227 } }
221 228 } }
229 #endif
222 230
223 231 const struct typeandname *getVariable(const char *varname) const struct typeandname *getVariable(const char *varname)
224 232 { {
 
... ... const struct typeandname *getVariable(const char *varname)
230 238 if (result) return result; if (result) return result;
231 239 result = lookup(&globals, varname); result = lookup(&globals, varname);
232 240 if (result) return result; if (result) return result;
233 sprintf(ebuf, "Undeclared variable %s", varname);
234 getsuggestions(varname, ebuf, 3, &locals, &params, &globals);
241 snprintf(ebuf, 1024, "Undeclared variable %s", varname);
242 //getsuggestions(varname, ebuf, 3, &locals, &params, &globals);
235 243 yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf);
236 244 // Store it as unidentified variable // Store it as unidentified variable
237 245 put(curtab, varname, newtypeandname(gAny, varname)); put(curtab, varname, newtypeandname(gAny, varname));
 
... ... void validateGlobalAssignment(const char *varname) {
246 254 struct typeandname *result; struct typeandname *result;
247 255 result = lookup(&globals, varname); result = lookup(&globals, varname);
248 256 if (result) { if (result) {
249 sprintf(ebuf, "Assignment to global variable %s in constant function", varname);
257 snprintf(ebuf, 1024, "Assignment to global variable %s in constant function", varname);
250 258 yyerrorline(2, lineno - 1, ebuf); yyerrorline(2, lineno - 1, ebuf);
251 259 } }
252 260 } }
 
... ... void put(struct hashtable *h, const char *name, void *val)
377 385
378 386 if (lookup(h, name) != NULL) { if (lookup(h, name) != NULL) {
379 387 char ebuf[1024]; char ebuf[1024];
380 sprintf(ebuf, "Symbol %s multiply defined", name);
388 snprintf(ebuf, 1024, "Symbol %s multiply defined", name);
381 389 yyerrorline(3, islinebreak ? lineno - 1 : lineno, ebuf); yyerrorline(3, islinebreak ? lineno - 1 : lineno, ebuf);
382 390 return; return;
383 391 } }
 
... ... int canconvert(const struct typenode *ufrom, const struct typenode *uto, const i
454 462 return 1; return 1;
455 463 } }
456 464
457 sprintf(ebuf, "Cannot convert %s to %s", ufrom->typename, uto->typename);
465 snprintf(ebuf, 1024, "Cannot convert %s to %s", ufrom->typename, uto->typename);
458 466 yyerrorline(3, lineno + linemod, ebuf); yyerrorline(3, lineno + linemod, ebuf);
459 467 return 0; return 0;
460 468 } }
 
... ... int canconvertreturn(const struct typenode *ufrom, const struct typenode *uto, c
481 489 to = getPrimitiveAncestor(to); to = getPrimitiveAncestor(to);
482 490 if ((typeeq(to, gReal)) && (typeeq(from, gInteger))) { if ((typeeq(to, gReal)) && (typeeq(from, gInteger))) {
483 491 // can't return integer when it expects a real (added 9.5.2005) // can't return integer when it expects a real (added 9.5.2005)
484 sprintf(ebuf, "Cannot convert returned value from %s to %s", getTypePtr(from)->typename, getTypePtr(to)->typename);
492 snprintf(ebuf, 1024, "Cannot convert returned value from %s to %s", getTypePtr(from)->typename, getTypePtr(to)->typename);
485 493 yyerrorline(1, lineno + linemod, ebuf); yyerrorline(1, lineno + linemod, ebuf);
486 494 return 0; return 0;
487 495 } }
 
... ... int canconvertreturn(const struct typenode *ufrom, const struct typenode *uto, c
494 502 } else if (typeeq(from, to)) } else if (typeeq(from, to))
495 503 return 1; return 1;
496 504
497 sprintf(ebuf, "Cannot convert returned value from %s to %s", getTypePtr(ufrom)->typename, getTypePtr(uto)->typename);
505 snprintf(ebuf, 1024, "Cannot convert returned value from %s to %s", getTypePtr(ufrom)->typename, getTypePtr(uto)->typename);
498 506 yyerrorline(1, lineno + linemod, ebuf); yyerrorline(1, lineno + linemod, ebuf);
499 507 return 0; return 0;
500 508 } }
File misc.h changed (mode: 100644) (index 71dc23c..306abf4)
... ... struct hashtable {
59 59 struct hashnode *h[BUCKETS]; struct hashnode *h[BUCKETS];
60 60 }; };
61 61
62 void getsuggestions(const char*, char*, int, ...);
62 //void getsuggestions(const char*, char*, int, ...);
63 63 void *lookup(struct hashtable *h, const char *name); void *lookup(struct hashtable *h, const char *name);
64 64 void put(struct hashtable *h, const char *name, void *val); void put(struct hashtable *h, const char *name, void *val);
65 65 void clear(struct hashtable *h); void clear(struct hashtable *h);
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/pjass

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/pjass

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/pjass

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main