wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Warcraft Editing Tools
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 03-29-2009, 08:22 PM   #1
Zoxc
( ~)>
 
Zoxc's Avatar


Respected User
 
Join Date: Feb 2005
Posts: 959

Submissions (9)

Zoxc is just really nice (312)Zoxc is just really nice (312)Zoxc is just really nice (312)

Default A JASS2 Parser

Here is my JASS parser which is designed to be used as a background syntax checker and parser. I though I should put it up here for some gentle testing

Command line options

JassParserCLI <options> <documents>
  • --implicit-reals and -ir: Reports implicit conversion from integer constants to reals.
  • --pjass: Emulate PJASS CLI.
  • --report-leaks: Reports memory leaks at shutdown.
  • --return-bug and -rb: This will emulate the return bug.
  • --help: Shows version and command line options.

Known bugs
  • Globals and types can be declared anywhere (intensional)
  • Variable shadowing does not work correctly with 1.24.

Version history

Hidden information:

Version 0.1.12
  • Classifies error messages and reports the error location more accurately.
  • Fixed: A bug where a operation involving a integer and a real would result in a integer.

Version 0.1.11
  • Better handling of undefined identifiers
  • Fixed: A string comparison bug

Version 0.1.10
  • Strong typechecking on return statements.

Version 0.1.9
  • Added a option to emulate the return bug. Return bug emulation is now off by default.

Version 0.1.8
  • Added checking for UTF-8 BOM
  • Fixed: Couldn't convert null to boolean
  • Fixed: \" wasn't valid in strings

Version 0.1.7
  • Added a help command line options
  • Fixed: Reals needed numbers behind the separator if it didn't start with 0

Version 0.1.6
  • Added detection for implicit conversion from integer constant to reals
  • Fixed: Numbers couldn't be followed by an identifier
  • Fixed: Non-constant natives couldn't be used in constant expressions

Version 0.1.5
  • Better parsing of unknown functions
  • Fixed: Uninitialized variables could be used in their first assignment
  • Fixed: Global code arrays were allowed
  • Fixed: Code function with parameters didn't report an error
  • Fixed: Unknown characters on a new line had the wrong line number

Version 0.1.4
  • Fixed: Symbols from another file could be redeclared

Version 0.1.3
  • Emulated the return bug
  • Fixed: Parameters couldn't be used in constant funcitons

Version 0.1.2
  • Checks for uninitialized variables
  • Checks if functions used as code has parameters
  • Checks for constant locals
  • Checks for returns instead of return
  • Removed vJASS keywords
  • Fixed: A stack overflow with !
  • Fixed: Strings made the column index in errors wrong
  • Fixed: Checks for variable assignments in constant functions
  • Fixed: Local variables can't have the same name as function or global array
  • Fixed: Constants couldn't be in derived base-types
  • Fixed: Variables could be used in their initializers
  • Fixed: Arrays could have initializers
  • Fixed: No errors if variables had an array index or not
  • Fixed: Functions can't be in global variable initializers
  • Fixed: Non-constant functions can't be in constant functions
  • Fixed: Functions can't be in it's own local variable initializers
  • Fixed: No return was needed function with a return type

Version 0.1.1
  • Typechecking added
  • Fixed: Local variables could be declared anywhere
  • Fixed: Recursive function weren't allowed

Version 0.1
  • Parses blizzard.j without errors


You can find the latest source here: http://github.com/Zoxc/JassParser
Attached Files
File Type: 7z JassParser_0.1.5.7z (813.6 KB, 1467 views)
File Type: 7z JassParserCLI_0.1.12.7z (43.6 KB, 663 views)
__________________

Last edited by Zoxc : 11-02-2009 at 02:56 PM.
Zoxc is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 03-29-2009, 09:49 PM   #2
peq
User
 
peq's Avatar
 
Join Date: Jul 2006
Posts: 57

peq has little to show at this moment (4)

Default

The error messages seam to be better understandable than Pjass.

However I found one error when parsing my map script.

Collapse JASS:
if this==null then
this line is generated by jasshelper and "this" is an integer. Pjass allows this but your tool throws an error.

Maybe you could also add a check for uninitialized variables, so something like this should throw an error:
Collapse JASS:
function stupid takes nothing returns nothing
  local integer i 
  call doSomethingWith(i) // i used without initialisation
endfunction
peq is offline   Reply With Quote
Old 03-30-2009, 05:15 PM   #3
Barade
User
 
Barade's Avatar
 
Join Date: May 2006
Posts: 163

Barade is on a distinguished road (14)

Default

Source code?
__________________
Barade is offline   Reply With Quote
Old 03-30-2009, 06:15 PM   #4
C2H3NaO2
User
 
Join Date: May 2008
Posts: 80

C2H3NaO2 is on a distinguished road (17)

Default

Is it portable?
Can we use it without gui in scripts?
Should there be syntax errors in the demo?

edit: You haven't written the parse part by hand?
Collapse JASS:
function t takes nothing returns nothing
    if 1==0then
    endif
endfunction
does not work, but it is correct jass code. (afaik only adolf used it ^^)

Last edited by C2H3NaO2 : 03-30-2009 at 06:19 PM.
C2H3NaO2 is offline   Reply With Quote
Old 03-30-2009, 06:28 PM   #5
Zoxc
( ~)>
 
