I have an alpha-test version of a syntax checker for J scripts. It is in the addons, as

general/misc/lint.ijs

The goal is to catch errors before execution. It can find only gross errors, but those are the kind my programming students make, so this is progress IMO. What it looks for is:

 explicit definitions lacking trailing ), and ) with no definition
 undefined names, including names not defined in all paths
 verbs used with invalid valences
 non-noun results at the end of condition blocks and verbs
 syntax errors
 sentences with no effect on execution (eg verb verb)

The idea is that lint can be used in place of load. It loads the script, then checks it for errors by executing each line of each explicit definition in 'safe mode' where side effects are prevented.

example:

lint '~addons/general/misc/lint.ijs'

The result of the verb is a table of (line number);(error message).
If there are errors, it brings up a grid showing the program and error messages.

I would test this a lot more before releasing it, but school starts tomorrow & I'm not going to have much more time to put on it. I think it's better than nothing - not freshman-proof, but I'll fix that as the freshmen tear into it. Meanwhile I would appreciate suggestions and bug reports.

(My thanks to Dan King who suggested this project at the J Conference in response to my bellyaching about J's error-detection deficiencies)

Henry Rich
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to