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 notation

    • heritage - type specializations and conjugations

    • type_relationships - non-specialization type relationships appearing after specialization part, including feature chaining

    • children - elements in the children block (in-between brackets { and }) in textual notation, and expression arguments

    • declared_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 additional try_append and try_insert methods that return None without 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 FeatureReferenceExpression and OwningMembership are 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 raises ValueError.

  • 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 Element has been removed from the model. This can be fixed by adding the Element back into the model as an owned element.

Index

Submodules

debug

Various debugging related utilities.

experimental

Labs

Umbrella submodule for all experimental implementations.

gc

Internal GC interface.

ide

Submodule for IDE related functions.

json

Labs

Convenience module intending to match the standard library json module.

version

Structured access to Syside version

preview

Labs

Module implementing various proposals for how to make the Syside API more convenient and easier to pick up.

Classes

AcceptActionUsage

SysML

Implementation of AcceptActionUsage defined in the SysML specification.

ActionDefinition

SysML

Implementation of ActionDefinition defined in the SysML specification.

ActionParameterAccessor

A typed accessor for parameter action bodies

ActionUsage

SysML

Implementation of ActionUsage defined in the SysML specification.

ActorMembership

SysML

Implementation of ActorMembership defined in the SysML specification.

AllocationDefinition

SysML

Implementation of AllocationDefinition defined in the SysML specification.

AllocationUsage

SysML

Implementation of AllocationUsage defined in the SysML specification.

AnalysisCaseDefinition

SysML

Implementation of AnalysisCaseDefinition defined in the SysML specification.

AnalysisCaseUsage

SysML

Implementation of AnalysisCaseUsage defined in the SysML specification.

AnnotatingElement

SysML

Implementation of AnnotatingElement defined in the KerML specification.

Annotation

SysML

Implementation of Annotation defined in the KerML specification.

Annotations

An accessor for annotating element annotations

ArgumentsAccessor

A convencience accessor for instantiation arguments.

AssertConstraintUsage

SysML

Implementation of AssertConstraintUsage defined in the SysML specification.

AssignmentActionUsage

SysML

Implementation of AssignmentActionUsage defined in the SysML specification.

Association

SysML

Implementation of Association defined in the KerML specification.

AssociationStructure

SysML

Implementation of AssociationStructure defined in the KerML specification.

AstNode

The basic type of all AST nodes.

AttributeDefinition

SysML

Implementation of AttributeDefinition defined in the SysML specification.

AttributeMap

Internal opaque type for deserialization attribute mapping

AttributeUsage

SysML

Implementation of AttributeUsage defined in the SysML specification.

BaseModel

A SysMLv2 model represented using abstract syntax.

BasicDocument

The base type of all documents corresponding to a single source file.

Behavior

SysML

Implementation of Behavior defined in the KerML specification.

BindingConnector

SysML

Implementation of BindingConnector defined in the KerML specification.

BindingConnectorAsUsage

SysML

Implementation of BindingConnectorAsUsage defined in the SysML specification.

BooleanExpression

SysML

Implementation of BooleanExpression defined in the KerML specification.

BoundMetaclass

A cheap-to-constructor surrogate for metadata features

CalculationDefinition

SysML

Implementation of CalculationDefinition defined in the SysML specification.

CalculationUsage

SysML

Implementation of CalculationUsage defined in the SysML specification.

CaseDefinition

SysML

Implementation of CaseDefinition defined in the SysML specification.

CaseUsage

SysML

Implementation of CaseUsage defined in the SysML specification.

ChainedChildrenNodes

Container that stores a vector of children nodes that may own feature chainings.

ChainedFeatureMemberAccessor

A typed accessor for potentially unowned member features that may be also chained

ChainedFeatureReference

A typed accessor for feature reference that may also be chained

ChainedMemberAccessor

An accessor for potentially unowned member features that may be also chained

ChainedReferenceAccessor

An accessor for reference that may also be chained

ChainedTypeReference

A typed accessor for type reference that may also be chained

ChildrenNodes

Container that stores a vector of children nodes.

ChildrenNodesView

A view to a container of children nodes.

Class

SysML

Implementation of Class defined in the KerML specification.

Classifier

SysML

Implementation of Classifier defined in the KerML specification.

ClassifierReference

A typed accessor for classifier reference

CodeDescription

Structure to capture a description for an error code.

CollectExpression

SysML

Implementation of CollectExpression defined in the KerML specification.

Comment

SysML

Implementation of Comment defined in the KerML specification.

CompilationReport

Messages emitted during compilation or evaluation.

