[RELz] - Script Validator

Post » Sun Aug 08, 2010 7:47 pm

Now that I'm finally on a break from University, I've been able to find some time to finally get my website, http://www.cipscis.com, up and running. As part of this, I've written a JavaScript utility that can automatically indent scripts and check them for several structural errors, including some that the GECK compiler misses, such as extra "endif" statements.

Here's the link for anyone interested in trying it out - http://www.cipscis.com/fallout/utilities/validator.aspx

Cipscis

EDIT:

Update 3/08/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now validate "set" commands.
Update 8/08/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now return an error if an "elseif" or "else" statement is used without a preceeding "if" statement
Update 13/08/09 - Minor fixes to indenting of code with conditional statement errors. If code contains "else" or "elseif" statements without preceeding "if" statements, the code will now be indented as if the error did not exist.
Update 20/08/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now validate ScriptName declarations, and will automatically detect the type of script that is being validated in order to appropriately validate code outside of Begin/End blocks.
Update 24/09/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now return an error if a variable declaration is found within a Begin/End block, or if a non-"ref" variable is declared in a result script.
Update 10/12/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now return an error if a script's EditorID (as defined in the ScriptName) begins with a number.

As of 10/12/09 the JavaScript for my validator has been compiled via the http://closure-compiler.appspot.com/home. This reduces its size greatly, but also makes it pretty much impossible to read. However, if anyone wants to view the original source just let me know and I'll make it available to them.

Update 13/12/09 - Rewrote the validator in order to shorten it a bit and ended up fixing a few bugs (including a pretty serious one in IE) at the same time. I've been through and checked that each error works as expected so hopefully I haven't introduced any new bugs.

Update 14/12/09 - The http://www.cipscis.com/fallout/utilities/validator.aspx will now return an error if an invalid blocktype is used.

Cipscis

EDIT2:

I'm currently working on a new version of the validator available http://www.cipscis.com/dev/validator/validator.html

Cipscis

EDIT3:

There is, once again, only 1 version of the validator available. You can find the latest version http://www.cipscis.com/fallout/utilities/validator.aspx.

Cipscis
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Sun Aug 08, 2010 4:05 pm

Hiya Cipscis,

Long time no hear from? lol Thxs for another wonderful program!

Keep them coming
It's always appreciated!

CJ :goodjob:
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Sun Aug 08, 2010 10:09 am

Sweeeeeet. :D
User avatar
Jonathan Braz
 
Posts: 3459
Joined: Wed Aug 22, 2007 10:29 pm

Post » Sun Aug 08, 2010 10:07 pm

Yeah, I've been pretty quiet over the last 5 weeks or so, thanks to my exams. I had to stop working on a few project for that time, but I'm doing my best to pick them all back up now. This particular project was inspired in much the same way as my "Scripting For Beginners" tutorial - I was tired of recommending someone else's utility for automatically indenting scripts and thought I'd try my hand at making my own one. In the end, it turned into a little more than just an auto-indenter, too. I'm glad you like it!

I plan to create more web-based utilities for http://www.cipscis.com in the future, most likely for things like automatically generating code from templates, but for now I'm working on some more reference articles.

P.S. For those who don't know about the script indenter that I used to recommend, it was written for Morrowind by ManaUser and can be found here - http://webpages.charter.net/manauser/morrowind/indenter.htm

Cipscis
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am

Post » Sun Aug 08, 2010 10:11 pm

Yeah, I've been pretty quiet over the last 5 weeks or so, thanks to my exams. I had to stop working on a few project for that time, but I'm doing my best to pick them all back up now. This particular project was inspired in much the same way as my "Scripting For Beginners" tutorial - I was tired of recommending someone else's utility for automatically indenting scripts and thought I'd try my hand at making my own one. In the end, it turned into a little more than just an auto-indenter, too. I'm glad you like it!

I plan to create more web-based utilities for http://www.cipscis.com in the future, most likely for things like automatically generating code from templates, but for now I'm working on some more reference articles.

P.S. For those who don't know about the script indenter that I used to recommend, it was written for Morrowind by ManaUser and can be found here - http://webpages.charter.net/manauser/morrowind/indenter.htm

Cipscis



Very nice indeed! Glad to have ya back around!


CJ
User avatar
Elena Alina
 
Posts: 3415
Joined: Sun Apr 01, 2007 7:24 am