Zoxc's Avatar


Respected User
 
Join Date: Feb 2005
Posts: 959

Submissions (9)

Zoxc is just really nice (312)Zoxc is just really nice (312)Zoxc is just really nice (312)

Default

Quote:
Originally Posted by C2H3NaO2
Is it portable?
Yes, with a simple port to freepascal

Quote:
Originally Posted by C2H3NaO2
Can we use it without gui in scripts?
Not yet.

Quote:
Originally Posted by C2H3NaO2
Should there be syntax errors in the demo?
Plenty of 'em.

Quote:
Originally Posted by C2H3NaO2
You haven't written the parse part by hand?
I have :)

Quote:
Originally Posted by C2H3NaO2
Collapse JASS:
function t takes nothing returns nothing
    if 1==0then
    endif
endfunction
does not work, but it is correct jass code. (afaik only adolf used it ^^)
Fuck blizzard :)

I updated the parser with most of the complaints I found in the PJASS thread.
__________________
Zoxc is offline   Reply With Quote
Old 03-31-2009, 04:45 PM   #6
Zoxc
( ~)>
 
Zoxc's Avatar


Respected User
 
Join Date: Feb 2005
Posts: 959

Submissions (9)

Zoxc is just really nice (312)Zoxc is just really nice (312)Zoxc is just really nice (312)

Default

Here is version 0.1.3. Now it handles the return bug and has a pjass compatible command line interface. Simply replace the pjass.exe you were using with JassParserCLI.exe.
__________________
Zoxc is offline   Reply With Quote
Old 04-04-2009, 02:29 AM   #7
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Line numbers sometimes get off-by-one errors like in this blizzard.j:
Attached Files
File Type: zip Blizzard.j.zip (58.0 KB, 27 views)
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 04-04-2009, 09:09 AM   #8
Skater
User
 
Skater's Avatar
 
Join Date: Jan 2007
Posts: 80

Skater is on a distinguished road (17)

Default

Bugreport:

Collapse JASS:
globals
    code array cc //this gives no error
endglobals

function bla takes nothing returns nothing
endfunction

function test takes nothing returns nothing
    call TriggerAddCondition(CreateTrigger(), Condition(function bla)) //this gives no error
endfunction
__________________
Skater is offline   Reply With Quote
Old 04-04-2009, 11:13 AM   #9
Deaod
User
 
Join Date: Jan 2007
Posts: 542

Submissions (11)

Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)

Send a message via ICQ to Deaod Send a message via MSN to Deaod
Default

the second bug is no bug.
__________________
Deaod is offline   Reply With Quote
Old 04-04-2009, 11:28 AM   #10
peq
User
 
peq's Avatar
 
Join Date: Jul 2006
Posts: 57

peq has little to show at this moment (4)

Default

it is a bug, bla has to return a boolean.
---
It is really nice you added the Checks for uninitialized variables but it could still be better. This two functions give no error:

Collapse JASS:
function foo takes nothing returns nothing
    local integer i
    set i = i + 1
endfunction

function bar takes nothing returns integer
    local integer i
    if false then
        set i = 5
    endif
    return i
endfunction
peq is offline   Reply With Quote
Old 04-04-2009, 11:36 AM   #11
Deaod
User
 
Join Date: Jan 2007
Posts: 542

Submissions (11)

Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)

Send a message via ICQ to Deaod Send a message via MSN to Deaod
Default

It should, but it doesnt have to. Returning no boolean is fine, as long as noone with a Mac plays your map.
__________________
Deaod is offline   Reply With Quote
Old 04-04-2009, 12:12 PM   #12
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Quote:
Originally Posted by peq
...

Collapse JASS:
function bar takes nothing returns integer
    local integer i
    if false then
        set i = 5
    endif
    return i
endfunction

that example would be really hard to implement .as you wont have a simple "false", but some real condition there normally ..and parser cant check usually if that condition will come true.
But still it should display a warning that some code paths can return non-initialized-shit
__________________
akolyt0r is offline   Reply With Quote
Old 04-04-2009, 01:10 PM
Vexorian
This message has been deleted by Vexorian.
Old 04-04-2009, 01:15 PM   #13
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
Originally Posted by akolyt0r
that example would be really hard to implement .as you wont have a simple "false", but some real condition there normally ..and parser cant check usually if that condition will come true.
But still it should display a warning that some code paths can return non-initialized-shit
It shouldn't matter whether the condition is false or not, normally uninitialized var parsers react to code like that giving an error.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 04-04-2009, 02:08 PM   #14
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Ah true ...
Well pretty much true ...Visual Studio C# throws an error for this aswell ...
but Visual Studio C++ doesnt ...but Oh'well ..Visual Studio C++ sucks anyways..
__________________
akolyt0r is offline   Reply With Quote
Old 04-04-2009, 04:20 PM   #15
Zoxc
( ~)>
 
Zoxc's Avatar


Respected User
 
Join Date: Feb 2005
Posts: 959

Submissions (9)

Zoxc is just really nice (312)Zoxc is just really nice (312)Zoxc is just really nice (312)

Default

Fixed some stuff. The uninitialized variable thing is really just a simple flag designed to catch the most primitive errors. The Condition/Filter thing is more or less a WC3 bug and would require special handling, maybe I'll add it later.
__________________
Zoxc is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 10:36 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2017, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services