It can check .ssc, .stc, .dsc and .cel files for their syntax (but not the values of each parameter). This can be useful if you have an ssc file which is very long (e.g. a long timeline with many parameters each) and you are unsure if you have closed all opened braces.
To use it:
Open a command line, run the file from there and pass the name to the .ssc/.stc/.dsc/.cel file as an argument, like this:
Code: Select all
celcheck myfile.ssc
Note: the script allows you to put ssc, stc, dsc objects and cel scripts together into one file, so if you have a large addon with two or more types of objects and scripts, you don't have to check each file separately but all in once.
This script doesn't check the names and values of the parameters (for compatibility reasons, one Celestia version has other/new paramaters than an older one).
Examples for defintions celcheck will mark as valid:
Code: Select all
"My object" "Sol/Parent" {
Class "moon"
}
Modify "My other object" "Sol/Parent" {}
"" "" {}
# This definition has wrong values but celcheck doesn't care about that:
"My fourth object" "Sol/Parent" {
Class 123
Radius "invalid radius, but valid file"
Texture [1 2 3]
EllipticalOrbit true
SomeUnknownParameter [1 [1 2] {Key "value"} true 1 3 false]
}
Invalid definitions:
Code: Select all
# [] instead of {}
"My object" "Sol/Parent" [
Class "moon"
]
# Forget to specify the parent object
Modify "My other object" {}
# Forget the {}
"" ""
# The 'UniformRotation' parameter doesn't have a value +
# there is an unclosed { in the SomeUnknownParameter (or if it is closed by the end }, the main body isn't closed)
"My fourth object" "Sol/Parent" {
Class 123
Radius "invalid radius, but valid file"
UniformRotation
Texture [1 2 3]
EllipticalOrbit true
SomeUnknownParameter [1 [1 2] {Key "value" true 1 3 false]
}
Note: there must be at least one object definition in the file to be valid.
The script has been written in Python and uses the Lark parser.
How the script works internally:
1. Try to read input file
If everything runs well:
_2. Build the parser
_3. Parse the file
_If there are no errors:
__4. Tell the user that the file is valid
_If there are errors:
__4. Print the errors
If none is specified or it could not be read:
_2. print an appropriate message
5. Exit
Files for download:
celcheck_1.1.exe - binary program (note on file size: the script was built with Pyinstaller so don't wonder about the 112.57 MB)
source_code_1.1.zip - contains "celcheck.py" and "grammar.txt" (for anyone who wants to modify/fix bugs/extend the script, but you have to credit me if you publish that modifed version)
Update 1.1: Added support for .cel scripts! If you need an older version, comment below or PM me.