• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

PJass updates

Status
Not open for further replies.

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
-->Latest version<--
-->
Readme / Sourcecode<--

Hey,
just wanted to release my pjass with some litte updates.
  1. pjass now handles rawcodes (more?) correct. I think most of the time it makes no difference as jasshelper doesn't accept those rawcodes.
  2. When pjass encounters some name it hasn't seen it also throws some suggestions in the error message.
  3. Increased max recursion limit to 100000. This should help with realy big scripts.

Example:
test.j
JASS:
type bla extends integner

globals
    integer a = 'a\\bd'
    integer b = '\\'
    integer c = 'avc'
endglobals

function foo takes nothing returns nothing
endfunction

function go takes nothing returns nothing
endfunction

function bar takes nothing returns nothing
endfunction

function xxx takes nothing returns nothing
    local real abc
    set acb = 1
    call fo()
endfunction

Code:
$ pjass test.j
test.j:1: Undefined type integner. Maybe you meant integer
test.j:4: Escaped chars are only allowed if they are the only char in the rawcode.
test.j:4: Escaped chars are only allowed if they are the only char in the rawcode.
test.j:6: Rawcodes must be 1 or 4 characters.
test.j:20: Undeclared variable acb. Maybe you meant abc
test.j:21: Undeclared function fo. Maybe you meant go, foo
test.j failed with 6 errors
Parse failed: 6 errors total

The code might be a bit ugly somtimes but i just wanted it working :)

-->Latest version<--
-->
Readme / Sourcecode<--
 

Attachments

  • pjass10n_src.zip
    23.6 KB · Views: 487
  • pjass10n.zip
    55.6 KB · Views: 603
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
try putting local integer i = ' a b' if this compiles.

edit: both spaces are actual tabs, and they compile no problem in normal world editor(not \t but physical tabs. You can insert them by putting tab somwhere where it will eat it(Notepad++ will do) and copy-pasting them)
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
try putting local integer i = ' a b' if this compiles.

edit: both spaces are actual tabs, and they compile no problem in normal world editor(not \t but physical tabs. You can insert them by putting tab somwhere where it will eat it(Notepad++ will do) and copy-pasting them)

I'm not quite sure what you're trying to tell...
Yes, tabs are just as valid as any other byte. In fact the only values not allowed in rawcodes are \0, ' and \.
Also you can test it just from the cmd:
Code:
$ pjass
globals
integer asdf = '        a       b'
endglobals
^D
Parse successful:        4 lines: <stdin>
Parse successful:        4 lines: <total>
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Nice. Does this pjass include that update that extends the cap for pjass? (someone complained a while back about pjass stopping halfway through their 100k lines of code or something, and you attached an updated version). Either way, would you mind this being bundled into the latest JNGP (with credit, of course)?

It didn't until now, changed YYMAXDEPTH to 100000.
And i don't see a reason why you shouldn't or coulnd't use this in the new JNGP ;)
As long as you test it good.

Attached new source and exe to first post.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041

bXK7r3H9zRj7wNY0brlsXTpLQjbNDrWe2mV6p_Pa1Sw



So yea, either compile it statically against runtime, or spread the dll around.

And since I cant test it, because I am too lazy to install it :D so can you say if this compiles successfully?

JASS:
function myF takes nothing returns integer
    return 4
endfunction

function myOtherF takes nothing returns nothing
    call TriggerAddCondition(null, Filter(function myF))
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543

bXK7r3H9zRj7wNY0brlsXTpLQjbNDrWe2mV6p_Pa1Sw



So yea, either compile it statically against runtime, or spread the dll around.

And since I cant test it, because I am too lazy to install it :D so can you say if this compiles successfully?

JASS:
function myF takes nothing returns integer
    return 4
endfunction

function myOtherF takes nothing returns nothing
    call TriggerAddCondition(null, Filter(function myF))
endfunction

Man, developing on windows is srsly pain. Compiled it with mingw and it doesn't show cygwin1.dll in ldd output any more, so that's good i guess. Someone other has to test it though.
Updated .exe in first post.

