syside
Native Syside module for Python.
Internally, Syside uses snake_case for all non-type symbols, e.g. attributes and
functions, whereas the specification and the Pilot implementation both use camelCase
instead. snake_case was chosen because it integrates far better into Python -
the programming language that Syside uses.
Additionally, Syside does not use multiple inheritance to implement the standard model
and instead uses sum-types where appropriate (typing.Union in Python). This improves
performance as methods and attributes can be inlined and are not required to be accessed
through interfaces (no pointer chasing), reduces memory usage as unused members need not
be stored (e.g. Relationship interface for Associations), and improves usability
by allowing more flexible constraints on element types.
Usability is further improved by storing child elements in separate members based on
their position in the textual syntax. This is in comparison to the Pilot implementation,
which only uses two such members, ownedRelationship and ownedRelatedElement.
Syside implementation allows direct access to most special members without resorting to
filtering every time, improving performance. Moreover, modifying and inserting such
members does not require potentially expensive reshuffling of children arrays.
Lastly, because textual source files may contain syntax errors, all model elements may return optional elements, even if the corresponding attribute in the specification expects a non-null element. This also allows elements to be default constructible.
Additional Notes
For performance reasons, elements and their groups are stored as specific members in AST nodes based on their position in textual syntax which also makes mutation easier. Notably:
prefixes- group for metadata prefixes, prefixed with#in textual notationheritage- type specializations and conjugationstype_relationships- non-specialization type relationships appearing after specialization part, including feature chainingchildren- elements in the children block (in-between brackets{and}) in textual notation, and expression argumentsdeclared_ends,declared_messages- end features and messages before the children block. In the textual syntax they appear in the same position, hence in contrast to similar groups there are additionaltry_appendandtry_insertmethods that returnNonewithout throwing if modification failed because the slot is already occupied by either ends or messages.
Due to parser limitations, argument member references are parsed as argument members instead. This has little effect on analysis as intermediate
FeatureReferenceExpressionandOwningMembershipare excluded from the expression tree.Elements can only be owned nodes in the same document to satisfy tree constraints, elements can be referenced by any appropriate element. Violating this constraint raises
ValueError. Similarly, trying to steal ownership also raisesValueError.Relationship ends cannot generally be modified unless they are member elements, and only a few allow this dependent on the textual syntax (KerML only but there are currently no checks that models constructed are actually representable in chosen textual syntax beyond some simple checks during printing).
Model Modifications
Adding new owned or referenced Elements to a model can raise:
TypeError:if the relationship type is not allowed by the container/setter as this violates internal invariants.
if the element type is not allowed by the container/setter as this violates internal invariants.
if the element type is not allowed by the relationship as this violates internal invariants.
if the element is owned but the relationship instead only references related element to prevent orphan elements.
ValueError:if taking ownership of an element from another document as this violates internal invariants.
if stealing ownership of the element as there is no good default behaviour on what should happen, remove the element from the model first before trying to re-parent it.
RuntimeError:if the parent
Elementhas been removed from the model. This can be fixed by adding theElementback into the model as an owned element.
Index
Submodules
Various debugging related utilities. |
||
Labs |
Umbrella submodule for all experimental implementations. |
|
Internal GC interface. |
||
Submodule for IDE related functions. |
||
Labs |
Convenience module intending to match the standard library |
|
Structured access to Syside version |
||
Labs |
Module implementing various proposals for how to make the Syside API more convenient and easier to pick up. |
Classes
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for parameter action bodies |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for annotating element annotations |
||
A convencience accessor for instantiation arguments. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
The basic type of all AST nodes. |
||
SysML |
Implementation of |
|
Internal opaque type for deserialization attribute mapping |
||
SysML |
Implementation of |
|
A SysMLv2 model represented using abstract syntax. |
||
The base type of all documents corresponding to a single source file. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A cheap-to-constructor surrogate for metadata features |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Container that stores a vector of children nodes that may own feature chainings. |
||
A typed accessor for potentially unowned member features that may be also chained |
||
A typed accessor for feature reference that may also be chained |
||
An accessor for potentially unowned member features that may be also chained |
||
An accessor for reference that may also be chained |
||
A typed accessor for type reference that may also be chained |
||
Container that stores a vector of children nodes. |
||
A view to a container of children nodes. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for classifier reference |
||
Structure to capture a description for an error code. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Messages emitted during compilation or evaluation. |
||
A non-recursive compiler/virtual machine for KerML and SysML expressions. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for ends in |
||
An accessor for ends in |
||
An accessor for ends in connector declarations |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An immutable view into a native random-access container. Implements Sequence protocol. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A CST node |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for dependency |
||
An accessor for dependency metadata prefixes |
||
The model as it was deserialized, with references potentially unresolved. |
||
Deserializer for SysML models. The actual deserialization input depends on used |
||
LSP compatible diagnostic structure. |
||
Additional diagnostics context information for formatting. |
||
Diagnostic formatting style options |
||
A diagnostic providing information about a model. |
||
Represents a related message and source code location for a diagnostic. |
||
The collection of all diagnostics for a single document. |
||
All model diagnostics. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
KerML and SysML specific document type |
||
Strongly typed numerical document id |
||
Options to construct new document with |
||
Utf-8 based segment into a source text document. |
||
Stage times for a single document. |
||
Document version |
||
SysML |
Implementation of |
|
A typed accessor for transition effects |
||
SysML |
Implementation of |
|
A typed accessor for unowned member elements |
||
SysML |
Implementation of |
|
Percent-encoding options |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Standard library environment for use with user models. |
||
SysML |
Implementation of |
|
Schedule execution result |
||
Thread-pool executor used to run various multi-threaded tasks internally. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for parameter expression members |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for feature reference |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for feature value members |
||
Strongly typed CST field id |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Options used to control how model is pretty-printed structurally. |
||
Formatting option that can either be preserved from source, or overridden. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for transition guards |
||
An accessor for type specializations and conjugations |
||
An IO schedule that can be executed concurrently on an |
||
An IP version 4 style address. |
||
An IP version 6 style address. |
||
|
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A statically indexed symbol |
||
A cheap-to-construct marker for infinity ( |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Unbound reader for JSON deserialization |
||
Options for serialization writer to JSON strings |
||
Serialization writer that outputs JSON string |
||
A base type for all internally-iterated objects. |
||
Strongly typed numerical library id |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for specific member elements |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for messages in |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A SysMLv2 model represented using abstract syntax. |
||
An exception thrown when model contains errors. |
||
Pretty-printer for KerML/SysML models back to textual syntax. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for namespace body |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An accessor for namespace metadata prefixes |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Container that stores a vector of potentially owned children nodes. |
||
A typed accessor for multiplicity range bounds expression |
||
A typed accessor for some owned member features |
||
An accessor for specific owned member elements |
||
A typed accessor for multiplicity in |
||
A typed accessor for transition succession |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for some parameter members |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A subset of |
||
A sequence of path segments that stringifies with unrestricted names as needed. |
||
SysML |
Implementation of |
|
A typed accessor for flow payload features |
||
Reference that has yet to be linked. |
||
SysML |
Implementation of |
|
A language agnostic multithreaded parsing and analysis pipeline. |
||
Options for |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Utf-16 based text position |
||
Utf-32 based text position |
||
Utf-8 based text position |
||
SysML |
Implementation of |
|
Formatting options for pretty-printed models |
||
A sequence of qualified name segments that stringifies with unrestricted names as needed. |
||
Utf-16 based text range |
||
Utf-32 based text range |
||
Utf-8 based text range |
||
Abstract base class for all deserialization readers. |
||
SysML |
Implementation of |
|
A generic accessor for references in the model |
||
A typed accessor for various parameter members |
||
An opaque reference print function that will be called only for synthetic references. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for some reference usage members |
||
An accessor for feature reference expression referent member |
||
SysML |
Implementation of |
|
Container for relationship bodies. Works similarly to |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for function and expression result members |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for satisfaction subject of |
||
SysML |
Implementation of |
|
A schedule for parsing and analysis of documents. |
||
Signifies an error when attempting to schedule documents for analysis |
||
Options for a particular |
||
SysML |
Implementation of |
|
Semantic resolver for SysML. This is responsible for linking references and resolving semantic rules in the pipeline. |
||
SysML |
Implementation of |
|
Message emitted during (de)serialization |
||
(De)Serialization report containing emitted messages. |
||
Options for SysML model serialization. Attribute options are ordered in descending precedence. |
||
Serializer for SysML models. The actual serialization output depends on used |
||
Options for S-exp output |
||
A mutex-protected data |
||
SysML |
Implementation of |
|
Total times for each pipeline stage. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Strongly typed CST state id |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A static thread-safe index that allows multiple entries using the same name |
||
Cache of standard library elements used by sema. |
||
SysML |
Implementation of |
|
A type-erased iterable |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Strongly typed CST symbol id |
||
A typed accessor for target feature member in feature chain expressions |
||
SysML |
Implementation of |
|
A basic text document that holds source text and allows conversions between encoded text positions and byte offsets. |
||
Data used to initialize new text documents with. |
||
Utf-16 based text edit |
||
Utf-32 based text edit |
||
Utf-8 based text edit |
||
A thread-safe registry for |
||
A textual edit applicable to a text document. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A typed accessor for transition source |
||
SysML |
Implementation of |
|
A typed accessor for transition triggers |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
The type used in a type check expression, e.g. |
||
A typed accessor for type reference |
||
An accessor for type and feature relationships that are part of the declaration |
||
An error signifiying that a different reference was found while attempting to revert changes made by sema, and requiring manual intervention. |
||
SysML |
Implementation of |
|
|
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
A context manager for managing lock acquiry and release. |
||
Abstract base class for serialization writer implementations. |
Attributes
|
Marker to signal the deserializer that attributes are using internal names (snake_case). |
|
|
Marker to signal the deserializer that attributes are using standard names (camelCase). |
|
|
Generic |
|
|
Generic |
|
|
Generic type variable |
|
|
Generic type variable |
|
|
Generic |
|
|
Generic covariant type variable |
|
Expression evaluation result type. |
Functions
Build the AST for |
||
Collect and cache symbols exported by |
||
Recursively collect all |
||
Decode a filesystem path from a |
||
Convenience function for deserialization. Prefer using |
||
Format diagnostics to string. |
||
Get a default initialized |
||
Load a SysMLv2 model. |
||
Construct a |
||
Creates a combined pipeline for parsing and analysing both KerML and SysML documents. |
||
Prints model subtree starting at |
||
Precompute element IDs for a given |
||
Reset semantic state of |
||
Convenience function for serialization. Prefer using |
||
Generate a minimal S-expression of owned elements rooted at |
||
Load a SysMLv2 model. |
Enumerations
An option to |
||
Document build state |
||
The severity of the diagnostic |
||
Is this a model-created document? |
||
The state of a document inside of a pipeline. |
||
A document tier. |
||
Operator that can be declared explicitly, e.g. excluding |
||
Action taken when a serialization error is encountered. |
||
SysML |
Implementation of |
|
Synthetic float format |
||
The type of host in a URL. |
||
An implicit specialization kind that also depends on the type of the element. |
||
An option to print a non-word |
||
Possible formatted line endings |
||
Language used to parse/build the model |
||
Whether to place |
||
An option to control multiplicity range placement relative to declaration specializations. |
||
The identifier used to reference the element in the textual syntax. |
||
Preference for selecting identifiers when printing synthetic references. |
||
Whether to print null expressions as |
||
Any operator, including implicit operators |
||
Whether to place operators |
||
An option to |
||
An option to print a non-word |
||
An option to |
||
SysML |
Implementation of |
|
Syntax mode to print the model into. |
||
SysML |
Implementation of |
|
A known URL scheme. |
||
Semantic resolution state of |
||
SysML |
Implementation of |
|
Represents reasons why a text document is saved. |
||
SysML |
Implementation of |
|
Kind of glyphs to insert when formatting related information tree |
||
SysML |
Implementation of |
|
Cost threshold of validation rules to execute. |
||
SysML |
Implementation of |
|
A strongly typed explicit visitation operation |
Attributes
- DESERIALIZE_INTERNAL: syside.AttributeMap = Ellipsis
Marker to signal the deserializer that attributes are using internal names (snake_case).
- DESERIALIZE_STANDARD: syside.AttributeMap = Ellipsis
Marker to signal the deserializer that attributes are using standard names (camelCase).
- M = TypeVar("M", bound=syside.Element)
Generic
Elementtype variable
- R = TypeVar("R", bound=syside.Relationship)
Generic
Relationshiptype variable
- T = TypeVar("T")
Generic type variable
- TElement = TypeVar("TElement", bound=syside.Element)
Generic type variable
- TNode = TypeVar("TNode", bound=syside.AstNode)
Generic
AstNodetype variable
- U = TypeVar("U", covariant=True)
Generic covariant type variable
- type Value = int | float | bool | syside.Infinity | str | range | syside.Element | syside.BoundMetaclass | None | list[Value]
Expression evaluation result type.
May be:
int,float,bool,str, orNonefrom literal expressions, or expressions evaluated as suchInfinityfrom literal expressionsrangefrom range operator expressionsElementfrom reference or chain expressionsBoundMetaclassfrom metadata access expressionslistfrom sequence expressions
Functions
- build_model(document: syside.Document, language: syside.ModelLanguage | None = None) list[syside.Diagnostic]
Build the AST for
documentfrom itstext_document.Any existing model will be cleared, and the built model will not have its references linked. Instead, most references will use placeholder references that will be replaced by actual targets in linking stage. Only
sysmlandkermllanguages are supported.This is a CST -> AST stage in the pipeline.
Raises
ValueErrorif thedocumenthas unsupported language, or it has no associatedtext_document.
- collect_exports(document: syside.Document) int
Collect and cache symbols exported by
document. This must be called before thedocumentis indexed, otherwise wrong or no symbols may be indexed. Returns the number of symbols cached.
- collect_files_recursively(directory_path: str | os.PathLike[Any]) list[pathlib.Path]
Recursively collect all
.sysmland.kermlfiles in the specified directory.
- decode_path(arg0: syside.Url, options: syside.EncodingOpts = ...) str
Decode a filesystem path from a
Url.This correctly handles Windows and Posix paths using
file://scheme and returns otherUrlsas is.
- deserialize(document: syside.Document, reader: syside.Reader, attributes: syside.AttributeMap) tuple[syside.DeserializedModel, syside.SerdeReport[syside.DocumentSegment | str | syside.Element]]
Convenience function for deserialization. Prefer using
Deserializerto avoid allocations when doing repeated deserializations.
- format_diagnostics(errors: Sequence[syside.Diagnostic], context: syside.DiagnosticContext = ..., options: syside.DiagnosticFormatOptions = ...) str
Format diagnostics to string.
contextwill be used to add additional contextual information, like source snippets, to the formatted output.optionscontrol how the diagnostics are formatted.Note that this is subject to change in future releases.
- get_default_executor() syside.Executor
Get a default initialized
Executorfor running schedules. Default executor will use half the logical cores that are available on the current machine. An executor is just a thread pool so there is no reason for constructing and destroying one all the time.
- load_model(paths: Iterable[str | os.PathLike[Any]], *, environment: syside.Environment | None = None, sysml_source: str | None = None, kerml_source: str | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- load_model(*, sysml_source: str, kerml_source: str | None = ..., environment: syside.Environment | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- load_model(*, kerml_source: str, sysml_source: str | None = ..., environment: syside.Environment | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
Load a SysMLv2 model.
At least one of
paths,sysml_source, andkerml_sourcemust not be none.- Parameters:
paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (
.sysmlor.kerml).environment – The environment to be used for the model. If this parameter is left to
None, uses the default environment. sysml_source: A SysMLv2 source to be loaded as an in-memory file. kerml_source: A KerML source to be loaded as an in-memory file.attach_comments – if
True, source notes are attached to the model and preserved on formatting the model back to text
- Returns:
Model and Diagnostics pair.
- Raises:
ModelError – If returned diagnostics contain errors, or if
warnings_as_errorsisTrue, if diagnostics contain errors or warnings.
- make_file_url(arg0: str, options: syside.EncodingOpts = ...) syside.Url
Construct a
Urlfor a filesystem path with thefile:scheme.This correctly handles Windows and Posix paths, normalizes Windows drive letters to uppercase, and percent escapes Unicode characters.
- make_file_url(arg0: str | os.PathLike[AnyStr], options: syside.EncodingOpts = ...) syside.Url
- make_pipeline(arg: syside.PipelineOptions, /) syside.Pipeline
Creates a combined pipeline for parsing and analysing both KerML and SysML documents.
- pprint(arg0: syside.Element, printer: syside.ModelPrinter | None = None, config: syside.PrinterConfig = ...) str
Prints model subtree starting at
rootto textual syntax.NOTE This performs very little checking that the given model can be represented in textual syntax, besides checking for elements that are missing. This has no effect when used as a formatter on a model parsed without syntax errors but programmatic models are not guaranteed to be valid textual syntax. In addition, it does not check that references are reachable from their scopes so parsing the printed model can fail to find them again. Otherwise, clearly unreachable references, such as when one of their ancestors is anonymous, will raise errors.
Only the first import from any parent namespaces that would shorten the printed reference is used. This does not apply to imports themselves to prevent reference resolution errors due to multiple or cyclical imports. Additionally, references relative to left-hand side expression result types, such as those from
FeatureChainExpressions, are assumed to be directly or indirectly accessible so only their short or regular name is printed.
- precompute_element_ids(arg: syside.Document | syside.Element, /) None
Precompute element IDs for a given
DocumentorElementsubtree.This has complexity
O(n)for number of elements irrespective of tree depth and number of owned elements, and is far more efficient than generating element IDs lazily throughElement.element_id. Consider precomputing element IDs for documents that will be serialized to improve performance.A similar precomputation is performed on serialization, however its results are not persisted to the elements.
- sema_reset(element: syside.Element) None
Reset semantic state of
element.This will typically remove any implied relationships, and reverse a few other changes made by sema. After this completes,
element.sema_state == SemaState.None.
- sema_reset(document: syside.Document, reporter: Callable[[syside.Element, syside.UnexpectedDifferentReference], None] | None = None) None
Reset semantic state of
document.This will call
sema_reseton all owned elements, and additionally reset all resolved references back to unresolved state. While resetting references, if the resolved reference does not match the current reference,reporterwill be called with the element the reference applies to andUnexpectedDifferentReferencethat was found. By default,reporterwill print such errors tostderr.After this completes,
document.build_state == BuildState.Indexed.
- serialize(root: syside.Element, writer: syside.Writer[syside.T], options: syside.SerializationOptions = ...) syside.SerdeReport[syside.Element]
Convenience function for serialization. Prefer using
Serializerto avoid allocations when doing repeated serializations.
- serialize(root: syside.Element, writer: syside.Writer[syside.T], use_standard_names: bool = True, include_derived: bool = False, include_redefined: bool = False, include_default: bool = False, include_optional: bool = False, include_implied: bool = False, fail_action: syside.FailAction = FailAction.Diagnose) syside.SerdeReport[syside.Element]
- sexp(root: syside.Element, options: syside.SexpOptions = ...) str
Generate a minimal S-expression of owned elements rooted at
root, useful for debugging.
- sexp(root: syside.Element, indent: int = 2, include_implicit: bool = True, print_references: bool = False) str
- try_load_model(paths: Iterable[str | os.PathLike[Any]], *, environment: syside.Environment | None = None, sysml_source: str | None = None, kerml_source: str | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- try_load_model(paths: Iterable[str | os.PathLike[Any]], environment: syside.Environment) tuple[syside.Model, syside.Diagnostics]
- try_load_model(*, sysml_source: str, kerml_source: str | None = ..., environment: syside.Environment | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- try_load_model(*, kerml_source: str, sysml_source: str | None = ..., environment: syside.Environment | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
Load a SysMLv2 model.
At least one of
paths,sysml_source, andkerml_sourcemust not be none.- Parameters:
paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (
.sysmlor.kerml).environment – The environment to be used for the model. If this parameter is left to
None, uses the default environment.sysml_source – A SysMLv2 source to be loaded as an in-memory file.
kerml_source – A KerML source to be loaded as an in-memory file.
attach_comments – if
True, source notes are attached to the model and preserved on formatting the model back to text
- Returns:
Model and Diagnostics pair. Note that models may only be partial if parsing failed, however even a partial model may be of interest for analysis.
Enumerations
- class AlwaysNever
An option to
alwaysprinti some token, ornever. Used in
-
- class BuildState
Document build state
- class DiagnosticSeverity
The severity of the diagnostic
- class DocumentKind
Is this a model-created document?
MODELIs this a model-created document?
ENVIRONMENTIs this a model-created document?
ALLIs this a model-created document?
USERIs this a model-created document?
STDLIBIs this a model-created document?
Used in
- class DocumentState
The state of a document inside of a pipeline.
Created= 0
Document has been created
Building= 1
Document is being built
Completed= 2
Document was built successfully
Cancelled= 3
Document building was cancelled
Error= 4
Document building errored
Used in
- class DocumentTier
A document tier.
This is used internally to apply specific optimizations, mainly to standard library sources.
StandardLibraryDocument is a part of standard library. Assume that such documents change very rarely, or only change with new tool versions.
ExternalDocument is imported from a third-party library. Assume that they do not change unless the third-party library is updated.
ProjectDocument is a part of the current project and may be edited at any time.
- class ExplicitOperator
Operator that can be declared explicitly, e.g. excluding
select.IfNullCoalescingImpliesLogicalOrOrXorLogicalAndAndEqualsSameNotEqualsNotSameIsTypeHasTypeAtAtAtAsMetaLessLessEqualGreaterGreaterEqualRangePlusMinusMultiplyDivideModuloExponentStarExponentCaretConjugationNotAllQuantityComma Used in
- class FailAction
Action taken when a serialization error is encountered.
- class FeatureDirectionKind
SysML
Implementation of
FeatureDirectionKinddefined in the KerML specification.Specification:
FeatureDirectionKindenumerates the possible kinds ofdirectionthat aFeaturemay be given as a member of aType.For language description, see section 7.3.4.2 of the KerML specification. For more details on the model, see section 8.3.3.1.5 of the KerML specification.
- class FloatFormat
Synthetic float format
Used in
- class HostType
The type of host in a URL.
noneNo host is specified.
NameA host is specified by reg-name.
IPv4A host is specified by ipv4_address.
IPv6A host is specified by ipv6_address.
IPvFutureA host is specified by IPvFuture.
Used in
- class ImplicitSpecializationKind
An implicit specialization kind that also depends on the type of the element.
Note that not all
(type, kind)combinations are valid.AccessedFeatureActionTransitionAfterAnnotatedElementAssumptionAtBaseBaseTypeBinaryBinaryObjectCaseActorCheckedConstraintClassifierConcernDataValueDecisionDoEffectEnclosedPerformanceEntryExclusiveStateExitFeatureFeatureWriteFlowGuardIfThenElseIncomingTransferLifeLoopVariableMergeMessageNegatedObjectOccurrenceOwnedActionOwnedPerformanceOwnedPortParticipantPayloadPerformedActionPortionRequirementRequirementActorRequirementStakeholderSatisfiedSnapshotSourceOutputStartingAtStateTransitionSubAnalysisCaseSubUseCaseSubVerificationCaseSubactionSubcalculationSubcaseSubitemSubobjectSuboccurrenceSubpartSubperformanceSubportSubrenderingSubrequirementSubstateSubviewTargetTargetInputTimesliceTransitionLinkTriggerVerificationViewRenderingWhen Used in
- class KwToken
An option to print a non-word
token, or wordkeyword. Used in
- class LineEnd
Possible formatted line endings
Used in
- class ModelLanguage
Language used to parse/build the model
- class MultiOrder
Whether to place
ordered, ornonunique, first when printing multiplicity ranges.
- class MultiPlacement
An option to control multiplicity range placement relative to declaration specializations.
Used in
- class NameID
The identifier used to reference the element in the textual syntax.
This may be used to select the printed identifier for synthetic references when printing the model back to textual syntax.
Used in
- class NamePreference
Preference for selecting identifiers when printing synthetic references.
AutomaticImplementation defined name preference
RegularPrefer regular name, otherwise fall back to short name
ShortPrefer short name, otherwise fall back to regular name
ShortestPrefer shortest name
LongestPrefer longest name (for completeness)
Used in
- class NullFormat
Whether to print null expressions as
null, or(). Used in
- class Operator
Any operator, including implicit operators
IfNullCoalescingImpliesLogicalOrOrXorLogicalAndAndEqualsSameNotEqualsNotSameIsTypeHasTypeAtAtAtAsMetaLessLessEqualGreaterGreaterEqualRangePlusMinusMultiplyDivideModuloExponentStarExponentCaretConjugationNotAllQuantityCommaDotCollectIndexSelect
- class OperatorBreak
Whether to place operators
beforeline break, orafter. Used in
- class OptionalKw
An option to
alwaysprinti some token, oras-needed. Used in
-
- class OptionalKwToken
An option to print a non-word
token, wordkeyword, ornone.
- class OptionalToken
An option to
alwaysprint some token,neverprint, or printon-breakdue to line width limits.
- class PortionKind
SysML
Implementation of
PortionKinddefined in the SysML specification.Specification:
PortionKindis an enumeration of the specific kinds ofOccurrenceportions that can be represented by anOccurrenceUsage.For language description, see section 7.9.3 of the SysML specification. For more details on the model, see section 8.3.9.5 of the SysML specification.
- class PrintMode
Syntax mode to print the model into.
Used in
- class RequirementConstraintKind
SysML
Implementation of
RequirementConstraintKinddefined in the SysML specification.Specification:
A
RequirementConstraintKindindicates whether aConstraintUsageis an assumption or a requirement in aRequirementDefinitionorRequirementUsage.For language description, see section 7.21.2 of the SysML specification. For more details on the model, see section 8.3.21.6 of the SysML specification.
- class Scheme
A known URL scheme.
noneIndicates that no scheme is present
UnknownIndicates the scheme is not a well-known scheme
FtpFile Transfer Protocol (FTP)
FTP is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network.
FileFile URI Scheme
The File URI Scheme is typically used to retrieve files from within one’s own computer.
HttpThe Hypertext Transfer Protocol URI Scheme
URLs of this type indicate a resource which is interacted with using the HTTP protocol.
HttpsThe Secure Hypertext Transfer Protocol URI Scheme
URLs of this type indicate a resource which is interacted with using the Secure HTTP protocol.
WsThe WebSocket URI Scheme
URLs of this type indicate a resource which is interacted with using the WebSocket protocol.
WssThe Secure WebSocket URI Scheme
URLs of this type indicate a resource which is interacted with using the Secure WebSocket protocol.
Used in
- class SemaState
Semantic resolution state of
Elements.Sema will use this information to discard duplicate work, e.g. when resolving elements in a group of related documents.
Used in
- class StateSubactionKind
SysML
Implementation of
StateSubactionKinddefined in the SysML specification.Specification:
A
StateSubactionKindindicates whether theactionof a StateSubactionMembership is an entry, do or exit action.For language description, see section 7.18.2 of the SysML specification. For more details on the model, see section 8.3.18.3 of the SysML specification.
- class TextDocumentSaveReason
Represents reasons why a text document is saved.
- class TransitionFeatureKind
SysML
Implementation of
TransitionFeatureKinddefined in the SysML specification.Specification:
A
TransitionActionKindindicates whether thetransition_featureof aTransitionFeatureMembershipis a trigger, guard or effect.For language description, see section 7.18.3 of the SysML specification. For more details on the model, see section 8.3.18.7 of the SysML specification.
- class TreeDrawing
Kind of glyphs to insert when formatting related information tree
NoNo tree is drawn
AsciiUse ASCII symbols for drawing
UnicodeUse unicode symbols for drawing
Used in
- class TriggerKind
SysML
Implementation of
TriggerKinddefined in the SysML specification.Specification:
TriggerKindenumerates the kinds of triggers that can be represented by aTriggerInvocationExpression.For language description, see section 7.18.3 of the SysML specification. For more details on the model, see section 8.3.17.18 of the SysML specification.
- class ValidationTiming
Cost threshold of validation rules to execute.
OnTypeValidation rules will be executed on every key stroke.
OnSaveValidation rules will be executed on document save.
ManualValidation rules will be executed manually.
NeverNo validation rules will be executed
Used in
- class VisibilityKind
SysML
Implementation of
VisibilityKinddefined in the KerML specification.Specification:
VisibilityKindis an enumeration whose literals specify the visibility of aMembershipof anElementin aNamespaceoutside of thatNamespace. Note that “visibility” specifically restricts whether anElementin aNamespacemay be referenced by name from outside theNamespaceand only otherwise restricts access to anElementas provided by specific constraints in the abstract syntax (e.g., preventing the import or inheritance of privateElements).For language description, see section 7.2.5.2 of the KerML specification. For more details on the model, see section 8.3.2.4.7 of the KerML specification.
- class VisitAction
A strongly typed explicit visitation operation