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: object

Kat model compiler.

compile(string, **kwargs)[source]

Compile the contents of string.

Parameters

stringstr

The string to compile kat script from.

Other Parameters

kwargs

Keyword arguments supported by compile_file().

Returns

Model

The model compiled from reading string.

compile_file(fobj, model=None, resolve=True, build=True)[source]

Compile the contents of the specified file.

Parameters

fobjio.FileIO

The file object to compile kat script from. This should be opened in text mode.

modelModel, optional

An existing model to compile the contents of fobj into. If not specified, a new, empty model is created.

resolvebool, 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.

buildbool, 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

Model or None

If resolve and build are True, the model compiled from reading fobj; None otherwise.

Raises

KatSyntaxError

If a syntax error is present in the contents of fobj.

property script[source]
exception finesse.script.compiler.KatCycleError(script, cyclic_nodes)[source]

Bases: KatScriptError

Cyclic parameters.

exception finesse.script.compiler.KatDirectiveBuildError(error, directive, script, statement_node, adapter, graph, spec)[source]

Bases: KatDirectiveError

Error 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: KatScriptError

Error compiling a directive (either resolving or building).

exception finesse.script.compiler.KatIncorrectFormError(user_directive_token, script, spec)[source]

Bases: KatSyntaxError

Error 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: KatScriptError

Error during the building of a directive parameter.

exception finesse.script.compiler.KatParameterSelfReferenceException[source]

Bases: Exception

Indication that a parameter contains a self-reference that must be resolved later.