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)
Added unitialized check for globals. d8a909d8ac08cc233f5cd988afac043cbaeb1b4e lep 2018-11-06 19:43:57
Fixed off-by-one error in str_append. b458eb97a71bad87bbbbef610009da40e0dbf855 lep 2018-11-01 12:26:48
Added modulo operator. 70b4c5117a0b84cddd0c35e07a47e3b2aaf847b8 lep 2018-08-09 19:46:14
realloc returns the new pointer... c15eac9a4c2c2531a256125bc70272edbbf1d036 lep 2018-07-24 20:03:41
Track blocks d2763ae8473a1c699aa2e5605922e4b500c83ed4 lep 2018-07-22 13:28:40
Cross compile and strip under FreeBSD 296bd56c1347afb7a20337e02574f9196b48317a lep 2018-07-22 11:55:29
Track opening/closing blocks. 49b23df64b209106cce92e417ee13ecebb0bc009 lep 2018-07-09 09:37:01
Replace strncat with str_append. ad968e040f315ed3cf6580e46587342897839529 lep 2018-03-21 13:53:11
Do not report arrays as uninitialized when the index is missing. 72e93bd234743a438fb0a5c105514bf732c22b89 lep 2017-12-20 14:59:10
Better error messages. ad8342582ac3617280f471d889b1766be272858b lep 2017-11-15 17:52:08
Handle wrong shadowing. 0500a60ef11f39c4f33044e26c29798f6d8445b5 lep 2017-02-19 14:37:21
Added checks for natives which behave bad in a globals block. 3e6ac270dda9ad695723d3bc2aac4d69a2fdf87a lep 2017-02-19 10:57:33
Update readme.md 2c9177dd5482ed8c4c1464a4ade37c301205fe6b lep 2017-02-01 17:42:49
Public git release. 2da78f3665ac4f53f5833c6a48ebbeaabea0cd49 lep 2017-02-01 16:42:21
Better ifdef-handling for aligned malloc. d95ebafa7204e49d84a9fed8cdeb01713dd0bc82 lep 2017-02-01 16:41:07
Makefile changes. 0458bb26764aad1caec71ccf721e84a28c699ee0 lep 2017-02-01 15:48:25
Can now compile on freebsd and linux from one branch. 0772c4bd17dcfc389ca0e887b4bbceda8e46fa8e lep 2017-01-07 21:05:10
More descriptive check for assignment. 474462b44fe20e958e8c6a3b51ba2da9c4a46451 lep 2016-11-24 16:47:15
Actually add all the sources to the release zipball 151ae88aac4c3ac8aae432a4a240239f652fa8f4 lep 2016-11-10 15:30:38
Don't treat ``.'' as a valid real value. 72e5087e22af66de0765c6d4f9ceae154725e2c2 lep 2016-10-24 14:55:02
Commit d8a909d8ac08cc233f5cd988afac043cbaeb1b4e - Added unitialized check for globals.
Check is active for global declerations and is available in function
behind `+checkglobalsinit` flag.
Author: lep
Author date (UTC): 2018-11-06 19:43
Committer name: lep
Committer date (UTC): 2018-11-06 19:43
Parent(s): b458eb97a71bad87bbbbef610009da40e0dbf855
Signer:
Signing key:
Signing status: N
Tree: 23f33c5cf72b4512f7c854b2d7c9c1b516ce8f0d
File Lines added Lines deleted
.gitignore 2 1
grammar.y 25 8
main.c 3 0
misc.c 2 0
misc.h 2 0
tests/should-check/uninit-global-init-in-function.j 10 0
tests/should-fail/uninit-global-in-function.j 3 2
tests/should-fail/uninit-globals-in-globals.j 4 0
tests/should-fail/uninitialized-var-shadow.j 8 0
tests/should-fail/vardecl-missing-equal.j 3 0
File .gitignore changed (mode: 100644) (index c1ca229..28f83f8)
... ... grammar.tab.h
5 5 grammar.tab.c grammar.tab.c
6 6 token.yy.c token.yy.c
7 7 token.yy.h token.yy.h
8 pjass.exe
8 *.exe
9 9 pjass pjass
10 10 *.out *.out
11 11 *-analysis.txt *-analysis.txt
12 12 *.sw* *.sw*
13 *.dll
13 14 tests/Blizzard.j tests/Blizzard.j
14 15 tests/common.j tests/common.j
15 16 tests/map-scripts/ tests/map-scripts/
File grammar.y changed (mode: 100644) (index f92cdee..e99cf72)
... ... expr: intexpr { $$.ty = gInteger; }
239 239 yyerrorex(semanticerror, ebuf); yyerrorex(semanticerror, ebuf);
240 240 } }
241 241 checkwrongshadowing(tan, 0); checkwrongshadowing(tan, 0);
242 if(!tan->isarray && infunction && ht_lookup(curtab, $1.str) && !ht_lookup(&initialized, $1.str) ){
243 char ebuf[1024];
244 snprintf(ebuf, 1024, "Variable %s is uninitialized", $1.str);
245 yyerrorline(semanticerror, lineno - 1, ebuf);
246 }
247 $$.ty = tan->ty;
242 if( !tan->isarray && !ht_lookup(&initialized, $1.str) ){
243 char buf[1024];
244
245 if( ht_lookup(&locals, $1.str)){
246 snprintf(buf, 1024, "Variable %s is uninitialized", $1.str);
247 yyerrorline(semanticerror, lineno - 1, buf);
248 }else if(ht_lookup(&uninitialized_globals, $1.str)){
249 if(infunction ){
250 if( flagenabled(flag_checkglobalsinit) ){
251 snprintf(buf, 1024, "Variable %s might be uninitalized", $1.str);
252 yyerrorline(semanticerror, lineno, buf);
253 }
254 }else{
255 snprintf(buf, 1024, "Variable %s is uninitalized", $1.str);
256 yyerrorline(semanticerror, lineno, buf);
257 }
258 }
259
260
248 261 } }
262 $$.ty = tan->ty;
263 }
249 264 | expr EQUALS expr {yyerrorex(syntaxerror, "Single = in expression, should probably be =="); checkeqtest($1.ty, $3.ty); $$.ty = gBoolean;} | expr EQUALS expr {yyerrorex(syntaxerror, "Single = in expression, should probably be =="); checkeqtest($1.ty, $3.ty); $$.ty = gBoolean;}
250 265 | LPAREN expr {yyerrorex(syntaxerror, "Mssing ')'"); $$.ty = $2.ty;} | LPAREN expr {yyerrorex(syntaxerror, "Mssing ')'"); $$.ty = $2.ty;}
251 266
 