Also, the code above: is there a pjass version with codereturnsboolean check disabled? I mean i could disable it but i'm not sure. Maybe i'll add a command line flag.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
I dont know, Ive never seen pjass source I think :D but I know this is indeed valid, because I even tried with native editor just to make sure that return type is not part of function's signature

Well adding functions which don't return booleans used to cause desyncs.
So the worldedit always acceptet this but pjass knew better.
It *seems* that this has stopped with some patch but im still hestiant to add such a behavior as default.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Hey, i've made some more updates. As i've put pjass into git, the current version is pjass-git-0b81ede.
  • I removed the returnsboolean check for Filter/Condition
  • In courtesy to Gismo359 i've changed it so that pjass now accepts comments delimited by EOF in addition to a newline.
  • Removed the handling of multiline-comments. Don't even know why they were in pjass to begin with.
 

Attachments

  • pjass.zip
    54 KB · Views: 349

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Hey, another funny feature in form of pjass version git-31a4d73.
JASS:
function x takes nothing returns integer
    local integer a
    return a
endfunction
Code:
$ pjass test.j
test.j:5: Variable a is uninitialized
test.j failed with 1 error
Parse failed: 1 error total
Pjass now does a very simple check for uninitialized variables.
Note that this check is the most basic possible and currently only checks locals.
Something like the following compiles without errors:
JASS:
function y takes nothing returns integer
    local integer b
    if false then
        set b = 1
    endif
    return b
endfunction

I'd like people to test this a bit so that i can attach these newer versions to the OP.
Another thing is that the uninitialized var check might have too many false positives (which i doubt) so that a warning would be better instead of an error.

e:
This is what i mean by false positive:
JASS:
function z takes nothing returns integer
    local integer c
    if false then
        set c = c
    endif
    return 3
endfunction
Code:
$ pjass test.j
test.j:5: Variable c is uninitialized
test.j failed with 1 error
Parse failed: 1 error total
 

Attachments

  • pjass.zip
    54.1 KB · Views: 345
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Another funky update in the form of pjass git-0fab355.
Up until now pjass would accept the following code
JASS:
function foo takes nothing returns integer
    if false then
        return 0
    elseif true then
    else
        return 2
    endif
endfunction
But now the following error will appear
Code:
$ pjass test.j
test.j:7: Missing return
test.j failed with 1 error
Parse failed: 1 error total

I also urge people to test this version because i also fixed some memory violations.

e: I also added two early exits to the name-suggestiong function which should speed it up some (dunno if it was a problem in the first place :| ).
 

Attachments

  • pjass.zip
    94 KB · Views: 280

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Since hashtables are used as pjass' only datastructure i took a jab at rewriting them. Just the normal continous block of memory and resizing when 2/3 filled.
Then i also changed the hashfunction to murmur3_32. Not that pjass was slow to begin with but now pjass parses scripts in upto half the time.
 

Attachments

  • pjass.zip
    94.2 KB · Views: 273

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
The missing return feature is cool but it seems to break TimerUtils(previous versions work fine) and probable some other libraries.

Bug reports are always appriciated. But could you post the snippet you use?
I just c'n'p'd this and it does work. So what kind of configuration do you use?
Could you either reduce the script to just the error or post your war3map.j? pm would be ok too.
 
Level 20
Joined
Jul 14, 2011
Messages
877
I tried it using both Cohadar's and Vexorian's jasshelper, both via JNGP and outside. I also tried using a normal war3map.j(generated from jngp) and one that contains only the main function and timerutils(which should work).
It says the error is here:
JASS:
    function GetTimerData takes timer t returns integer
//#         static if TimerUtils__USE_HASH_TABLE  then
                // new blue
                return LoadInteger(TimerUtils__ht, 0, GetHandleId(t))
                