Compiler

A non-recursive compiler/virtual machine for KerML and SysML expressions.

ConcernDefinition

SysML

Implementation of ConcernDefinition defined in the SysML specification.

ConcernUsage

SysML

Implementation of ConcernUsage defined in the SysML specification.

ConjugatedPortDefinition

SysML

Implementation of ConjugatedPortDefinition defined in the SysML specification.

ConjugatedPortTyping

SysML

Implementation of ConjugatedPortTyping defined in the SysML specification.

Conjugation

SysML

Implementation of Conjugation defined in the KerML specification.

ConnectionDefinition

SysML

Implementation of ConnectionDefinition defined in the SysML specification.

ConnectionUsage

SysML

Implementation of ConnectionUsage defined in the SysML specification.

Connector

SysML

Implementation of Connector defined in the KerML specification.

ConnectorAsUsage

SysML

Implementation of ConnectorAsUsage defined in the SysML specification.

ConnectorAsUsageEnds

An accessor for ends in ConnectorAsUsage declaration

ConnectorEnds

An accessor for ends in Connector declaration

ConnectorEndsAccessor

An accessor for ends in connector declarations

ConstraintDefinition

SysML

Implementation of ConstraintDefinition defined in the SysML specification.

ConstraintUsage

SysML

Implementation of ConstraintUsage defined in the SysML specification.

ConstructorExpression

SysML

Implementation of ConstructorExpression defined in the KerML specification.

ContainerView

An immutable view into a native random-access container. Implements Sequence protocol.

ControlNode

SysML

Implementation of ControlNode defined in the SysML specification.

CrossSubsetting

SysML

Implementation of CrossSubsetting defined in the KerML specification.

CstNode

A CST node

DataType

SysML

Implementation of DataType defined in the KerML specification.

DecisionNode

SysML

Implementation of DecisionNode defined in the SysML specification.

Definition

SysML

Implementation of Definition defined in the SysML specification.

Dependency

SysML

Implementation of Dependency defined in the KerML specification.

DependencyEnds

An accessor for dependency client and supplier references.

DependencyPrefixes

An accessor for dependency metadata prefixes

DeserializedModel

The model as it was deserialized, with references potentially unresolved.

Deserializer

Deserializer for SysML models. The actual deserialization input depends on used Reader.

Diagnostic

LSP compatible diagnostic structure.

DiagnosticContext

Additional diagnostics context information for formatting.

DiagnosticFormatOptions

Diagnostic formatting style options

DiagnosticMessage

A diagnostic providing information about a model.

DiagnosticRelatedInformation

Represents a related message and source code location for a diagnostic.

DiagnosticResults

The collection of all diagnostics for a single document.

Diagnostics

All model diagnostics.

Differencing

SysML

Implementation of Differencing defined in the KerML specification.

Disjoining

SysML

Implementation of Disjoining defined in the KerML specification.

Document

KerML and SysML specific document type

DocumentID

Strongly typed numerical document id

DocumentOptions

Options to construct new document with

DocumentSegment

Utf-8 based segment into a source text document.

DocumentTimes

Stage times for a single document.

DocumentVersion

Document version (source, sema) pair.

Documentation

SysML

Implementation of Documentation defined in the KerML specification.

EffectAccessor

A typed accessor for transition effects

Element

SysML

Implementation of Element defined in the KerML specification.

ElementAccessor

A typed accessor for unowned member elements

ElementFilterMembership

SysML

Implementation of ElementFilterMembership defined in the KerML specification.

EncodingOpts

Percent-encoding options

EndFeatureMembership

SysML

Implementation of EndFeatureMembership defined in the KerML specification.

EnumerationDefinition

SysML

Implementation of EnumerationDefinition defined in the SysML specification.

EnumerationUsage

SysML

Implementation of EnumerationUsage defined in the SysML specification.

Environment

Standard library environment for use with user models.

EventOccurrenceUsage

SysML

Implementation of EventOccurrenceUsage defined in the SysML specification.

ExecutionResult

Schedule execution result

Executor

Thread-pool executor used to run various multi-threaded tasks internally.

ExhibitStateUsage

SysML

Implementation of ExhibitStateUsage defined in the SysML specification.

Expose

SysML

Implementation of Expose defined in the SysML specification.

Expression

SysML

Implementation of Expression defined in the KerML specification.

ExpressionParameterAccessor

A typed accessor for parameter expression members

Feature

SysML

Implementation of Feature defined in the KerML specification.

FeatureChainExpression

SysML

Implementation of FeatureChainExpression defined in the KerML specification.

