Check SLAX Scripts for Common Syntax Errors
One common problem with writing large SLAX scripts is the difficulty in isolating the location of the inevitable syntax errors. Unterminated comments or strings and other syntax problems tend to cause cascading errors, which do not point clearly to the line where the problem occurred.
The slax-doctor script helps locate these types of errors. It is not perfect but it can detect the following problems:
- Unterminated comments
- Unterminated strings
- Lines that lack proper termination
- Mixed up parenthesis and curly braces
- Missing brackets
- Missing parenthesis
- Unknown parameters included in template calls
- Missing default-less parameters in template calls
- Trying to treat template parameters like function arguments
- Trying to treat function arguments like template parameters
- Missing call statements when redirecting template results to variables
- Missing namespaces for <func:function> function names
Caveats When Using the slax-doctor Script
- Comment delimiters within quotes will cause false errors
- Comment delimiters within comments will cause false errors
- Brackets, parenthesis, and braces within quotes will cause false errors
- Equal signs within quotes passed as function arguments will cause false errors
- More than one single-line comment within a line will cause false errors
- Location paths with /* will cause false errors
- Parameter checking only works within parenthesis, not using the with statement
- Code lines that are split across multiple file lines could cause false errors
To use the script, install it on a JUNOS device which contains the script that you want to check.
user@JUNOS> op slax-doctor filename problem-script.slax
The slax-doctor script will process the script file line and report any problems it finds.
Minimum JUNOS Version: 9.4.
Latest Script Version: 1.42
SHA-256 Checksum: b165914b2409c6aaa69b3f97a72dd225cdb6c882391ff436ae5f50d31487000e