//#         elseif (TimerUtils__USE_FLEXIBLE_OFFSET) then
//#             // orange
//#             static if  true  then
//#                 if(GetHandleId(t)-TimerUtils__VOFFSET<0) then
//#                     call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
//#                 endif
//#             endif
//#             return TimerUtils__data[GetHandleId(t)-TimerUtils__VOFFSET]
//#         else
//#             // new red
//#             static if  true  then
//#                 if(GetHandleId(t)-TimerUtils__OFFSET<0) then
//#                     call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
//#                 endif
//#             endif
//#             return TimerUtils__data[GetHandleId(t)-TimerUtils__OFFSET]
//#         endif        <- Missing return
    endfunction
E: Ah, here is the problem - it thinks that the empty line(and comments) after the return is invalid.(dont really know how to say it in english)
JASS:
function foo takes nothing returns integer
    return 0 // <-Compiles correctly
endfunction

function foo takes nothing returns integer
    return 0
    // <-This does not
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Thanks for the report. I found some strange behaviour in pjass versions even prior to mine.

For example the following code didn't work in pjass:
JASS:
function x takes nothing returns nothing
endfunction

function foo takes nothing returns integer
    return 1337
    call x()
endfunction

It *should* work now but the code which handles types and associated stuff is kinda hairy.
I should probably rewrite it eventually but in the mean time please test it :)
 

Attachments

  • pjass.zip
    94.2 KB · Views: 270
Level 20
Joined
Jul 14, 2011
Messages
877
Here is a minor bug:
JASS:
function foo takes nothing returns integer
	return i
	return ii
endfunction
It will suggest 'i' on the second return even though such variable doesnt exist.

Also, "syntax error" is still lower case (Im kinda ocd :p).
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Here is a minor bug:
JASS:
function foo takes nothing returns integer
	return i
	return ii
endfunction
It will suggest 'i' on the second return even though such variable doesnt exist.
Fixed.

Also, "syntax error" is still lower case (Im kinda ocd :p).
But lowercase "syntax error" wont be fixed probably. It is possible but it wont happen on my side though. The only way this would happen is if we internationalize pjass at whole.
 

Attachments

  • pjass-git-9465e96.zip
    94.2 KB · Views: 135

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Hi,
nice project. I wonder if yo

I had to move to http://www.wc3c.net/showthread.php?t=105235 from pjass since pjass had a "memory exhausted" error on too much input code.
That bug might be related to Flex/Bison and its buffer size.
Maybe you could fix that too.

Did you start from http://www.wc3c.net/showthread.php?t=75239 or is there any later source base?

Already increased the parserdepth as others already requested it.
I based it off of this but i've put all versions that i could find the source of into my git :)

_____
I've also come full circle since my first modification and rewrote the rawcode handling again for the next release :DD
 
Level 27
Joined
Feb 2, 2006
Messages
1,577
For the folowing code it says "Cannot convert returned value from integer to real":
JASS:
function s__ARealNumericVector_min takes integer this returns real
    local integer i
    local real result
				if ( s__ARealVector_empty(this) ) then
					return 0 // syntax error
				endif
				set result=s__ARealVector__getindex(this,0)
				set i=1
				loop
					exitwhen ( i == s__ARealVector_size(this) )
					if ( s__ARealVector__getindex(this,i) < result ) then
						set result=s__ARealVector__getindex(this,i)
					endif
					set i=i + 1
				endloop
				return result
   endfunction
Works with the JASS parser.

Something like:
JASS:
 local real result= 0
does not fail either.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
For the folowing code it says "Cannot convert returned value from integer to real":
JASS:
function s__ARealNumericVector_min takes integer this returns real
    local integer i
    local real result
				if ( s__ARealVector_empty(this) ) then
					return 0 // syntax error
				endif
				set result=s__ARealVector__getindex(this,0)
				set i=1
				loop
					exitwhen ( i == s__ARealVector_size(this) )
					if ( s__ARealVector__getindex(this,i) < result ) then
						set result=s__ARealVector__getindex(this,i)
					endif
					set i=i + 1
				endloop
				return result
   endfunction