FeatureChaining

SysML

Implementation of FeatureChaining defined in the KerML specification.

FeatureInverting

SysML

Implementation of FeatureInverting defined in the KerML specification.

FeatureMembership

SysML

Implementation of FeatureMembership defined in the KerML specification.

FeatureReference

A typed accessor for feature reference

FeatureReferenceExpression

SysML

Implementation of FeatureReferenceExpression defined in the KerML specification.

FeatureTyping

SysML

Implementation of FeatureTyping defined in the KerML specification.

FeatureValue

SysML

Implementation of FeatureValue defined in the KerML specification.

FeatureValueAccessor

A typed accessor for feature value members

FieldId

Strongly typed CST field id

Flow

SysML

Implementation of Flow defined in the KerML specification.

FlowDefinition

SysML

Implementation of FlowDefinition defined in the SysML specification.

FlowEnd

SysML

Implementation of FlowEnd defined in the KerML specification.

FlowUsage

SysML

Implementation of FlowUsage defined in the SysML specification.

ForLoopActionUsage

SysML

Implementation of ForLoopActionUsage defined in the SysML specification.

ForkNode

SysML

Implementation of ForkNode defined in the SysML specification.

FormatOptions

Options used to control how model is pretty-printed structurally.

FormatPreserved

Formatting option that can either be preserved from source, or overridden.

FramedConcernMembership

SysML

Implementation of FramedConcernMembership defined in the SysML specification.

Function

SysML

Implementation of Function defined in the KerML specification.

GuardAccessor

A typed accessor for transition guards

Heritage

An accessor for type specializations and conjugations

IOSchedule

An IO schedule that can be executed concurrently on an Executor.

IPv4Address

An IP version 4 style address.

IPv6Address

An IP version 6 style address.

IdMap

DeserializedModel compatible mapping for elements. This will typically be used for linking pending references:

IfActionUsage

SysML

Implementation of IfActionUsage defined in the SysML specification.

Import

SysML

Implementation of Import defined in the KerML specification.

IncludeUseCaseUsage

SysML

Implementation of IncludeUseCaseUsage defined in the SysML specification.

IndexExpression

SysML

Implementation of IndexExpression defined in the KerML specification.

IndexedSymbol

A statically indexed symbol

Infinity

A cheap-to-construct marker for infinity (* in KerML/SysML)

InstantiationExpression

SysML

Implementation of InstantiationExpression defined in the KerML specification.

Interaction

SysML

Implementation of Interaction defined in the KerML specification.

InterfaceDefinition

SysML

Implementation of InterfaceDefinition defined in the SysML specification.

InterfaceUsage

SysML

Implementation of InterfaceUsage defined in the SysML specification.

Intersecting

SysML

Implementation of Intersecting defined in the KerML specification.

Invariant

SysML

Implementation of Invariant defined in the KerML specification.

InvocationExpression

SysML

Implementation of InvocationExpression defined in the KerML specification.

ItemDefinition

SysML

Implementation of ItemDefinition defined in the SysML specification.

ItemUsage

SysML

Implementation of ItemUsage defined in the SysML specification.

JoinNode

SysML

Implementation of JoinNode defined in the SysML specification.

JsonReader

Unbound reader for JSON deserialization

JsonStringOptions

Options for serialization writer to JSON strings

JsonStringWriter

Serialization writer that outputs JSON string

LazyIterator

A base type for all internally-iterated objects.

LibraryID

Strongly typed numerical library id

LibraryPackage

SysML

Implementation of LibraryPackage defined in the KerML specification.

LiteralBoolean

SysML

Implementation of LiteralBoolean defined in the KerML specification.

LiteralExpression

SysML

Implementation of LiteralExpression defined in the KerML specification.

LiteralInfinity

SysML

Implementation of LiteralInfinity defined in the KerML specification.

LiteralInteger

SysML

Implementation of LiteralInteger defined in the KerML specification.

LiteralRational

SysML

Implementation of LiteralRational defined in the KerML specification.

LiteralString

SysML

Implementation of LiteralString defined in the KerML specification.

LoopActionUsage

SysML

Implementation of LoopActionUsage defined in the SysML specification.

MemberAccessor

An accessor for specific member elements

Membership

SysML

Implementation of Membership defined in the KerML specification.

MembershipExpose

SysML

Implementation of MembershipExpose defined in the SysML specification.

MembershipImport

SysML

Implementation of MembershipImport defined in the KerML specification.

MergeNode

SysML

Implementation of MergeNode defined in the SysML specification.

Messages

An accessor for messages in FlowUsage declaration

