[RELz] - Script Validator

Post » Sun Aug 08, 2010 10:14 pm

If I remember correctly, OBSE adds some extra compiler errors to accompany its additional syntax, and I think for errors that were originally missed such as extra "endif" statements.

The dev validator will now give a warning at the end of the script if a local variable is declared but never assigned a value. This is not necessarily an error, as local variables may only be set remotely, so it will appear with a yellow background rather than a red one.

Cipscis
User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Sun Aug 08, 2010 10:09 pm

If I remember correctly, OBSE adds some extra compiler errors to accompany its additional syntax, and I think for errors that were originally missed such as extra "endif" statements.
Yup. Also when there's a return call inside a while loop. Those 2 are the only script-wide evaluations being made, to my knowledge.
User avatar
SEXY QUEEN
 
Posts: 3417
Joined: Mon Aug 13, 2007 7:54 pm

Post » Sun Aug 08, 2010 7:01 pm

I've just implemented a rudimentary script dictionary such that the validator should now let you know if you've called a function that has no return value in an expression. I've had to guess the return type of some of the more obscure undocumented functions, but if I have made any mistakes they'll hopefully be with functions that will probably never be used.

Cipscis
User avatar
Katie Louise Ingram
 
Posts: 3437
Joined: Sat Nov 18, 2006 2:10 am

Post » Mon Aug 09, 2010 4:38 am

It's been a little while since my last update here. I've made quite a few tweaks to the dev version, although I haven't been keeping tack of them very well recently and don't remember what the status was when I last posted about an update here. I'm just about ready to get to work on function evaluation though, and hopefully there are very few bugs currently left in the validator.

I've just added a couple of extra buttons to show/hide any warnings so that the validated (and indented) script can be copied if it has warnings but isn't invalid. Here's a link again - http://cipscis.com/dev/validator/validator.html

Cipscis
User avatar
Rob Davidson
 
Posts: 3422
Joined: Thu Aug 02, 2007 2:52 am

Post » Mon Aug 09, 2010 10:02 am

Could you post a list of the tool's features (as in the errors it validates) ? I would like to see what I can port to Oblivion.
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Sun Aug 08, 2010 10:03 pm

I just wanted to chime in and thank you for this invaluable tool. If I didn't have to share the computer with my wife I would have set up your script validator as my homepage.

It is however hotkeyed!!
User avatar
sophie
 
Posts: 3482
Joined: Fri Apr 20, 2007 7:31 pm

Post » Mon Aug 09, 2010 5:29 am

Just updated the dev version of the validator again with some minor fixes to expression parsing, as well as replacing the two buttons to show/hide warnings with a single "Toggle Warnings" button.

Sorry ShadeMe, I missed your post. I'll put together a list of warnings and errors for you later tonight. Most of them will be caught by the GECK's compiler already, so I'll try to focus on the ones specific to my validator.

Thanks for your kind words SteveDog! I'm glad to hear you find it useful.

Cipscis
User avatar
Rex Help
 
Posts: 3380
Joined: Mon Jun 18, 2007 6:52 pm

Post » Sun Aug 08, 2010 10:15 pm

Sorry ShadeMe, I missed your post. I'll put together a list of warnings and errors for you later tonight. Most of them will be caught by the GECK's compiler already, so I'll try to focus on the ones specific to my validator.
My thanks. I shall, meanwhile, continue my travels through the CS's disassembly and attempt to find a cozy address to hook at.
User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Mon Aug 09, 2010 10:43 am