Works with the JASS parser.
tbh. i'm not really fluent in the typing rules in the patches after the returnbug removal but im pretty sure while the above code runs and probably even returns what you'd expect it does not in general.
Take a look at the following snippet and try to guess what it prints:
JASS:
library foo initializer init

function test takes nothing returns real
    return 1123477881
endfunction

function init takes nothing returns nothing
    call TriggerSleepAction(0)
    call BJDebugMsg(R2S(test()))
endfunction

endlibrary
Result:
123.456
This is what allows this


Something like:
JASS:
 local real result= 0
does not fail either.

This does seems to work properly. Rewriting the typechecking is on my mind but i'd need the exact rules for it. Also i'd probably remove the returnbug exception but since that's quite a change i'd like to hear some comments.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Some updates. "now with source again"-edition (tm)
I've changed operating systems so i have no idea if pjass works on your machine now.
Changelog:
  1. Rewrote rawcode handling for somewhat better error messages
  2. Rewrote string handling to better handle newlines
  3. Changed canconvertreturn behaviour. See this.

The last point could be somewhat massive as i changed one of the core checks of pjass.
Please test this rigorously.
 

Attachments

  • pjass-git-79cb006.zip
    63 KB · Views: 109
  • pjass-git-79cb006-src.zip
    31.9 KB · Views: 91
Level 23
Joined
Apr 16, 2012
Messages
4,041
I wonder, is this cause of PJass, or is JassHelper fucked up?

JASS:
function a takes nothing returns integer
    return 5
endfunction

function c takes string s returns nothing
    call BJDebugMsg(s)
endfunction

function b takes nothing returns nothing
    call c("call a()")
endfunction

causes crash(out of memory)
 
Level 20
Joined
Jul 14, 2011
Messages
877
No, thats from jasshelper. If "Disable script optimization" is ticked it wont crash (because it doesnt inline).

This is basically the minimum for the error to occur:
JASS:
function a takes nothing returns nothing
		call BJDebugMsg("Test") // a one-liner
endfunction

function b takes nothing returns nothing
	local string s = "a("
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
As a workaround for the only useful returnbug left i added a thing.
This is a testversion
See also

JASS:
// this does not throw an error
//! +rb
function bar takes handle h returns integer
	return h
	return 0
endfunction

// this throws an error
function foo takes handle h returns integer
	return h
	return 0
endfunction
 

Attachments

  • pjass-git-f2bd583-src.zip
    16.4 KB · Views: 99
  • pjass-git-f2bd583.zip
    38.8 KB · Views: 76
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Fixed a rare crash.
The following code used to crash pjass:
JASS:
//# +rb
function bar takes handle h returns integer
    return 0
    type foo extends integer
endfunction

I also changed //! +rb to //# +rb because jasshelper seems to eat all //! -comments.

Otherwise nothing big changed. Should be a bit smaller, a bit faster.
 

Attachments

  • pjass-git-371820c.zip
    36.3 KB · Views: 84
  • pjass-git-371820c-src.zip
    16.6 KB · Views: 77

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Fixed another rare crash after some fuzzing.
JASS:
function a takes nothing returns nothing
    if true then
    elseif false then
        local integer a
     endif
endfunction

This code used to crash pjass.
 

Attachments

  • pjass-git-d6e8be9.zip
    36.3 KB · Views: 111
  • pjass-git-d6e8be9-src.zip
    16.6 KB · Views: 70
Level 3
Joined
Jan 31, 2012
Messages
42
Little investigation into multi-line strings using different line termination sequences:
JASS:
globals
//\r\n:

string s0 = "
"//OK.

string s1 = "\
"//Error: Invalid escape character sequence.

integer i0 = '
'//Error: Rawcodes must consist of 1 or 4 characters.
//Actually, it's OK. There are really two characters: CR and LF.

integer i1 = '\
'//Error: Invalid escape character sequence & OK: Rawcodes must consist of 1 or 4 characters.

//\n:

string s2 = "
"//OK.

string s3 = "\
"//OK.

integer i2 = '
'//OK.

