finesse.script.compiler module
Kat model compiler.
This takes parsed productions, figures out the dependencies and builds the model in the correct order.
Sean Leavey <sean.leavey@ligo.org>
- class finesse.script.compiler.KatCompiler(spec=None)[source]
Bases:
objectKat model compiler.
- compile(string, **kwargs)[source]
Compile the contents of string.
Parameters
- string
str The string to compile kat script from.
Other Parameters
- kwargs
Keyword arguments supported by
compile_file().
Returns
ModelThe model compiled from reading string.
- string
- compile_file(fobj, model=None, resolve=True, build=True)[source]
Compile the contents of the specified file.
Parameters
- fobj
io.FileIO The file object to compile kat script from. This should be opened in text mode.
- model
Model, optional An existing model to compile the contents of fobj into. If not specified, a new, empty model is created.
- resolve
bool, optional Resolve the parsed script. If False, the parsed contents is added to graph but no sanity checks are performed and nothing is returned. Defaults to True.
- build
bool, optional Build the parsed script. If False, no Finesse objects will be added to the model and nothing will be returned. Defaults to True.
Returns
Modelor NoneIf resolve and build are True, the model compiled from reading fobj; None otherwise.
Raises
KatSyntaxErrorIf a syntax error is present in the contents of fobj.
- fobj
- exception finesse.script.compiler.KatCycleError(script, cyclic_nodes)[source]
Bases:
KatScriptErrorCyclic parameters.
- exception finesse.script.compiler.KatDirectiveBuildError(error, directive, script, statement_node, adapter, graph, spec)[source]
Bases:
KatDirectiveErrorError during the building of a directive (i.e. the call to the Finesse Python object).
- exception finesse.script.compiler.KatDirectiveError(error, directive, script, error_items, spec, add_syntax_hint=False)[source]
Bases:
KatScriptErrorError compiling a directive (either resolving or building).
- exception finesse.script.compiler.KatIncorrectFormError(user_directive_token, script, spec)[source]
Bases:
KatSyntaxErrorError representing an element, command or analysis that uses the wrong syntax form.
For example, this is thrown when a command is written in “element” KatScript form, and vice versa.
This is technically a syntax error, but it is not caught there because it doesn’t know which directives use which type of syntax.
- exception finesse.script.compiler.KatParameterBuildError(error, script, param_node, graph)[source]
Bases:
KatScriptErrorError during the building of a directive parameter.