Post » Sun Aug 08, 2010 11:08 am

Already bookmarked it when I was looking at your info on Loops. Great work Buddy.

Thanks!

Skykappa
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Sun Aug 08, 2010 8:00 pm

Wonderous. :)

You the man!

M
User avatar
yessenia hermosillo
 
Posts: 3545
Joined: Sat Aug 18, 2007 1:31 pm

Post » Sun Aug 08, 2010 10:05 pm

Cipscis,

A quick note - I accidentally put a number-sign (#) in my script for a comment instead of a semi-colon ( ; ) -habbit from the coding I do at work. The script let this pass with no errors found, though the GECK nabbed me for it. :)

Thanks again for the tool, I plan to use it on all of my scripts and to credit you in the mod for helping make the scripting go alot faster!

Cheers,

M
User avatar
Chloe Botham
 
Posts: 3537
Joined: Wed Aug 30, 2006 12:11 am

Post » Sun Aug 08, 2010 2:33 pm

Glad to have ya back around!
Thanks, I'm glad to be back!

@Miaximus:
The way the validator is currently written, it scans the beginning of each line in order to detect what type of line it is. If the line is a valid structural element, such as an "if" statement, then the validator processes it and uses it to validate the script structure, but if the line is not a valid structural element then the validator ignores it. These are the types of lines that the validator currently processes:
  • "if" statements
  • "elseif" statements
  • "else" statements
  • "endif" statements
  • Begin statements
  • End statements
  • Variable declarations
    • long
    • short
    • int
    • float
    • reference
    • ref
If a line isn't one of these types, then the validator will skip it. I will probably add more things to the validator in the future, especially if FOSE adds any new syntax, but for now it only checks those things.

Cipscis
User avatar
jesse villaneda
 
Posts: 3359
Joined: Wed Aug 08, 2007 1:37 pm

Post » Sun Aug 08, 2010 7:52 pm

Ahhhh I gotcha, thanks for the clarification. :)

I plan to use this Extensively on all of my scripts. I only have a dozen in the mod so far, but that will rise to at least 50 before the end.

Again my thanks for this! Very nice tool

M
User avatar
Flutterby
 
Posts: 3379
Joined: Mon Sep 25, 2006 11:28 am

Post » Sun Aug 08, 2010 6:48 pm

Update:

The http://www.cipscis.com/fallout/utilities/validator.aspx will now validate "set" commands. While it doesn't check the content of the variable name or expression, it does ensure that each "set" command uses the following syntax:
set varName to expression

Cipscis
User avatar
Far'ed K.G.h.m
 
Posts: 3464
Joined: Sat Jul 14, 2007 11:03 pm

Post » Sun Aug 08, 2010 5:02 pm

I know how your Script Validator works!

When you press "validate" it sends the text to an IRC channel where you (Cipscis) are, then you drink 20 Gallons of Red Bull and get to work and code inject your own site with a reply.

AMMARITE?
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Sun Aug 08, 2010 12:03 pm

Thank you very much for that Cipscis. :goodjob:

I think I'll just paste in all of the vanilla scripts just for fun, I'm almost certain I'm going to find something somewhere.
User avatar
Tracey Duncan
 
Posts: 3299
Joined: Wed Apr 18, 2007 9:32 am

Post » Mon Aug 09, 2010 2:03 am

Yeah, thanks Cipscis! Works great, good work :D

-ArT
User avatar
Floor Punch
 
Posts: 3568
Joined: Tue May 29, 2007 7:18 am

Post » Sun Aug 08, 2010 10:09 pm

You're pretty close, Arkayer, but I'm actually hooked up to an intravenous drip so I can get hands-free energy.
I'm glad you like it Artisten!

Thanks to Lyrondor commenting on a script that he ran through my validator, I have now added another error check to it. My http://www.cipscis.com/fallout/utilities/validator.aspx will now output an error if "elseif" or "else" statements are used without a preceeding "if" statement.

For an example of this, try validating the following code:
elseif <condition>endifelseendif
The error output should be:
"elseif" statement on line 1 not valid unless preceeded by "if" statement"else" statement on line 4 not valid unless preceeded by "if" statement

Cipscis
User avatar
Lauren Dale
 
Posts: 3491
Joined: Tue Jul 04, 2006 8:57 am

Post » Mon Aug 09, 2010 2:03 am