Metaclass

SysML

Implementation of Metaclass defined in the KerML specification.

MetadataAccessExpression

SysML

Implementation of MetadataAccessExpression defined in the KerML specification.

MetadataDefinition

SysML

Implementation of MetadataDefinition defined in the SysML specification.

MetadataFeature

SysML

Implementation of MetadataFeature defined in the KerML specification.

MetadataUsage

SysML

Implementation of MetadataUsage defined in the SysML specification.

Model

A SysMLv2 model represented using abstract syntax.

ModelError

An exception thrown when model contains errors.

ModelPrinter

Pretty-printer for KerML/SysML models back to textual syntax.

Multiplicity

SysML

Implementation of Multiplicity defined in the KerML specification.

MultiplicityRange

SysML

Implementation of MultiplicityRange defined in the KerML specification.

Namespace

SysML

Implementation of Namespace defined in the KerML specification.

NamespaceBody

An accessor for namespace body

NamespaceExpose

SysML

Implementation of NamespaceExpose defined in the SysML specification.

NamespaceImport

SysML

Implementation of NamespaceImport defined in the KerML specification.

NamespacePrefixes

An accessor for namespace metadata prefixes

NullExpression

SysML

Implementation of NullExpression defined in the KerML specification.

ObjectiveMembership

SysML

Implementation of ObjectiveMembership defined in the SysML specification.

OccurrenceDefinition

SysML

Implementation of OccurrenceDefinition defined in the SysML specification.

OccurrenceUsage

SysML

Implementation of OccurrenceUsage defined in the SysML specification.

OperatorExpression

SysML

Implementation of OperatorExpression defined in the KerML specification.

OwnedChildrenNodes

Container that stores a vector of potentially owned children nodes.

OwnedExpressionAccessor

A typed accessor for multiplicity range bounds expression

OwnedFeatureAccessor

A typed accessor for some owned member features

OwnedMemberAccessor

An accessor for specific owned member elements

OwnedMultiplicityAccessor

A typed accessor for multiplicity in Type declaration

OwnedSuccessionAccessor

A typed accessor for transition succession

OwningMembership

SysML

Implementation of OwningMembership defined in the KerML specification.

Package

SysML

Implementation of Package defined in the KerML specification.

ParameterAccessor

A typed accessor for some parameter members

ParameterMembership

SysML

Implementation of ParameterMembership defined in the KerML specification.

PartDefinition

SysML

Implementation of PartDefinition defined in the SysML specification.

PartUsage

SysML

Implementation of PartUsage defined in the SysML specification.

PartialTextDocumentData

A subset of TextDocumentData for opening a new text document when one was not found

Path

A sequence of path segments that stringifies with unrestricted names as needed.

PayloadFeature

SysML

Implementation of PayloadFeature defined in the KerML specification.

PayloadFeatureAccessor

A typed accessor for flow payload features

PendingReference

Reference that has yet to be linked.

PerformActionUsage

SysML

Implementation of PerformActionUsage defined in the SysML specification.

Pipeline

A language agnostic multithreaded parsing and analysis pipeline.

PipelineOptions

Options for Pipeline construction.

PortConjugation

SysML

Implementation of PortConjugation defined in the SysML specification.

PortDefinition

SysML

Implementation of PortDefinition defined in the SysML specification.

PortUsage

SysML

Implementation of PortUsage defined in the SysML specification.

PositionUtf16

Utf-16 based text position

PositionUtf32

Utf-32 based text position

PositionUtf8

Utf-8 based text position

Predicate

SysML

Implementation of Predicate defined in the KerML specification.

PrinterConfig

Formatting options for pretty-printed models

QualifiedName

A sequence of qualified name segments that stringifies with unrestricted names as needed.

RangeUtf16

Utf-16 based text range

RangeUtf32

Utf-32 based text range

RangeUtf8

Utf-8 based text range

Reader

Abstract base class for all deserialization readers.

Redefinition

SysML

Implementation of Redefinition defined in the KerML specification.

ReferenceAccessor

A generic accessor for references in the model

ReferenceParameterAccessor

A typed accessor for various parameter members

ReferencePrinter

An opaque reference print function that will be called only for synthetic references.

ReferenceSubsetting

SysML

Implementation of ReferenceSubsetting defined in the KerML specification.

ReferenceUsage

SysML

Implementation of ReferenceUsage defined in the SysML specification.

ReferenceUsageAccessor

A typed accessor for some reference usage members

ReferentAccessor

An accessor for feature reference expression referent member

Relationship

SysML

