DarkBlizz

Game On => Land of AI => STARCRAFT II: WINGS OF LIBERTY => AI Development => Topic started by: LAPIN on March 06, 2010, 06:35:42 AM

Title: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 06, 2010, 06:35:42 AM
Sick of Galaxy syntax errors? This tool should be able to show you the culprit line.

Instructions:
Syntax and static type analysis. Download attachment!


Web version available at http://www.galaxyvalidator.com/ (http://www.galaxyvalidator.com/)


Type checking e.g. http://galaxyvalidator.com/results/46a5c72eb6794ecebd1fcbce4d218e28/ (http://galaxyvalidator.com/results/46a5c72eb6794ecebd1fcbce4d218e28/)


Enjoy,
Lapin
Title: Re: Galaxy syntax validator
Post by: 1337 on March 06, 2010, 07:09:36 AM
i <3 u
Title: Re: Galaxy syntax validator
Post by: LAPIN on March 06, 2010, 07:12:36 AM
There are some constructs that might not be supported. If so, please provide me with your source file. Or even better, with a simplified example of the syntax.
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 06, 2010, 03:48:30 PM
0.3 out w\ gui
Title: Re: Galaxy syntax validator Tool
Post by: CneoC on March 07, 2010, 10:52:01 AM
Nice tool, already saved me a bit of time so far :)

one thing it doesn't seem to be able to validate though: the += -= *= etc operators, which i use regularly (a += 1; beats a = a + 1; in my book :P)

Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 07, 2010, 04:28:46 PM
Version 0.4 is out.


Added the += syntax.


It will also validate the files you include in your script. So my recommendation is to make a IncludeAll.galaxy file so you can run the program on just one file which will validate all your files.
Title: Re: Galaxy syntax validator Tool
Post by: CneoC on March 07, 2010, 04:32:56 PM
awesome :)
Title: Re: Galaxy syntax validator Tool
Post by: hd on March 07, 2010, 04:45:33 PM
my 7zip won't extract the files :X

nevermind, got it to work.

unfortunately, it's not helping me find the current error ;\
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 07, 2010, 04:57:13 PM
If it's a type error it wont be able to catch it. Let me know what the error is when you know so maybe I can add detection for that sort of errors.
Title: Re: Galaxy syntax validator Tool
Post by: CneoC on March 07, 2010, 05:01:06 PM
well the most usefull error validation would probably be name typo's... though that would require a bit more work i guess. But even if it just generated a list of function calls it could not find in the specified includes. (as in, put each function definition in a list and each function call in a separate list and check which calls are not in the definition list :))

It could generate a few false positives if not all includes etc are parsed, but those could be put in a separate function dictionary text file (compile once with a working build and copy/paste everything i guess ;))

same with variables per-function but that is probably even more work ;)
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 07, 2010, 09:43:45 PM

Version 0.5 is out

i added a simple function check with this version. I also provided a list of "built-in" functions.
Title: Re: Galaxy syntax validator Tool
Post by: CneoC on March 08, 2010, 02:45:00 AM
Quote from: LAPIN on March 07, 2010, 09:43:45 PM

Version 0.5 is out

i added a simple function check with this version. I also provided a list of "built-in" functions.

nice  ;D
Title: Re: Galaxy syntax validator Tool
Post by: jenkinsdjtg on March 08, 2010, 10:01:35 AM
 :D
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 09, 2010, 12:52:58 PM
New version with basic struct/pointers support. Also detects a few more things.


Note: validate.bat will look in the current working directory now! And not in TriggerLibs.
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 09, 2010, 07:05:40 PM
I'm looking for someone to host a web asp .net front-end for this tool.


Update: http://www.galaxyvalidator.com/ (http://www.galaxyvalidator.com/)

Any help is welcomed.
Title: Re: Galaxy syntax validator Tool
Post by: Astazha on March 10, 2010, 02:56:06 PM
Nice work.
Title: Re: Galaxy syntax validator Tool
Post by: asdf14 on March 10, 2010, 04:21:50 PM
Good job man.


I've made a simple GUI for your tool. Consider it a beta. Let me know if you have any suggestions.


http://www.mediafire.com/?tl1yidd1zyy (http://www.mediafire.com/?tl1yidd1zyy)
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 10, 2010, 10:02:23 PM
Cool. gj on the editor. I added it to the first post.
Title: Re: Galaxy syntax validator Tool
Post by: asdf14 on March 11, 2010, 06:52:07 AM
It's not really an editor at the moment. It simply lets you select a file to validate and lists file contents with added line numbering and validation results. I've changed it a bit, so you may want to update your link.


http://www.mediafire.com/?ym5tyli2ij3 (http://www.mediafire.com/?ym5tyli2ij3)


Changelog:
- Auto-validates a file on load.
- Textboxes are now read-only to avoid confusion.
- If it doesn't find Lapin.exe in current directory it prompts a user to find it's path.
- Status bar now works correctly.