Minor update - if validated code contains "else" and/or "elseif" statements without preceeding "if" statements then the code will be indented as if the error did not exist.

For example, the following invalid code would previously have looked like this after being validated:
Begin GameMode	if <condition>		; Do stuff	endifelse	; Do more stuffendifif <condition2>	; As you can see, this screws up the rest of the indentingendifEnd
These indentation errors will no longer accompany conditional statement errors. Here is the code as it would look after being validated now:
Begin GameMode	if <condition>		; Do stuff	endif	else		; Do more stuff	endif	if <condition2>		; As you can see, the indenting now looks fine	endifEnd
The error log for both portions of code are still the same:
"else" statement on line 6 not valid unless preceeded by "if" statement

Cipscis
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Sun Aug 08, 2010 3:08 pm

Glad to see that you are maintaining the site :)

Would it be possible to require a 'ScriptName' or 'scn' function at the start of the script? And address all non-commented text outside a block as errors?
Not likely a error big as that that would happen, but who knows? Feel free to ignore this request if you want to priority something else :)

Oh, and another thanks from me, I admire your infinite source of helpfulness and patience on these forums!

Art
User avatar
Emma-Jane Merrin
 
Posts: 3477
Joined: Fri Aug 08, 2008 1:52 am

Post » Sun Aug 08, 2010 12:57 pm

Thanks Artisten. The main reason why I haven't done this yet is because I'm using the same code to validate "regular" scripts as I am to validate result scripts or just partial scripts. I definitely agree that it would be useful though, as there are notable differences between these types of script so if the same code is used to validate each then some errors will surely be missed.

When I get the time I'd like to put in a form so that the user can specify the type of script so that I can validate it accordingly by selecting options such as "Result Script" so that I know how to treat "ScriptName" declarations and Begin/End blocks. Hopefully I'll have time to put some decent work into this, and my next tutorial, early next week.

Cipscis
User avatar
sally coker
 
Posts: 3349
Joined: Wed Jul 26, 2006 7:51 pm

Post » Sun Aug 08, 2010 4:52 pm

Ah, I see. Thanks!
User avatar
[ becca ]
 
Posts: 3514
Joined: Wed Jun 21, 2006 12:59 pm

Post » Sun Aug 08, 2010 3:56 pm

Another update - although there's still no form to specify the type of script that's being validated, ScriptName declarations are now validated and the http://www.cipscis.com/fallout/utilities/validator.aspx will attempt to detect the type of script that is being validated in order to appropriately validate code outside of Begin/End blocks.

Cipscis
User avatar
Michelle Serenity Boss
 
Posts: 3341
Joined: Tue Oct 17, 2006 10:49 am

Post » Sun Aug 08, 2010 10:17 pm

One more update - if a variable is declared within a Begin/End block or a non-"ref" variable is declared in a result script (defined here as a script with no ScriptName declaration and no Begin/End blocks) the http://www.cipscis.com/fallout/utilities/validator.aspx will now return an error.

Cipscis
User avatar
Noraima Vega
 
Posts: 3467
Joined: Wed Jun 06, 2007 7:28 am

Post » Sun Aug 08, 2010 2:10 pm

Thanks for continually updated and refreshing your site! I use the Validator whenever I work on scripts, and am using your staged timers for the main battle scene in my mod.

Kudo's for a really great contribution. :)

:turtle:

Miax
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Sun Aug 08, 2010 4:17 pm

As of 10/12/09 the JavaScript for my validator has been compiled via the http://closure-compiler.appspot.com/home. This reduces its size greatly, but also makes it pretty much impossible to read. However, if anyone wants to view the original source just let me know and I'll make it available to them.

Cipscis

EDIT:

Oops, looks like I'd accidentally copied the OP here. Fixed now.

Cipscis
User avatar
kat no x
 
Posts: 3247
Joined: Mon Apr 16, 2007 5:39 pm

Post » Sun Aug 08, 2010 7:55 pm

I don't know if you track hits, but I use it frequently!

Great stuff. :)

Miax
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Sun Aug 08, 2010 10:18 pm

I do track hits, actually, via Google anolytics. Interestingly enough, and despite my recent inactivity, http://www.cipscis.com/ had more unique visitors and visits overall (by 1) a couple of days ago than ever before.

Cipscis
User avatar
Eileen Müller
 
Posts: 3366
Joined: Fri Apr 13, 2007 9:06 am

Next

Return to Fallout 3