Implementation of Relationship defined in the KerML specification.

RelationshipBody

Container for relationship bodies. Works similarly to ChildrenNodes except relationships are not needed and all elements are taken ownership off.

RenderingDefinition

SysML

Implementation of RenderingDefinition defined in the SysML specification.

RenderingUsage

SysML

Implementation of RenderingUsage defined in the SysML specification.

RequirementConstraintMembership

SysML

Implementation of RequirementConstraintMembership defined in the SysML specification.

RequirementDefinition

SysML

Implementation of RequirementDefinition defined in the SysML specification.

RequirementUsage

SysML

Implementation of RequirementUsage defined in the SysML specification.

RequirementVerificationMembership

SysML

Implementation of RequirementVerificationMembership defined in the SysML specification.

ResultExpressionAccessor

A typed accessor for function and expression result members

ResultExpressionMembership

SysML

Implementation of ResultExpressionMembership defined in the KerML specification.

ReturnParameterMembership

SysML

Implementation of ReturnParameterMembership defined in the KerML specification.

SatisfactionSubjectAccessor

A typed accessor for satisfaction subject of SatisfyRequirementUsage.

SatisfyRequirementUsage

SysML

Implementation of SatisfyRequirementUsage defined in the SysML specification.

Schedule

A schedule for parsing and analysis of documents.

ScheduleError

Signifies an error when attempting to schedule documents for analysis

ScheduleOptions

Options for a particular Schedule.

SelectExpression

SysML

Implementation of SelectExpression defined in the KerML specification.

Sema

Semantic resolver for SysML. This is responsible for linking references and resolving semantic rules in the pipeline.

SendActionUsage

SysML

Implementation of SendActionUsage defined in the SysML specification.

SerdeMessage

Message emitted during (de)serialization

SerdeReport

(De)Serialization report containing emitted messages.

SerializationOptions

Options for SysML model serialization. Attribute options are ordered in descending precedence.

Serializer

Serializer for SysML models. The actual serialization output depends on used Writer.

SexpOptions

Options for S-exp output

SharedMutex

A mutex-protected data

Specialization

SysML

Implementation of Specialization defined in the KerML specification.

StageTimes

Total times for each pipeline stage.

StakeholderMembership

SysML

Implementation of StakeholderMembership defined in the SysML specification.

StateDefinition

SysML

Implementation of StateDefinition defined in the SysML specification.

StateId

Strongly typed CST state id

StateSubactionMembership

SysML

Implementation of StateSubactionMembership defined in the SysML specification.

StateUsage

SysML

Implementation of StateUsage defined in the SysML specification.

StaticIndex

A static thread-safe index that allows multiple entries using the same name

Stdlib

Cache of standard library elements used by sema.

Step

SysML

Implementation of Step defined in the KerML specification.

Stream

A type-erased iterable

Structure

SysML

Implementation of Structure defined in the KerML specification.

Subclassification

SysML

Implementation of Subclassification defined in the KerML specification.

SubjectMembership

SysML

Implementation of SubjectMembership defined in the SysML specification.

Subsetting

SysML

Implementation of Subsetting defined in the KerML specification.

Succession

SysML

Implementation of Succession defined in the KerML specification.

SuccessionAsUsage

SysML

Implementation of SuccessionAsUsage defined in the SysML specification.

SuccessionFlow

SysML

Implementation of SuccessionFlow defined in the KerML specification.

SuccessionFlowUsage

SysML

Implementation of SuccessionFlowUsage defined in the SysML specification.

Symbol

Strongly typed CST symbol id

TargetFeatureAccessor

A typed accessor for target feature member in feature chain expressions

TerminateActionUsage

SysML

Implementation of TerminateActionUsage defined in the SysML specification.

TextDocument

A basic text document that holds source text and allows conversions between encoded text positions and byte offsets.

TextDocumentData

Data used to initialize new text documents with.

TextDocumentEditUtf16

Utf-16 based text edit

TextDocumentEditUtf32

Utf-32 based text edit

TextDocumentEditUtf8

Utf-8 based text edit

TextDocuments

A thread-safe registry for TextDocuments.

TextEdit

A textual edit applicable to a text document.

TextualRepresentation

SysML

Implementation of TextualRepresentation defined in the KerML specification.

TransitionFeatureMembership

SysML

Implementation of TransitionFeatureMembership defined in the SysML specification.

TransitionSourceAccessor

A typed accessor for transition source

TransitionUsage

SysML

Implementation of TransitionUsage defined in the SysML specification.

TriggerAccessor

A typed accessor for transition triggers

TriggerInvocationExpression