... ... statement: newline { $$.ty = gEmpty; }
427 442 } }
428 443 if (inconstant) if (inconstant)
429 444 validateGlobalAssignment($2.str); validateGlobalAssignment($2.str);
430 if(infunction && ht_lookup(curtab, $2.str) && !ht_lookup(&initialized, $2.str)){
431 put(&initialized, $2.str, (void*)1);
445 if(infunction && !ht_lookup(&initialized, $2.str)){
446 ht_put(&initialized, $2.str, (void*)1);
432 447 } }
448
433 449 } }
434 450 | SET rid rid EQUALS expr newline { | SET rid rid EQUALS expr newline {
435 451 char ebuf[1024]; char ebuf[1024];
 
... ... vardecl: vartypedecl newline {
630 646 if (tan->isconst) { if (tan->isconst) {
631 647 yyerrorline(syntaxerror, lineno - 1, "Constants must be initialized"); yyerrorline(syntaxerror, lineno - 1, "Constants must be initialized");
632 648 } }
649 ht_put(&uninitialized_globals, $1.str, (void*)1);
633 650 $$.ty = gNothing; $$.ty = gNothing;
634 651 } }
635 652 | vartypedecl EQUALS expr newline { | vartypedecl EQUALS expr newline {
File main.c changed (mode: 100644) (index f97aadd..ee39349)
... ... static void init()
26 26
27 27 ht_init(&bad_natives_in_globals, 17); ht_init(&bad_natives_in_globals, 17);
28 28 ht_init(&shadowed_variables, 17); ht_init(&shadowed_variables, 17);
29
30 ht_init(&uninitialized_globals, 511);
29 31
30 32 gHandle = addPrimitiveType("handle"); gHandle = addPrimitiveType("handle");
31 33 gInteger = addPrimitiveType("integer"); gInteger = addPrimitiveType("integer");
 
... ... static void init()
70 72 ht_put(&available_flags, "nosyntaxerror", (void*)flag_syntaxerror); ht_put(&available_flags, "nosyntaxerror", (void*)flag_syntaxerror);
71 73 ht_put(&available_flags, "nosemanticerror", (void*)flag_semanticerror); ht_put(&available_flags, "nosemanticerror", (void*)flag_semanticerror);
72 74 ht_put(&available_flags, "noruntimeerror", (void*)flag_runtimeerror); ht_put(&available_flags, "noruntimeerror", (void*)flag_runtimeerror);
75 ht_put(&available_flags, "checkglobalsinit", (void*)flag_checkglobalsinit);
73 76
74 77 ht_put(&bad_natives_in_globals, "OrderId", (void*)NullInGlobals); ht_put(&bad_natives_in_globals, "OrderId", (void*)NullInGlobals);
75 78 ht_put(&bad_natives_in_globals, "OrderId2String", (void*)NullInGlobals); ht_put(&bad_natives_in_globals, "OrderId2String", (void*)NullInGlobals);
File misc.c changed (mode: 100644) (index 8a197f6..1fb8d1e)
... ... struct hashtable bad_natives_in_globals;
43 43
44 44 struct hashtable shadowed_variables; struct hashtable shadowed_variables;
45 45
46 struct hashtable uninitialized_globals;
47
46 48
47 49 struct hashtable *curtab; struct hashtable *curtab;
48 50
File misc.h changed (mode: 100644) (index 9e4f9dd..05cecb0)
... ... enum {
43 43 flag_syntaxerror = 1 << 3, flag_syntaxerror = 1 << 3,
44 44 flag_semanticerror = 1 << 4, flag_semanticerror = 1 << 4,
45 45 flag_runtimeerror = 1 << 5, flag_runtimeerror = 1 << 5,
46 flag_checkglobalsinit = 1 << 6,
46 47 }; };
47 48
48 49 enum { enum {
 
... ... extern int yydebug;
98 99 int *showerrorlevel; int *showerrorlevel;
99 100 extern struct hashtable functions, globals, locals, params, types, initialized, *curtab; extern struct hashtable functions, globals, locals, params, types, initialized, *curtab;
100 101 extern struct hashtable bad_natives_in_globals; extern struct hashtable bad_natives_in_globals;
102 extern struct hashtable uninitialized_globals;
101 103 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;
102 104 extern struct typenode *gCodeReturnsNoBoolean, *gCodeReturnsBoolean; extern struct typenode *gCodeReturnsNoBoolean, *gCodeReturnsBoolean;
103 105 extern struct funcdecl *fCurrent; extern struct funcdecl *fCurrent;
File tests/should-check/uninit-global-init-in-function.j added (mode: 100644) (index 0000000..2b7470d)
1 globals
2 integer x
3 endglobals
4
5 //# +checkglobalsinit
6 function foo takes nothing returns integer
7 set x = 3
8 return x
9 endfunction
10
File tests/should-fail/uninit-global-in-function.j copied from file tests/should-check/shadowing-1.j (similarity 58%) (mode: 100644) (index 1a8e2b5..201d036)
1 1 globals globals
2 integer i
2 integer x
3 3 endglobals endglobals
4 4
5 //# +checkglobalsinit
5 6 function foo takes nothing returns nothing function foo takes nothing returns nothing
6 local integer i
7 local integer y = x
7 8 endfunction endfunction
File tests/should-fail/uninit-globals-in-globals.j added (mode: 100644) (index 0000000..5f518f3)
1 globals
2 integer a
3 integer b = a + 3
4 endglobals
File tests/should-fail/uninitialized-var-shadow.j added (mode: 100644) (index 0000000..cc908dc)
1 globals
2 integer x = 8
3 endglobals
4
5 function foo takes nothing returns integer
6 local integer x
7 return x
8 endfunction
File tests/should-fail/vardecl-missing-equal.j added (mode: 100644) (index 0000000..69b47bf)
1 globals
2 boolean B true
3 endglobals
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