integer i3 = '\
'//Error: Rawcodes must consist of 1 or 4 characters.
//But WTF is here? There is only LF, but pjass counts it as two characters.

integer i4 = '\
ab'//Passes, though it's invalid.
endglobals
Linux i686, pjass git-d6e8be9 (gcc 5.2.1, flex 2.5.39, bison 3.0.2).
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Thank you for investigating.

JASS:
string s3 = "\
"//OK.

This was an error and has been fixed.

JASS:
integer i3 = '\
'//Error: Rawcodes must consist of 1 or 4 characters.
//But WTF is here? There is only LF, but pjass counts it as two characters.
Working as intended? The backslash is only allowed when escaped. And then only when used as '\\'.
\\r or \\n (\r, \n literal) is not valid.


JASS:
integer i4 = '\
ab'//Passes, though it's invalid.
endglobals

This was an error and has been fixed.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Since there were no further comments i release a new version with the above bugs fixed.
 

Attachments

  • pjass-git-6149443-src.zip
    16.6 KB · Views: 76
  • pjass-git-6149443.zip
    36.3 KB · Views: 69

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Another small bugfix and something.
As warcraft 3 reads mapscripts as utf 8 encoded it ignores the byte sequence \xef\xbb\xbf , also known as utf8 bom.
pjass would throw an error on this though. This is fixed now.
This also means that the following script actually works.
JASS:
globals
    integerx=13
endglobals
Notice the zero width space between integer and x as boms in the middle of a file should be treated as zero width spaces.

With this release i also release (a part of) my test corpus.
 

Attachments

  • pjass-git-7d95b87.zip
    36.2 KB · Views: 285
  • pjass-git-7d95b87-src.zip
    38.4 KB · Views: 215
Level 19
Joined
Dec 12, 2010
Messages
2,070
/r for a few improvements:

  • Throw at least a warning if variable being declared with the same name as a global one. In case if they are same type, it will be passed just fine by engine, but map creator probably want to evade such bad naming.

JASS:
function fnf takes integer i returns nothing
	local trigger i=CreateTrigger()
	...
endfunction
  • Probably this will need a warning too? Although its completely valid, it's rather confusing. There are already warning if symbol defined multiply times, and it's totally legal, so why not.
  • Add "fatal error" if non-supported symbols. I randomly dropped few russian symbols in comment and map refused to load.
 
Level 19
Joined
Dec 12, 2010
Messages
2,070
GUI users use shadowing to use local variables within GUI (variables are looked up in local namespace before global namespace). For backwards compatibility reasons, I wouldn't throw a warning. It would suck if users suddenly got a warning message after updating pJASS.

didn't consider that. maybe add a flag for console users, which will enable this check?
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
Indeed, a flag is the way to go.
I'm currently cleaning up pjass a bit and i implemented shadow-error on that branch so i wouldnt call this a stable release.
I tried to write some tests for the code changes i made but their are rather simple.
In this version i also removed the +s and +e<n> flags from pjass.
I couldn't get any code working which would've triggered +s. And i bet nobody can tell me what code +s actually checks.

  • Add "fatal error" if non-supported symbols. I randomly dropped few russian symbols in comment and map refused to load.

I would need some code to test against this.
 

Attachments

  • pjass-git-5d32bf9.zip
    36.8 KB · Views: 152
  • pjass-git-5d32bf9-src.zip
    45.5 KB · Views: 124

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
JASS:
function a takes nothing returns nothing
call BJDebugMsg("anything")//рашн коммент

endfunction

Well when i paste it into my trigger editor all cyrillic chars get replaced with questionmarks. Using some of my native non ascii characters works though.
Importing your script via mpq editor into a map also works.
So i guess the problem is on your side. Make sure it's proper utf8 and not some other encoding.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
543
reason is, I dont use editor, inserting .j file directly to the map archive with WinMPQ. Im using pjass via command line.

As i said i also injected it into mpq via mpq editor and it works for me. Again, make sure your script is properly encoded. If you want you can send me your non-working map.
 
Status
Not open for further replies.
Top