SysML

Implementation of TriggerInvocationExpression defined in the SysML specification.

Type

SysML

Implementation of Type defined in the KerML specification.

TypeFeaturing

SysML

Implementation of TypeFeaturing defined in the KerML specification.

TypeGuard

The type used in a type check expression, e.g. istype, hastype.

TypeReference

A typed accessor for type reference

TypeRelationships

An accessor for type and feature relationships that are part of the declaration

UnexpectedDifferentReference

An error signifiying that a different reference was found while attempting to revert changes made by sema, and requiring manual intervention.

Unioning

SysML

Implementation of Unioning defined in the KerML specification.

Url

URL as described using the Uniform Resource Identifier (URI) specification (RFC3986).

Usage

SysML

Implementation of Usage defined in the SysML specification.

UseCaseDefinition

SysML

Implementation of UseCaseDefinition defined in the SysML specification.

UseCaseUsage

SysML

Implementation of UseCaseUsage defined in the SysML specification.

VariantMembership

SysML

Implementation of VariantMembership defined in the SysML specification.

VerificationCaseDefinition

SysML

Implementation of VerificationCaseDefinition defined in the SysML specification.

VerificationCaseUsage

SysML

Implementation of VerificationCaseUsage defined in the SysML specification.

ViewDefinition

SysML

Implementation of ViewDefinition defined in the SysML specification.

ViewRenderingMembership

SysML

Implementation of ViewRenderingMembership defined in the SysML specification.

ViewUsage

SysML

Implementation of ViewUsage defined in the SysML specification.

ViewpointDefinition

SysML

Implementation of ViewpointDefinition defined in the SysML specification.

ViewpointUsage

SysML

Implementation of ViewpointUsage defined in the SysML specification.

WhileLoopActionUsage

SysML

Implementation of WhileLoopActionUsage defined in the SysML specification.

WriteLocked

A context manager for managing lock acquiry and release.

Writer

Abstract base class for serialization writer implementations.

Attributes

DESERIALIZE_INTERNAL

R

Marker to signal the deserializer that attributes are using internal names (snake_case).

DESERIALIZE_STANDARD

R

Marker to signal the deserializer that attributes are using standard names (camelCase).

M

R

Generic Element type variable

R

R

Generic Relationship type variable

T

R

Generic type variable

TElement

R

Generic type variable

TNode

R

Generic AstNode type variable

U

R

Generic covariant type variable

Value

Expression evaluation result type.

Functions

build_model

Build the AST for document from its text_document.

collect_exports

Collect and cache symbols exported by document. This must be called before the document is indexed, otherwise wrong or no symbols may be indexed. Returns the number of symbols cached.

collect_files_recursively

Recursively collect all .sysml and .kerml files in the specified directory.

decode_path

Decode a filesystem path from a Url.

deserialize

Convenience function for deserialization. Prefer using Deserializer to avoid allocations when doing repeated deserializations.

format_diagnostics

Format diagnostics to string.

get_default_executor

Get a default initialized Executor for 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

Load a SysMLv2 model.

make_file_url

Construct a Url for a filesystem path with the file: scheme.

make_pipeline

Creates a combined pipeline for parsing and analysing both KerML and SysML documents.

pprint

Prints model subtree starting at root to textual syntax.

precompute_element_ids

Precompute element IDs for a given Document or Element subtree.

sema_reset

Reset semantic state of element.

serialize

Convenience function for serialization. Prefer using Serializer to avoid allocations when doing repeated serializations.

sexp

Generate a minimal S-expression of owned elements rooted at root, useful for debugging.

try_load_model

Load a SysMLv2 model.

Enumerations

AlwaysNever

An option to always printi some token, or never.

BuildState

Document build state

DiagnosticSeverity

The severity of the diagnostic

DocumentKind

Is this a model-created document?

DocumentState

The state of a document inside of a pipeline.

DocumentTier

A document tier.

ExplicitOperator

Operator that can be declared explicitly, e.g. excluding select.

FailAction

Action taken when a serialization error is encountered.

FeatureDirectionKind

SysML

Implementation of FeatureDirectionKind defined in the KerML specification.

FloatFormat

Synthetic float format

HostType

The type of host in a URL.

ImplicitSpecializationKind

An implicit specialization kind that also depends on the type of the element.

KwToken

An option to print a non-word token, or word keyword.

LineEnd

Possible formatted line endings

ModelLanguage

Language used to parse/build the model

MultiOrder

Whether to place ordered, or nonunique, first when printing multiplicity ranges.

MultiPlacement

