Jump to content

[WIPz] Script Validator


Cipscis

Recommended Posts

Some of you might be familiar with the Script Validator that I have hosted on cipscis.com. I've got a summer job at the moment that includes some work with JavaScript, in which I've learnt some neat new things that I didn't know when I first wrote the validator. Because of this, I've now started to rewrite it.

 

So far, I've nearly got my development version up to the same state as the live version, in terms of functionality, with less than half the required code. I'm not expecting anyone to take me up on this, but I've uploaded the dev version to cipscis.com. If anyone's interested in testing it or having a look at how I've written it (and perhaps offer some pointers if you know a bit of JavaScript) you can find it here.

 

I'll update this post when I update the file, and when I take it down once it's ready to go live. If anyone wants to have a look at it I'd appreciate it if they could let me know here just so I can see who's interested.

 

Cipscis

 

Updated file - fixed bugs with "else"/"elseif" statements and "set" commands.

 

Updated file - fixed error with IE 7, indentation bug and incorrect error reporting of missing "endif" statements at End statements.

 

Updated file - fixed indentation of empty lines, problems with residual error detection. Added script type detection via ScriptName and blocktype and related errors (not checking variables yet)

 

Cipscis

Link to comment
Share on other sites

  • 1 month later...

I've been slowly working on the dev version of my validator, and it's advanced a bit further since I last posted here. At the moment it checks all the same errors as the old validator with only a couple of exceptions (variables in result scripts), and checks a few more on top of them.

 

The current iteration can be found here

 

Cipscis

Link to comment
Share on other sites

Another update for the dev version - conditions will now be checked for mismatched brackets, and any unused expressions (i.e. on their own line) will give an error.

 

Cipscis

 

EDIT:

 

I've now implemented a rudimentary form of expression parsing. Expressions used in conditional statements or "set" commands will now give more comprehensive errors, telling you how your brackets are mismatched, and how many condition fragments are erroneous. For example, the following line of code will give errors:

set foo to bar.foo (* 3))

The errors given would be:

1 mismatched closing bracket
1 invalid expression fragment

At the moment, any expression in which two non-operator words (i.e. sets of alphanumeric characters) will be assumed to be function calls, so things like this won't give any errors:

set foo to 3 2

The next step will be to start on function parsing, and once I've got that working I should just be able to populate the function dictionary without having to change any of the actual code.

 

This expression parsing has been the hardest part of the validator to test so far, so if anyone finds any extra errors that are reported, or any that are missed, please let me know here.

 

Cipscis

 

EDIT:

 

If any invalid characters are found in an expression (at the moment I'm searching for these: @, #, $, ^, ?, :, [, ], \) then they'll throw one "invalid expression fragment" error and then the validator will remove them from the expression that is being validated. They'll still appear in the output, but once found the validator will ignore them as it validates the rest of the expression. EDIT: This behaviour will also be used if a function is called with explicit syntax, but the calling reference is omitted.

 

Cipscis

 

EDIT:

 

It looks like I'd forgotten to implement code that handles function calls in expressions, and they were throwing errors. That should be fixed now, though.

 

Cipscis

 

EDIT:

 

Now works with functions using commas to separate parameters.

 

Cipscis

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...