My current goal is to link it to Notepad++ so you can validate any file you're working on by pressing e.g. F5, to get more VS-like feeling.
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 11, 2010, 12:15:17 PM
Gj. In your next version it would be nice to indicate the tool version number so people know if they have to update.
Title: Re: Galaxy syntax validator Tool
Post by: LAPIN on March 12, 2010, 12:42:23 PM
New version 0.7.0.


Adds warnings for undeclared varaibles (which can be annoying a bit?).


Adds error when calling a function with the wrong number of arguments.
Title: Re: Galaxy syntax validator Tool
Post by: Astazha on March 12, 2010, 12:56:10 PM
A welcome pair of improvements!  That wrong # of arguments thing has caught me several times when switching between stock and stockunitnext functions.
Title: Re: Galaxy syntax validator Tool
Post by: Astazha on March 12, 2010, 12:58:24 PM
Feature suggestion:
allows you to run the prog with a command line switch and the name of a function, and it would return which file and line that function definition is on?


Not really high priority as we can still search manually and after a while you get to know your way around the files pretty well, but it would be nice at times and will help later when these projects start to get bigger.
Title: Re: Galaxy syntax validator Tool
Post by: vjeux on March 12, 2010, 03:06:22 PM

Really great!


Just found out some bugs:
int func(void);
struct Link { int value; Link* next; };


Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 16, 2010, 01:18:41 PM
Thanks for the feedback. Is void f(void) allowed? Or only void f()?
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 16, 2010, 01:20:22 PM
New version out 0.8.0. It allows you to read base scripts files to reduce the number of warnings.


If yo take time to setup your project, you should not get any false positives. So warnings about undeclared funtion/variables will actaully be helpful.


Hth,
Lapin
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: vjeux on March 16, 2010, 04:16:07 PM
This would be really nice if it could open up the mpq files and get all natives from there instead of having them extracted.
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: Kernel64 on March 17, 2010, 02:55:58 AM
This is great man. Haven't mentioned that yet, but this is much appreciated.
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: Astazha on March 18, 2010, 01:11:12 PM
Seems to have trouble with this array declaration.  The code is working.


static int[c_maxPlayers][c_OM_NextMemoryIndex] omOvermindMemory;


both of the size parameters are previously defined constants.

Title: Re: Lapin's Galaxy syntax validator Tool
Post by: kazibi on March 22, 2010, 02:58:32 AM
Nice tool!  :thumbsup:

@LAPIN
ATM I'm developing a editor for Galaxy, I'd got the syntax highlighting and code suggestions working at 100%, now it only needs to follow the language rules. Do you know where I can find info about its syntaxis?. Also, I would like to ask your permission to use your program (and its future revisions) within my editor.

kazibi.-
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 22, 2010, 11:07:31 PM
@Astazha: i need to add support for multi-dim arrays. thats in my todo.

@kazibi: feel free to integrate it in your editor. I do not know of a good source for the language syntax. I just ask people what works and what doesn't work. :-)

Edit: Oops, I do NOT know... :-)
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 22, 2010, 11:08:53 PM

@Astazha: i need to add support for multi-dim arrays. thats in my todo.


@kazibi: feel free to integrate it in your editor. I do know of a good source for the language syntax. I just ask people what works and what doesn't work. :-)
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 24, 2010, 12:35:20 AM
0.9.1 add support for multi-dim arrays.
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: Astazha on March 24, 2010, 07:37:24 AM
- Array sizing does not support operators like:


int[c_myConstant+1] myArray;


This is easy enough to get around.


- Access to multi-dim arrays does not seem to work.  This code:


result=omOvermindMemory[memIndex][c_OM_InitializedIndexOffset];


stops the validate on a parse error.  memIndex is an int.


Thanks again for all of your work Lapin.
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: AIAndy on March 24, 2010, 06:41:45 PM
Thanks for your great work.

The only thing I am missing now is proper type checking.
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 26, 2010, 01:54:29 PM
There is now a web version available at http://www.galaxyvalidator.com/ (http://www.galaxyvalidator.com/).
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: zeeg on March 26, 2010, 05:19:25 PM
Also if you have suggestions for the site (galaxyvalidator.com) you can direct them at me on here (though I'm likely to miss it), via email (dcramer@gmail), or in this thread: http://sc2.nibbits.com/forums/15/view/435/galaxy-syntax-validator (http://sc2.nibbits.com/forums/15/view/435/galaxy-syntax-validator)
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 29, 2010, 09:23:03 PM
New version with static type analysis. This is the initial release of this feature...


Tested with "major" existing AIs.


Let me know if some type conversions are not right.


Have fun,
Lapin
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on March 30, 2010, 02:15:06 PM
Online version is now running 1.0.0
Title: Re: Lapin's Galaxy syntax validator Tool
Post by: LAPIN on April 13, 2010, 11:42:21 AM
Version 1.1.0 is out. With small addition for more type checking.