An option to control multiplicity range placement relative to declaration specializations.

NameID

The identifier used to reference the element in the textual syntax.

NamePreference

Preference for selecting identifiers when printing synthetic references.

NullFormat

Whether to print null expressions as null, or ().

Operator

Any operator, including implicit operators

OperatorBreak

Whether to place operators before line break, or after.

OptionalKw

An option to always printi some token, or as-needed.

OptionalKwToken

An option to print a non-word token, word keyword, or none.

OptionalToken

An option to always print some token, never print, or print on-break due to line width limits.

PortionKind

SysML

Implementation of PortionKind defined in the SysML specification.

PrintMode

Syntax mode to print the model into.

RequirementConstraintKind

SysML

Implementation of RequirementConstraintKind defined in the SysML specification.

Scheme

A known URL scheme.

SemaState

Semantic resolution state of Elements.

StateSubactionKind

SysML

Implementation of StateSubactionKind defined in the SysML specification.

TextDocumentSaveReason

Represents reasons why a text document is saved.

TransitionFeatureKind

SysML

Implementation of TransitionFeatureKind defined in the SysML specification.

TreeDrawing

Kind of glyphs to insert when formatting related information tree

TriggerKind

SysML

Implementation of TriggerKind defined in the SysML specification.

ValidationTiming

Cost threshold of validation rules to execute.

VisibilityKind

SysML

Implementation of VisibilityKind defined in the KerML specification.

VisitAction

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 Element type variable

R = TypeVar("R", bound=syside.Relationship)

Generic Relationship type variable

T = TypeVar("T")

Generic type variable

TElement = TypeVar("TElement", bound=syside.Element)

Generic type variable

TNode = TypeVar("TNode", bound=syside.AstNode)

Generic AstNode type 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, or None from literal expressions, or expressions evaluated as such

  • Infinity from literal expressions

  • range from range operator expressions

  • Element from reference or chain expressions

  • BoundMetaclass from metadata access expressions

  • list from sequence expressions

Used in

󰊕 Functions

build_model(document: syside.Document, language: syside.ModelLanguage | None = None) list[syside.Diagnostic]

Build the AST for document from its text_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 sysml and kerml languages are supported.

This is a CST -> AST stage in the pipeline.

Raises ValueError if the document has unsupported language, or it has no associated text_document.

collect_exports(document: syside.Document) int

Collect and cache symbols exported by document. This must be called before the document is 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 .sysml and .kerml files 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 other Urls as 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 Deserializer to avoid allocations when doing repeated deserializations.

format_diagnostics(errors: Sequence[syside.Diagnostic], context: syside.DiagnosticContext = ..., options: syside.DiagnosticFormatOptions = ...) str

Format diagnostics to string.

context will be used to add additional contextual information, like source snippets, to the formatted output. options control how the diagnostics are formatted.

Note that this is subject to change in future releases.

get_default_executor() syside.Executor

Get a default initialized Executor for 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, and kerml_source must not be none.