Ok, I've finished collecting all the errors and warnings. Here are the errors that the GECK misses (I assume they're the same ones that the CS misses):
  • Script already has a ScriptName declaration
  • "ScriptName" is a keyword
  • "ScriptName" is a function
  • Blocktype invalid for this type of script (GECK catches this when reference-specific blocktypes are used for quest scripts, but not when effect-only blocktypes are used in non-effect scripts)
  • elseif statement invalid without preceeding if statement
  • elseif statement invalid after else statement on line #
  • else statement invalid without preceeding if statement
  • else statement invalid after else statement on line #
  • endif statement invalid without preceeding if statement
  • Condition not allowed (applied to lines starting with "Return", "End", "else" and "endif"
  • Multiple editorIDs (applied to ScriptName declarations)
  • EditorID starts with a number
  • EditorID contains invalid character (applied to ScriptName declarations. The compiler will truncate the editorID just before the invalid character)
  • EditorID starts with a number (applied to "set" commands with remote variables. The compiler will say that it can't find the variable, whereas the error is due to the editorID starting with a number)
  • Variable declaration invalid within Begin/End block
  • Variable "varName" has already been declared
The validator will also give a warning if a variable is declared but not used, and if a condition appears on its own line (therefore having no use). All other warnings and errors should be caught by the compiler already.

Cipscis
User avatar
Milagros Osorio
 
Posts: 3426
Joined: Fri Aug 25, 2006 4:33 pm

Post » Sun Aug 08, 2010 8:57 pm

The validator will also give a warning if a variable is declared but not used, and if a condition appears on its own line (therefore having no use). All other warnings and errors should be caught by the compiler already.
That is a lot. Shame on Beth. Thanks again.
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Mon Aug 09, 2010 4:53 am

Just completed another update, this time focussing on function validation. The validator will now check that a function call has an appropriate number of parameters (it will not check the contents of the parameters yet though), and will make sure that whether or not it has a return value is appropriate for its usage. For example, if http://geck.gamesas.com/index.php/Enable (which has no return value) is used in a condition, the validator will give a warning. Similarly, if http://geck.gamesas.com/index.php/PlaceAtMe (which has a return value) is used on its own, rather than in a condition, the validator will give a warning (only a warning though, as this use is still valid).

I guess the next step would be to check the contents of function calls more rigorously, but at the moment most of the functions haven't had their parameters defined so they can't have them validated, so I'll probably end up working on the function dictionary for a while rather than new functionality.

I've also implemented a feature by which the required version of FOSE for a script will be reported, but once again the usefulness of this feature is limited by the fact that most FOSE functions haven't got their required versions defined yet in my dictionary.

If anyone wants to try out the new functionality, http://geck.gamesas.com/index.php/PlaceAtMe, http://geck.gamesas.com/index.php/Enable and http://fose.silverlock.org/fose_command_doc.html#GetFOSEVersion are all in the dictionary.

@Tarrant:
Thanks for the bug report in your PM. The validator should accept http://geck.gamesas.com/index.php/GameMode and http://geck.gamesas.com/index.php/MenuMode in effect scripts now (I assume that's what the problem was).

Cipscis

EDIT:

I just realised that I don't have a way to deal with those FOSE functions that can be treated as reference functions or non-reference functions... I guess that won't be a problem until I've fully defined some of them though. If anyone would be willing to help me out with function definitions, please let me know either here or via PM.

Cipscis
User avatar
Euan
 
Posts: 3376
Joined: Mon May 14, 2007 3:34 pm

Post » Mon Aug 09, 2010 6:55 am

I'd like a few points from your previous post clarified, if you will.
"ScriptName" is a keyword"ScriptName"  is a function

When are the above warnings/errors raised ?
User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Sun Aug 08, 2010 10:16 pm

Oops! Those errors are referring to the script's editorID, rather than the "ScriptName" keyword itself. For example:
ScriptName setScriptName GetActorValue
While those are technically valid editorIDs, they really shouldn't be used as it could lead to confusion if the script's editorID is ever used in a script (for example, with FOSE's http://fose.silverlock.org/fose_command_doc.html#SetScript)

Cipscis
User avatar
Rex Help
 
Posts: 3380
Joined: Mon Jun 18, 2007 6:52 pm

Post » Mon Aug 09, 2010 7:56 am

Oops! Those errors are referring to the script's editorID, rather than the "ScriptName" keyword itself. For example:
ScriptName set ScriptName GetActorValue
While those are technically valid editorIDs, they really shouldn't be used as it could lead to confusion if the script's editorID is ever used in a script (for example, with FOSE's http://fose.silverlock.org/fose_command_doc.html#SetScript)

Cipscis
Ah, thanks!
User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Post » Mon Aug 09, 2010 10:00 am

The dictionary is coming along rather well. I only have about 50-60 functions documented at the moment, but I've added the ability to report function-specific errors and warnings under certain circumstances to make scripting even easier. For example, if http://geck.gamesas.com/index.php/GetSecondsPassed is used in a http://geck.gamesas.com/index.php/ScriptEffectUpdate block, the validator will give a warning and recommend using http://geck.gamesas.com/index.php/ScriptEffectElapsedSeconds instead.

A large number of existing functions (like "UnusedFunction21" and "IsRidingHorse") will be accepted by the compiler, but shouldn't be used. I've gone through the entire list and tagged the functions that I am certain or almost certain should be deprecated, so the validator will let you know if a function should not be used for this reason. If a deprecated function has an alternative that does work (and I know about it), the validator will recommend it (for example, http://geck.gamesas.com/index.php/Cast is deprecated, but http://geck.gamesas.com/index.php/CastImmediateOnSelf can be used in its place).

If anyone finds a mistake in any function documentation, or any unrecognised functions, please let me know and I'll update the function dictionary.

Cipscis
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Mon Aug 09, 2010 12:27 pm

Massive thanks to HugePinball, who has translated the entire library of FOSE v1 functions into the format required for my dictionary via a Perl script.

As a result of this, the http://cipscis.com/dev/validator/validator.html will now validate every function from FOSE v1, letting you know if you are missing any parameters (or have too many), if you have neglected its return value, and reporting the required version of FOSE at the end of the script if you've used at least one.

Cipscis

EDIT:

There are a few new functions that have been added since FOSE v1 was released, but they haven't been added to the documentation yet. I'll be adding them to my dictionary when the documentation is next updated.

Cipscis

EDIT:

Thought I'd mark the occasion:

This is my 4,600th post.

Cipscis
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Mon Aug 09, 2010 12:38 pm

Cool stuff!

There was a mean mistake that almost drove me mad the other day:
if player .isDead == 1endif

Those whitespaces sometimes slip in when you copy/paste and it took a while until i finally noticed where the problem was. Would be cool if this could be detected.
User avatar
dav
 
Posts: 3338
Joined: Mon Jul 30, 2007 3:46 pm

Post » Sun Aug 08, 2010 10:15 pm

Small update to the UI - I've removed the "Validate" button, and changed the page so that your script will be validated each time you change it. This allows you to write your script in the validator and have it indent it for you as you write it, as well as warning you about anything you've done wrong as you write it, to help keep your scripts as error-free as possible.

I'm thinking of implementing some form of syntax highlighting in the output as well, which should make the validator an even better tool for writing and editing scripts.

@schlangster:
At the moment, the validator recognises a period prefixed by whitespace or the start of an expression as an invalid expression fragment, and gives that as an error ("x invalid expression fragment(s)"). I'm sure there are other similar errors that it doesn't recognise though, so I'll look into it at some point.

Cipscis
User avatar
Rachel Cafferty
 
Posts: 3442
Joined: Thu Jun 22, 2006 1:48 am

Post » Mon Aug 09, 2010 4:11 am

I just implemented some rudimentary syntax highlighting, based on the styles used in my http://www.fallout3nexus.com/downloads/file.php?id=10322.

Now that the validator processes your code as you type, indents and highlights it, and provides useful output, I find that it's actually a relatively useful script-writing tool.

Cipscis
User avatar
Rachel Tyson
 
Posts: 3434
Joined: Sat Oct 07, 2006 4:42 pm

Post » Sun Aug 08, 2010 10:08 pm

Looks nice. :)

Thanks as always for making updates, I use your tool regularly!

Cheers,

Miax
User avatar
Rachyroo
 
Posts: 3415
Joined: Tue Jun 20, 2006 11:23 pm

Post » Sun Aug 08, 2010 9:11 pm

Thanks Miax.

I just made another update improving how the validator handles string literals. String literals will now give errors when used erroneously in function calls and will be highlighted in the output. The validator will also no longer interpret semicolons in strings as the beginning of a line comment.

I've improved how function parameters are checked too, so if they're incorrectly separated you should get an error.

Cipscis
User avatar
Haley Merkley
 
Posts: 3356
Joined: Sat Jan 13, 2007 12:53 pm

Post » Mon Aug 09, 2010 5:21 am

Just popping in to push http://www.gamesas.com/index.php?/topic/1082282-discussion-cs-script-editor-wish-list/page__p__15766768__fromsearch__1&#entry15766768 in your face and say "Thanks for that error list and inspiration, mate :thumbsup:".

Hopefully, when and if time permits, I'll see about porting this to the GECK.

PS : I haven't read through the thread, so pardon me for asking this of you - Added/discovered any new features/errors ?
User avatar
Francesca
 
Posts: 3485
Joined: Thu Jun 22, 2006 5:26 pm

Post » Mon Aug 09, 2010 3:58 am

I've been using this thing more lately. The weapctrl scripts as they live in FOOK are quite a beast. One extra endif in the middle can ruin your whole day... but the Cipscis Script Validator can help track it down!

If only from the accurate indenting, you can even directly see where that extra endif is hiding because it shifts the code over one column.

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

Post » Sun Aug 08, 2010 10:14 pm

@shadeMe:
Wow, that looks awesome! I can think of a couple of useful things that you might be able to include in it - I'll post them over in that thread.

Since you were last here, I've been working on function validation, including my function dictionary, so I've been mostly catching up with the GECK rather than doing new things. The new features that didn't already exist in the compiler are:
  • Function specific warnings and errors. For example, if http://geck.gamesas.com/index.php/http://geck.gamesas.com/index.php/GetSecondsPassed is called in a http://geck.gamesas.com/index.php/ScriptEffectUpdate block, then the validator will recommend http://geck.gamesas.com/index.php/ScriptEffectElapsedSeconds instead.
  • Pretty similar to the above point - some functions or parameters have been marked as deprecated, and will generate an error. http://cs.elderscrolls.com/constwiki/index.php/IsRidingHorse, for example, doesn't work in Fallout 3. The same applies to some function's parameters, like the duration parameter of http://geck.gamesas.com/index.php/ShowMessage.
  • Warnings will be given if a variable is not used anywhere. Previously I would give a warning if the variable is never assigned a value, whereas now I will also give a warning if a variable is never used in an expression, to call a reference function, or as a function parameter.

I've also added syntax highlighting to the output and started evaluating the script as it's written, rather than at the press of a button, but both of those are just UI updates.

@Tarrant:
Yeah, it's a massive scripts like that where structural errors can slip in, often due to copy/paste errors. They're a real [censored] to find by eye alone.

Cipscis
User avatar
Matt Fletcher
 
Posts: 3355
Joined: Mon Sep 24, 2007 3:48 am

Post » Mon Aug 09, 2010 3:51 am

[*]Function specific warnings and errors. For example, if http://geck.gamesas.com/index.php/http://geck.gamesas.com/index.php/GetSecondsPassed is called in a http://geck.gamesas.com/index.php/ScriptEffectUpdate block, then the validator will recommend http://geck.gamesas.com/index.php/ScriptEffectElapsedSeconds instead.
[*]Pretty similar to the above point - some functions or parameters have been marked as deprecated, and will generate an error. http://cs.elderscrolls.com/constwiki/index.php/IsRidingHorse, for example, doesn't work in Fallout 3. The same applies to some function's parameters, like the duration parameter of http://geck.gamesas.com/index.php/ShowMessage.
[*]Warnings will be given if a variable is not used anywhere. Previously I would give a warning if the variable is never assigned a value, whereas now I will also give a warning if a variable is never used in an expression, to call a reference function, or as a function parameter.[/list]
I've also added syntax highlighting to the output and started evaluating the script as it's written, rather than at the press of a button, but both of those are just UI updates.
  • ]Nice. That'll be something that I can work on in the future. Might require a rewrite of the parser.
  • That I've already added.

I took a look at the dev version - It looks super-awesome-face-awesome :goodjob:
User avatar
luke trodden
 
Posts: 3445
Joined: Sun Jun 24, 2007 12:48 am

PreviousNext

Return to Fallout 3