Parameters:
  • paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (.sysml or .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_errors is True, if diagnostics contain errors or warnings.

make_file_url(arg0: str, options: syside.EncodingOpts = ...) syside.Url

Construct a Url for a filesystem path with the file: 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 root to 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 Document or Element subtree.

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 through Element.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_reset on 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, reporter will be called with the element the reference applies to and UnexpectedDifferentReference that was found. By default, reporter will print such errors to stderr.

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 Serializer to 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, and kerml_source must not be none.

Parameters:
  • paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (.sysml or .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 always printi some token, or never.

Used in
class BuildState

Document build state

= 0

Document has only been created

= 1

Document content has changed

= 2

Document content was parsed

= 3

Document global and local exports have been indexed

= 4

Model has been built and linked

= 5

Model has been validated

Used in
class DiagnosticSeverity

The severity of the diagnostic

= 1

= 2

= 3

= 4

Used in
class DocumentKind

Is this a model-created document?

Is this a model-created document?

Is this a model-created document?

Is this a model-created document?

Is this a model-created document?

Is this a model-created document?

Used in
class DocumentState

The state of a document inside of a pipeline.

= 0

Document has been created

= 1

Document is being built

= 2

Document was built successfully

= 3

Document building was cancelled

= 4

Document building errored

Used in
class DocumentTier

A document tier.

This is used internally to apply specific optimizations, mainly to standard library sources.

Document is a part of standard library. Assume that such documents change very rarely, or only change with new tool versions.

Document is imported from a third-party library. Assume that they do not change unless the third-party library is updated.

Document is a part of the current project and may be edited at any time.

Used in
class ExplicitOperator

Operator that can be declared explicitly, e.g. excluding select.

Used in
class FailAction

Action taken when a serialization error is encountered.

Stop serialization on the first error.

Continue diagnosing errors but stop serialization.

Ignore errors and continue serialization.

Used in
class FeatureDirectionKind

SysML

Implementation of FeatureDirectionKind defined in the KerML specification.

Specification:

FeatureDirectionKind enumerates the possible kinds of direction that a Feature may be given as a member of a Type.

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.

Used in
class FloatFormat

Synthetic float format

Used in
class HostType

The type of host in a URL.

No host is specified.

A host is specified by reg-name.

A host is specified by ipv4_address.

A host is specified by ipv6_address.

A 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.

Entry

Used in
class KwToken

An option to print a non-word token, or word keyword.

Used in
class LineEnd

Possible formatted line endings

Use \n line ends (Posix)

Use \r\n line ends (Windows)

Used in
class ModelLanguage

Language used to parse/build the model

Used in
class MultiOrder

Whether to place ordered, or nonunique, first when printing multiplicity ranges.

Used in
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.

Reference element by its regular ID

Reference element by its short ID

Used in
class NamePreference

Preference for selecting identifiers when printing synthetic references.

Implementation defined name preference

Prefer regular name, otherwise fall back to short name

Prefer short name, otherwise fall back to regular name

Prefer shortest name

Prefer 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

Used in
class OperatorBreak

Whether to place operators before line break, or after.

Used in
class OptionalKw

An option to always printi some token, or as-needed.

Used in
class OptionalKwToken

An option to print a non-word token, word keyword, or none.

Used in
class OptionalToken

An option to always print some token, never print, or print on-break due to line width limits.

Used in
class PortionKind

SysML

Implementation of PortionKind defined in the SysML specification.

Specification:

PortionKind is an enumeration of the specific kinds of Occurrence portions that can be represented by an OccurrenceUsage.

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.

Used in
class PrintMode

Syntax mode to print the model into.

Print model back to KerML syntax.

Print model back to SysML syntax.

Used in
class RequirementConstraintKind

SysML

Implementation of RequirementConstraintKind defined in the SysML specification.

Specification:

A RequirementConstraintKind indicates whether a ConstraintUsage is an assumption or a requirement in a RequirementDefinition or RequirementUsage.

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.

Used in
class Scheme

A known URL scheme.

Indicates that no scheme is present

Indicates the scheme is not a well-known scheme

File 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.

File URI Scheme

The File URI Scheme is typically used to retrieve files from within one’s own computer.

The Hypertext Transfer Protocol URI Scheme

URLs of this type indicate a resource which is interacted with using the HTTP protocol.

The Secure Hypertext Transfer Protocol URI Scheme

URLs of this type indicate a resource which is interacted with using the Secure HTTP protocol.

The WebSocket URI Scheme

URLs of this type indicate a resource which is interacted with using the WebSocket protocol.

The 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 StateSubactionKind defined in the SysML specification.

Specification:

A StateSubactionKind indicates whether the action of 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.

Entry

Used in
class TextDocumentSaveReason

Represents reasons why a text document is saved.

Used in
class TransitionFeatureKind

SysML

Implementation of TransitionFeatureKind defined in the SysML specification.

Specification:

A TransitionActionKind indicates whether the transition_feature of a TransitionFeatureMembership is 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.

Used in
class TreeDrawing

Kind of glyphs to insert when formatting related information tree

No tree is drawn

Use ASCII symbols for drawing

Use unicode symbols for drawing

Used in
class TriggerKind

SysML

Implementation of TriggerKind defined in the SysML specification.

Specification:

TriggerKind enumerates the kinds of triggers that can be represented by a TriggerInvocationExpression.

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.

Used in
class ValidationTiming

Cost threshold of validation rules to execute.

Validation rules will be executed on every key stroke.

Validation rules will be executed on document save.

Validation rules will be executed manually.

No validation rules will be executed

Used in
class VisibilityKind

SysML

Implementation of VisibilityKind defined in the KerML specification.

Specification:

VisibilityKind is an enumeration whose literals specify the visibility of a Membership of an Element in a Namespace outside of that Namespace. Note that “visibility” specifically restricts whether an Element in a Namespace may be referenced by name from outside the Namespace and only otherwise restricts access to an Element as provided by specific constraints in the abstract syntax (e.g., preventing the import or inheritance of private Elements).

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.

Used in
class VisitAction

A strongly typed explicit visitation operation

Continue visitation

Stop visitation