Documentation
¶
Index ¶
- Constants
- func DeclNamedByReference(decl Node) (byReference, referenceOnly bool)
- func DeclaredMetadata(node Node) (prefixes []*PrefixMetadata, body []Node, ok bool)
- func Dump(n Node) string
- func EffectiveName(u *Usage) (string, source.Span)
- func FeatureChainBase(n *FeatureChainExpr) (Node, []NameSegment)
- func Inspect(n Node, visit func(Node) bool)
- func IsEntryAction(actions []Node, decl Node) bool
- func IsExpression(node Node) bool
- func IsFeatureChain(node Node) bool
- func IsReferenceSubsetting(decl Node, rel *Relationship) bool
- func IsSuccessionSource(member Node) bool
- func Notation(node Node) string
- func NotationKeyword(notation string) string
- func QualifiedNameHasChain(name *QualifiedName) bool
- func QualifiedText(node Node) string
- func SimpleName(node Node) string
- func TargetName(node Node) (string, source.Span)
- type AcceptActionUsage
- type AcceptEvent
- type ActionExecutionNode
- type Alias
- type AssignmentActionNode
- type AssumeMember
- type BodyDeclaration
- type BodyExpr
- type BodyParam
- type CallEvent
- type CastExpr
- type ChangeEvent
- type CollectExpr
- type Comment
- type ConnectorEnd
- type ConstraintMember
- type ConstructorExpr
- type ControlFlowEdge
- type CrossFeatureMember
- type DecisionNode
- type Definition
- type DefinitionKind
- type Dependency
- type DoMember
- type Documentation
- type EntryMember
- type ErrorNode
- type ExitMember
- type ExpressionOperand
- type FeatureChainExpr
- type FeatureDirection
- type FeatureReference
- type FilterMember
- type FinalNode
- type FlowEnds
- type ForkNode
- type Identification
- type IfActionNode
- type IfBranchKind
- type IfBranchNode
- type Import
- type ImportKind
- type IndexExpr
- type InitialNode
- type InvocationExpr
- type JoinNode
- type LiteralBool
- type LiteralInfinity
- type LiteralInteger
- type LiteralReal
- type LiteralString
- type LoopKind
- type Membership
- type MergeNode
- type MetadataAccessExpr
- type Multiplicity
- type MultiplicityDecl
- type NameSegment
- type NamedArg
- type Namespace
- type Node
- func ConditionReference(n Node) Node
- func ConstraintReferenceOf(n Node) Node
- func DeclMembers(decl Node) []Node
- func EndSelection(target Node) (feature, index Node)
- func EndTarget(target Node) Node
- func EntryActions(members []Node) []Node
- func ImplicitTransitionSource(members []Node, transition Node) Node
- func NodeBodyMembers(n Node) []Node
- func StateEntryActions(state Node) []Node
- func ValuePartOf(node Node) (value Node, isDefault, isInitial, ok bool)
- type NodeBase
- type NullExpr
- type ObjectFlowEdge
- type OperatorExpr
- type OperatorKind
- type OwnedConstraint
- type Package
- type PerformActionNode
- type PortionKind
- type PrefixMetadata
- type PseudostateKind
- type PseudostateNode
- type QualifiedName
- type Relationship
- type RelationshipKind
- type RelationshipMember
- type RequireMember
- type RootNamespace
- type SelectExpr
- type SendStatement
- type SequenceExpr
- type StateNode
- type StateRegion
- type SubjectMember
- type SubstateMember
- type SuccessionEdge
- type TerminateStatement
- type TextualRepresentation
- type TimeEvent
- type TransitionEdge
- type TransitionMember
- type TriggerEvent
- type Trivia
- type TriviaKind
- type Usage
- func (u *Usage) ConjugatedTyping() (*Relationship, bool)
- func (u *Usage) HasConjugatedTyping() bool
- func (u *Usage) IsAssumedConstraint() bool
- func (u *Usage) IsExhibitedState() bool
- func (u *Usage) IsIncludedUseCase() bool
- func (u *Usage) IsPerformedAction() bool
- func (u *Usage) IsRequirementConstraint() bool
- func (u *Usage) IsStateAction() bool
- func (u *Usage) IsSuccessionFlow() bool
- func (u *Usage) IsVariantReference() bool
- func (u *Usage) IsVerifiedRequirement() bool
- func (u *Usage) NamedByReference() bool
- func (u *Usage) PerformedInvocation() *InvocationExpr
- func (u *Usage) ReferenceSubsetting() *Relationship
- type UsageKind
- type Visibility
- type WhileLoopActionNode
Constants ¶
const DoneFeature = "done"
DoneFeature is the name of the end shot every state inherits from the standard library (`Systems Library/States.sysml`), which a transition enters to complete.
const ResultFeature = "result"
ResultFeature is the name of the result parameter every calculation and expression inherits from the kernel library (`Performances::Evaluation`), which an unnamed `return` parameter redefines and so is named by.
const StartFeature = "start"
StartFeature is the name of the start shot every state inherits from the standard library (`Systems Library/States.sysml`), which a succession leaves to start.
Variables ¶
This section is empty.
Functions ¶
func DeclNamedByReference ¶
DeclNamedByReference reports whether an unnamed declaration is named by the feature it references, and whether that reference is its only naming feature (a requirement's assume/require/verify member, which no redefinition names).
func DeclaredMetadata ¶
func DeclaredMetadata(node Node) (prefixes []*PrefixMetadata, body []Node, ok bool)
DeclaredMetadata returns the prefix metadata a declaration is written with and the body whose metadata members annotate it (KerML 8.2.4 PrefixMetadataMember; SysML.xtext UsageExtensionKeyword on SubjectUsage and RequirementConstraintUsage). A document root's members annotate the root namespace, an annotation's body members annotate the annotation itself, a transition's or succession's body members annotate that edge, a control node's prefixes annotate its usage, and a dependency's body members the dependency. ok is false for a node that carries neither.
func EffectiveName ¶
EffectiveName returns the name a usage answers to: its declared name (a short name alone included), else the name its naming feature supplies.
func FeatureChainBase ¶ added in v0.12.0
func FeatureChainBase(n *FeatureChainExpr) (Node, []NameSegment)
FeatureChainBase flattens a nested feature chain: `lander.mass.mDry` is one chain of members from `lander`, not a chain through the value of `lander.mass`.
func Inspect ¶
Inspect visits n and, wherever visit answers true, every node reachable through n's exported fields: pointer, interface, slice and map members, and structs that do not themselves implement Node, so no node is missed for want of a field list. A node is visited at most once.
func IsEntryAction ¶
IsEntryAction reports whether decl is one of the actions.
func IsExpression ¶
IsExpression reports whether node is an expression rather than a declaration or a statement: what a calculation body ends in as its result.
func IsFeatureChain ¶
IsFeatureChain reports whether a relationship target is written as a feature chain (`p.q`) rather than a plain or qualified name.
func IsReferenceSubsetting ¶
func IsReferenceSubsetting(decl Node, rel *Relationship) bool
IsReferenceSubsetting reports whether rel is decl's OwnedReferenceSubsetting, whatever kind the parser recorded it under.
func IsSuccessionSource ¶
IsSuccessionSource reports whether a positional `then` sequences from this body member: a feature that is not an edge (SysML v2 §7.17.4). Parser and RDF writer share it.
func Notation ¶
Notation names a declaration the way the notation writes it — "part def", "datatype", "assert constraint" — and is empty for a node the notation has no keyword of its own for.
func NotationKeyword ¶ added in v0.11.0
NotationKeyword is the kind keyword a notation names after its modifiers: `part def` of `abstract part def`, `ref part` of `variant ref part`, `variant` alone of `variant`.
func QualifiedNameHasChain ¶ added in v0.12.0
func QualifiedNameHasChain(name *QualifiedName) bool
QualifiedNameHasChain reports whether name reaches its element through a dotted feature chain (`a.b`), which the metamodel owns as a chain feature.
func QualifiedText ¶
QualifiedText renders a reference's whole name as written ("A::B::C"), or "" when node names nothing.
func SimpleName ¶
SimpleName returns a reference's last segment — the name the resolver and the runtime match on — or "" when node names nothing.
Types ¶
type AcceptActionUsage ¶
type AcceptActionUsage struct {
NodeBase
Name string
ParamName string
ParamType *QualifiedName
}
AcceptActionUsage represents an action that waits for a signal. Syntax: action <name> accept <param> : Type;
type AcceptEvent ¶
type AcceptEvent struct {
NodeBase
SignalType *QualifiedName // signal type to accept
// Subsets is the event feature the payload parameter subsets, a name or a
// feature chain (`accept :> shutDown`, `accept :> fall.touchdown`), nil when none.
Subsets Node
// Payload is the payload parameter as it was declared, when the accept named
// one (`accept msg : Warning`), so the name the received value binds to
// survives lowering.
Payload *Usage
}
AcceptEvent fires when a signal is received. It is the lowered form of the payload parameter of an accept (SysML.xtext `PayloadParameter`), whose three spellings this node keeps apart:
accept Warning — SignalType, an unnamed payload typed by Warning accept msg : Warning — SignalType with Payload naming the parameter accept :> shutDown — Subsets, the event feature accepted
Subsetting an event accepts occurrences of *that feature* rather than of a type, so the two are matched differently and are recorded separately.
type ActionExecutionNode ¶
type ActionExecutionNode struct {
NodeBase
Name string
ActionRef *QualifiedName // reference to nested action (mutually exclusive with Expression)
Expression Node // inline expression (mutually exclusive with ActionRef)
}
ActionExecutionNode performs action work: invokes nested action or evaluates inline expression.
type Alias ¶
type Alias struct {
NodeBase
Visibility Visibility
Ident Identification
For *QualifiedName
Body []Node
HasBody bool
}
Alias is `alias <shortName> name for QualifiedName ;|{}`.
type AssignmentActionNode ¶
type AssignmentActionNode struct {
NodeBase
Target Node // feature reference or qualified name
Value Node // expression to assign
}
AssignmentActionNode represents an assignment statement: assign target := value;
type AssumeMember ¶
type AssumeMember struct {
NodeBase
// Prefix metadata written before the declaration: `assume #goal constraint c;`.
Prefixes []*PrefixMetadata
Expression Node // the reference the member states, when written as one
Reference *QualifiedName // referenced constraint/requirement (reference-subsetting form)
Body []Node // ConstraintMembers of the nested constraint (for the braced form)
// Declaration of the constraint the member owns, when it is written with
// one: `assume constraint <c> c1 : C;`. DeclSpan covers it from `constraint` on.
Ident Identification
DeclSpan source.Span
Relationships []*Relationship
Multiplicity *Multiplicity
Value Node
// ValueOperatorSpan covers the value operator; ValueIsDefault and
// ValueIsInitial are its `default` and `:=` (KerML FeatureValue).
ValueOperatorSpan source.Span
ValueIsDefault bool
ValueIsInitial bool
// HasBody records that the member was written with braces, which an empty
// body does not otherwise show.
HasBody bool
}
AssumeMember represents an assumption in a requirement body. Syntax: assume <reference>; OR assume constraint { <expression>... } OR assume <Q::r> { body }
type BodyDeclaration ¶ added in v0.12.0
type BodyDeclaration struct {
Index int
Param *BodyParam
Member Node // the member as written, membership wrapper and all
Decl Node // the declaration the member holds
}
BodyDeclaration is one declaration of an expression body (`{ in x; attribute y = 2; x + y }`) at the position the RDF conversion numbers it by: Param for a parameter, written at slot `in%d`, else Member, written at slot `m%d`.
func BodyDeclarations ¶ added in v0.12.0
func BodyDeclarations(params []BodyParam, members []Node) []BodyDeclaration
BodyDeclarations are the parameters and members of an expression body in the order the RDF conversion numbers them: source order across both lists.
func (BodyDeclaration) Slot ¶ added in v0.12.0
func (d BodyDeclaration) Slot() string
Slot is the name the conversion writes the declaration under.
type BodyExpr ¶
type BodyExpr struct {
NodeBase
Params []BodyParam
// Members are the body's documentation and the features it declares ahead
// of its result: `private attribute lbcf = …;`.
Members []Node
Result Node
}
BodyExpr is `{ [doc] (in param ;)* (member)* resultExpr }`.
type BodyParam ¶
type BodyParam struct {
Name string
Type *QualifiedName // optional type annotation (e.g., in x : Type)
Multiplicity *Multiplicity // optional multiplicity after type (e.g., in x : Type [1])
Value Node // optional default value (e.g., in x = expr)
IsReference bool // true if 'ref' modifier present
Members []Node // optional body members (e.g., in x { doc ... })
// Relationships are the specializations the parameter declares other than
// its typing, which Type carries: `in p :> ISQ::mass` subsets a feature
// rather than naming a type.
Relationships []*Relationship
Span source.Span
}
BodyParam is `in name` inside a body expression.
type CallEvent ¶
type CallEvent struct {
NodeBase
Operation *QualifiedName // operation to invoke
Parameters []NameSegment // declared argument names, in written order
}
CallEvent fires when an operation is invoked. Parameters are the argument names the trigger declares (`accept op(speed)`); an empty list matches a call to that operation whatever arguments it carries.
type CastExpr ¶
type CastExpr struct {
NodeBase
TargetType *QualifiedName
Multiplicity *Multiplicity
}
CastExpr represents a type cast: (as Type) or (as Type[mult])
type ChangeEvent ¶
ChangeEvent fires when a condition becomes true.
type CollectExpr ¶
CollectExpr is `operand . body`.
type Comment ¶
type Comment struct {
NodeBase
Ident Identification
About []*QualifiedName
Locale string
BodySpan source.Span // the REGULAR_COMMENT token span
}
Comment is `[comment <id> [about refs]] [locale s] /* ... */`.
type ConnectorEnd ¶
type ConnectorEnd struct {
NodeBase
Target Node // QualifiedName or Expression (e.g., FeatureChainExpr for occ.startShot)
Multiplicity *Multiplicity
Reference Node // Optional "references X" clause - QualifiedName or FeatureChainExpr
Relationships []*Relationship // Optional relationships (e.g., ::> for interface binding)
}
ConnectorEnd represents a single connector end with optional multiplicity.
func (*ConnectorEnd) AttachedIndex ¶ added in v0.10.0
func (c *ConnectorEnd) AttachedIndex() Node
AttachedIndex returns the index expression an indexed end selects one element of its feature with — the `1` of `connect s.y#(1) to k.u`, an OpenSysML extension — or nil for an end attaching to the feature as a whole.
func (*ConnectorEnd) AttachedSelection ¶ added in v0.10.0
func (c *ConnectorEnd) AttachedSelection() Node
AttachedSelection returns the node the end attaches as it was written: the IndexExpr of an indexed end, otherwise the same node as AttachedTarget.
func (*ConnectorEnd) AttachedTarget ¶
func (c *ConnectorEnd) AttachedTarget() Node
AttachedTarget returns the node naming the feature this end attaches to: what it reference-subsets when it declares a name of its own (`connect bead references t.bead`), and the target it names otherwise (`connect a.p to b.q`). An indexed end (`connect s.y#(1) to k.u`) attaches to the feature it indexes, `s.y`; AttachedIndex is the index and AttachedSelection the end as written.
func (*ConnectorEnd) DeclaredName ¶
func (c *ConnectorEnd) DeclaredName() (Identification, bool)
DeclaredName returns the name the end declares for itself, and whether it declares one at all. A connector end names an end feature of the connector only when it also reference-subsets the feature that end attaches to (`connect bead references t.bead`, `connect supplierPort ::> a.p`); without that clause the end names an existing feature instead (`connect a to b`).
func (*ConnectorEnd) ReferencedTarget ¶
func (c *ConnectorEnd) ReferencedTarget() Node
ReferencedTarget returns the node naming the feature the end reference-subsets (`references x`, `::> x`), or nil when the end has no such clause.
type ConstraintMember ¶
type ConstraintMember struct {
NodeBase
IsAssert bool // true for 'assert', false for 'assume'
// Keyword is the keyword the condition was written with: "assert",
// "assume", or "" for a bare condition, which asserts implicitly.
Keyword string
IsNegated bool // true if 'not' keyword present (assert not expr)
Expression Node // the constraint expression, nil when stated through Body
Name string // name of the nested constraint, when it has one
Body []Node // conditions of a nested constraint: assert constraint { <expr> }
// Terminator is the `;` written after a bare condition, which no production
// admits after a body's result expression; zero where none was written.
Terminator source.Span
}
ConstraintMember represents a condition of a constraint body. Syntax: <expression> or assert [not] <reference>; or assert constraint { … }
type ConstructorExpr ¶
type ConstructorExpr struct {
NodeBase
Type *QualifiedName
Args []Node
NamedArgs []NamedArg
}
ConstructorExpr is `new Type ( args )`, with positional or named arguments.
type ControlFlowEdge ¶
type ControlFlowEdge struct {
NodeBase
Source *QualifiedName // source node (typically DecisionNode)
Target *QualifiedName // target node
Guard Node // boolean guard expression, nil for the default branch
// IsElse records that the edge was written as the `else <target>;` branch of
// a decision (SysML.xtext DefaultTargetSuccession), the branch taken when no
// guarded branch of the same decision is.
IsElse bool
// SourceMember and TargetMember bind an end by position rather than by name,
// as on SuccessionEdge: the branches of a decision node the body declares
// without a name (`then decide; if x then a; else b;`) reach it this way.
SourceMember Node
TargetMember Node
// SourceImplied and TargetImplied mark an end the notation supplied rather
// than the author writing it, as on SuccessionEdge.
SourceImplied bool
TargetImplied bool
}
ControlFlowEdge is guarded control flow from decision nodes.
type CrossFeatureMember ¶
type CrossFeatureMember struct {
NodeBase
// The prefix after `end` is the cross feature's (KerML.xtext BasicFeaturePrefix).
Direction FeatureDirection
IsDerived bool
IsAbstract bool
IsVariation bool
IsComposite bool
IsPortion bool
IsVariable bool
IsConstant bool
IsReference bool
Ident Identification
Multiplicity *Multiplicity
IsOrdered bool
IsNonunique bool
Relationships []*Relationship
}
CrossFeatureMember is the cross feature declared inline by an end feature, the `x1 [0..1]` of `end x1 [0..1] feature x : C1` (KerML 8.3.4.5).
type DecisionNode ¶
type DecisionNode struct {
NodeBase
Prefixes []*PrefixMetadata
Name string
NameSpan source.Span // span of Name, empty for an unnamed node
Members []Node // body members, as on ForkNode
HasBody bool
}
DecisionNode is a conditional branch point (1 incoming → N guarded outgoing).
type Definition ¶
type Definition struct {
NodeBase
Prefixes []*PrefixMetadata
Kind DefinitionKind
// Keyword is the kind keyword as written, kept for the same reason as
// Usage.Keyword.
Keyword string
// HasDefKeyword records the `def` of a SysML `part def`, which a KerML
// classifier declaration of the same kind is written without.
HasDefKeyword bool
IsAbstract bool
IsVariation bool
IsAll bool // 'all' multiplicity propagation modifier
IsConstant bool // 'constant' feature modifier
IsEvent bool // 'event' modifier for event-driven occurrences
IsIndividual bool // 'individual' modifier: `individual part def` (SysML v2 8.3.9.11)
// IndividualKeyword spans the `individual` written, zero when none was.
IndividualKeyword source.Span
// IsParallel is the `parallel` before a state body: the state's substates
// are orthogonal (SysML v2 StateDefinition::isParallel).
IsParallel bool
Visibility Visibility
Ident Identification
Multiplicity *Multiplicity
Relationships []*Relationship
Members []Node
HasBody bool
}
Definition is a `part def` / `attribute def` (and future kinds) node.
type DefinitionKind ¶
type DefinitionKind int
DefinitionKind discriminates the concrete definition taxonomy element.
const ( DefPart DefinitionKind = iota DefAttribute // Tier A — pure keyword-swaps of the part/attribute pattern. DefItem DefOccurrence DefIndividual DefMetaclass DefMetadata DefEnumeration DefView DefViewpoint DefRendering DefConcern // Tier B — distinctive declaration grammar. DefConnection DefFlow DefPort DefInterface DefAllocation DefBinding // Tier C — nested behavioral bodies (generic body this cycle). DefAction DefState DefCalc DefConstraint DefRequirement DefCase DefAnalysisCase DefVerificationCase DefUseCase // KerML structural kinds DefBehavior DefAssoc DefStruct DefClass DefPredicate DefBool )
func (DefinitionKind) IsAction ¶ added in v0.11.0
func (k DefinitionKind) IsAction() bool
IsAction reports whether a definition of the kind defines an action: an action definition, or a use case definition, which is a case, a calculation and so an action definition (SysML v2 §7.17, §7.19) whose body is an action body.
func (DefinitionKind) String ¶
func (k DefinitionKind) String() string
type Dependency ¶
type Dependency struct {
NodeBase
Prefixes []*PrefixMetadata
Ident Identification
Clients []*QualifiedName
Suppliers []*QualifiedName
Body []Node
HasBody bool
}
Dependency is `dependency [<id> from] clients to suppliers ;|{}`.
type DoMember ¶
DoMember represents an ongoing do action in a state body. Syntax: do <action>; — see EntryMember for the forms Actions holds.
type Documentation ¶
type Documentation struct {
NodeBase
Ident Identification
Locale string
BodySpan source.Span
}
Documentation is `doc <id> [locale s] /* ... */`.
type EntryMember ¶
EntryMember represents entry behavior in a state body. Syntax: entry <action>; — `entry action a;`, `entry assign x := 1;`, `entry a;` or `entry { … }` (SysML.xtext StateActionUsage).
Actions holds the one action the subaction performs, or nothing for `entry;`. A braced block is one anonymous action usage whose Members are the block's items and whose Keyword is empty, as no `action` keyword was written.
type ErrorNode ¶
ErrorNode represents a span of source the parser could not parse into a valid construct. The parser always produces a tree; unparseable regions become ErrorNodes so downstream tooling (LSP) still gets a partial tree.
type ExitMember ¶
ExitMember represents exit behavior in a state body. Syntax: exit <action>; — see EntryMember for the forms Actions holds.
type ExpressionOperand ¶ added in v0.12.0
ExpressionOperand is an operand at the slot the RDF conversion names it by, bound to `in` parameter Index of its expression (-1: no parameter binds it).
func ExpressionOperands ¶ added in v0.12.0
func ExpressionOperands(node Node) (operands []ExpressionOperand, typeArgument int)
ExpressionOperands are an expression's operands in the order the RDF conversion writes them, and its type argument's parameter index (-1 when it has none).
type FeatureChainExpr ¶
type FeatureChainExpr struct {
NodeBase
Operand Node
Member *QualifiedName
}
FeatureChainExpr is `operand . member` (feature chain access).
type FeatureDirection ¶
type FeatureDirection int
FeatureDirection is the in/out/inout direction modifier on a usage.
const ( DirNone FeatureDirection = iota DirIn DirOut DirInOut )
func (FeatureDirection) String ¶
func (d FeatureDirection) String() string
type FeatureReference ¶
type FeatureReference struct {
NodeBase
Name *QualifiedName
}
FeatureReference is a bare QualifiedName used as an expression.
type FilterMember ¶
FilterMember is an `filter <expression> ;` element filter.
type FinalNode ¶
type FinalNode struct {
NodeBase
}
FinalNode is the termination point for action execution.
type FlowEnds ¶
type FlowEnds struct {
NodeBase
From Node // Flow source (qualified name or feature chain)
To Node // Flow target (qualified name or feature chain)
Payload Node // optional; from the `of` clause (qualified name or feature chain)
// PayloadDecl is set when the `of` clause declares the payload feature
// (`of name : Type`) instead of referring to an existing one. That usage is
// also a member of the owning flow, and Payload names it.
PayloadDecl *Usage
// PayloadMultiplicity is the multiplicity stated with a payload type that
// declares no feature of its own (`of Publish[1]`, `of [1] Publish`). Where
// the payload is a declaration the multiplicity is that usage's own.
PayloadMultiplicity *Multiplicity
}
FlowEnds holds the ends of a flow usage: the `from`/`to` targets and an optional payload from the `of` clause. It embeds NodeBase (spannable) but is only ever reached through the *ast.Usage traversal case.
type ForkNode ¶
type ForkNode struct {
NodeBase
Prefixes []*PrefixMetadata
Name string
NameSpan source.Span // span of Name, empty for an unnamed node
// Members and HasBody carry the body every ControlNode may declare
// (SysML.xtext ControlNode: `UsageDeclaration? ActionBody`), which is where
// the node's parameters are written (`fork F { in a; out b; }`).
Members []Node
HasBody bool
}
ForkNode splits execution into concurrent flows (1 incoming → N outgoing).
type Identification ¶
type Identification struct {
ShortName string
ShortNameSpan source.Span
Name string
NameSpan source.Span
}
Identification captures `<shortName> name` or `name` on a declaration.
func (Identification) Declared ¶
func (id Identification) Declared() bool
Declared reports whether either name is declared, which is when a feature takes no name from its naming feature (KerML 7.3.4.5).
func (Identification) DeclaredName ¶
func (id Identification) DeclaredName() (string, source.Span)
DeclaredName returns the name a declaration is known by: its name, else its short name, as the symbol table registers it.
type IfActionNode ¶
type IfActionNode struct {
NodeBase
Condition Node // boolean expression
Then *IfBranchNode // branch taken when the condition holds
Else *IfBranchNode // branch taken otherwise (nil when there is no else)
}
IfActionNode represents conditional: if condition { thenBody } else { elseBody }
func (*IfActionNode) Branches ¶
func (n *IfActionNode) Branches() []*IfBranchNode
Branches returns the branches the conditional declares, in source order, skipping an absent else.
type IfBranchKind ¶
type IfBranchKind int
IfBranchKind discriminates the two branches of an if action.
const ( // IfBranchThen is the branch taken when the condition holds. IfBranchThen IfBranchKind = iota // IfBranchElse is the branch taken when it does not. IfBranchElse )
func (IfBranchKind) String ¶
func (k IfBranchKind) String() string
String renders the branch's introducing keyword.
type IfBranchNode ¶
type IfBranchNode struct {
NodeBase
Kind IfBranchKind
Body []Node // statements in the branch body
}
IfBranchNode is the body of one branch of an if action. It exists so that a branch is an element in its own right: the declarations a branch body makes are members of the branch, not of the enclosing behavior, and only a node can own a scope.
type Import ¶
type Import struct {
NodeBase
Visibility Visibility
IsAll bool
Kind ImportKind
Imported *QualifiedName
IsRecursive bool // `::**`
FilterExpr Node // Optional filter expression [<expr>]
Body []Node
HasBody bool
// IsExpose marks an `expose` declaration. Per SysML v2 8.3.26.2 an Expose
// always imports all elements regardless of visibility (isImportAll = true)
// and always has protected visibility, so IsAll and Visibility are fixed
// accordingly by the parser.
IsExpose bool
}
Import is `[visibility] import [all] QualifiedName[::*][::**] ;|{}`.
An `expose` declaration in a view body is also an Import: SysML v2 8.3.26.2 makes Expose a specialization of Import (MembershipExpose specializes MembershipImport, NamespaceExpose specializes NamespaceImport), so it is represented by this node with IsExpose set.
type ImportKind ¶
type ImportKind int
ImportKind distinguishes membership vs namespace imports.
const ( ImportMembership ImportKind = iota // import A::B ; ImportNamespace // import A::B::* ; )
type IndexExpr ¶
type IndexExpr struct {
NodeBase
Operand Node
Index Node
Bracket bool // written `operand [ seq ]`
}
IndexExpr is `operand # ( seq )` or `operand [ seq ]`. The two are distinct syntaxes: bracket form is the quantity operator, which pairs a magnitude with a measurement reference, while `#` indexes a sequence.
type InitialNode ¶
type InitialNode struct {
NodeBase
// First is the name written after `first`, nil when none was. In an action
// body's two-ended form it is a reference to the succession's source.
First *QualifiedName
Successor *QualifiedName // the target of `first X then Y`, nil for the one-ended form
Guard Node // optional guard condition for succession
// TargetMultiplicity is the written target end of `first X then [m] Y`,
// nil where none is written.
TargetMultiplicity *Multiplicity
// Members are the members of the body the succession was written with
// (`first start then continue { … }`), and HasBody that it was written with
// one rather than ended by ';'.
Members []Node
HasBody bool
}
InitialNode is a `first` member of an action or state body. One-ended (`first start;`, `first a;`) it marks where the flow starts; with a Successor (`first a then b;`) it states the succession a -> b and declares no node of its own.
func (*InitialNode) Name ¶
func (n *InitialNode) Name() string
Name is the text of the name written after `first`, "" when none was.
func (*InitialNode) NameSpan ¶
func (n *InitialNode) NameSpan() source.Span
NameSpan is the span of the name written after `first`, empty when none was.
type InvocationExpr ¶
type InvocationExpr struct {
NodeBase
Operand Node // receiver for `->` form, else nil
Type *QualifiedName // instantiated type
Args []Node // positional args (Argument) or ...
NamedArgs []NamedArg // named args, mutually exclusive with Args
}
InvocationExpr is `Type ( args )` or `operand -> Type ( args | body | funcref )`.
type JoinNode ¶
type JoinNode struct {
NodeBase
Prefixes []*PrefixMetadata
Name string
NameSpan source.Span // span of Name, empty for an unnamed node
Members []Node // body members, as on ForkNode
HasBody bool
}
JoinNode synchronizes concurrent flows (N incoming → 1 outgoing).
type LiteralInfinity ¶
type LiteralInfinity struct{ NodeBase }
LiteralInfinity is `*` in an expression position.
type LiteralInteger ¶
LiteralInteger is a DECIMAL_VALUE literal (raw text).
type LiteralReal ¶
LiteralReal is a RealValue literal (raw text).
type LiteralString ¶
LiteralString is a double-quoted string literal (raw token text, quotes included).
type LoopKind ¶
type LoopKind int
LoopKind discriminates the loop forms, which share one node because they share a body and a condition but differ in when the condition is tested.
const ( // LoopWhile is `while <cond> { body }`: the condition is tested before every // iteration, so a body may run zero times. LoopWhile LoopKind = iota // LoopUntil is `loop { body } until <cond>;`: the condition is tested after // every iteration, so the body runs at least once. A loop written without an // `until` clause has no condition and iterates until the step budget stops it. LoopUntil // LoopFor is `for <var> in <collection> { body }`: the body runs once per // element of the collection, with the element bound to the loop's variable. LoopFor )
type Membership ¶
type Membership struct {
NodeBase
Visibility Visibility
IsTypeFeature bool
Member Node
}
Membership wraps a namespace member with a visibility prefix. Member is the owned element (a Package/Namespace/Dependency/Comment/... or ErrorNode). A `then` prefixing a member is not recorded here: it sequences the members either side of it rather than describing one of them, so the parser desugars it to a SuccessionEdge of its own (see internal/syntax/parser/succession.go).
type MergeNode ¶
type MergeNode struct {
NodeBase
Prefixes []*PrefixMetadata
Name string
NameSpan source.Span // span of Name, empty for an unnamed node
Members []Node // body members, as on ForkNode
HasBody bool
}
MergeNode merges alternative flows (N incoming → 1 outgoing, each arrival passes).
type MetadataAccessExpr ¶
type MetadataAccessExpr struct {
NodeBase
Ref *QualifiedName
}
MetadataAccessExpr is `ref . metadata`.
type Multiplicity ¶
Multiplicity is a `[n]` / `[lo..hi]` / `[*]` bound on a usage. Bounds are expression Nodes (reusing the expression AST); `*` becomes LiteralInfinity. For the single-bound form `[n]`, Upper holds n and IsRange is false.
type MultiplicityDecl ¶
type MultiplicityDecl struct {
NodeBase
Ident Identification
Range *Multiplicity // range bounds, in the MultiplicityRange form
// Subsets is the subsetted multiplicity of a MultiplicitySubset; the two
// forms are exclusive.
Subsets *QualifiedName
Members []Node // optional - body members (typically doc comments)
HasBody bool // true if has {}, false if just ;
}
MultiplicityDecl is `multiplicity <id> [range] ;|{}` (a MultiplicityRange) or `multiplicity <id> subsets f ;|{}` (a MultiplicitySubset, KerML.xtext:754). Declares a named multiplicity like exactlyOne [1..1].
type NameSegment ¶
type NameSegment struct {
Text string
Span source.Span
// Chained records that the segment was written after '.' rather than after
// '::': a feature chain step (`S2.S3`) rather than a namespace member.
Chained bool
}
NameSegment is one identifier in a qualified name, with its source span. It carries no semantic information: the symbol a segment resolves to lives in the resolver's side table, reachable through Resolver.PartSymbol.
type NamedArg ¶
type NamedArg struct {
Name *QualifiedName
Value Node
}
NamedArg is `name = value` in an argument list.
type Namespace ¶
type Namespace struct {
NodeBase
Prefixes []*PrefixMetadata
Ident Identification
Members []Node
HasBody bool // false when body was `;`
}
Namespace is `namespace <id> { ... }`.
type Node ¶
Node is the common interface for every AST/CST node. The tree is syntax-only and immutable after parsing; all semantic information (resolved references, types) lives in side tables keyed by node, added in later plans.
func ConditionReference ¶
ConditionReference returns the name or feature chain an assume or require member's condition consists of alone (`require r1;`, `require h.r1;`): the reference form the parser keeps as a condition expression, whose target is resolved as a reference subsetting's.
func ConstraintReferenceOf ¶
ConstraintReferenceOf returns the constraint or requirement an assume or require member states by reference alone (`require P::r1;`, `require r1;`, `require h.r1;`): a qualified name or a feature chain.
func DeclMembers ¶
DeclMembers is the body of a definition or usage, and nil for any other node.
func EndSelection ¶ added in v0.10.0
EndSelection splits an end's target into the feature it names and the index an indexed end selects one element of that feature with (`s.y#(1)`: the chain `s.y` and the expression `1`). A plain end is its own feature with a nil index.
func EndTarget ¶ added in v0.10.0
EndTarget is the feature a connector end's target names: the operand of an indexed end (`s.y` of `s.y#(1)`), else the target itself.
func EntryActions ¶
EntryActions returns the actions the entry subactions among a state body's members declare, in declaration order.
func ImplicitTransitionSource ¶
ImplicitTransitionSource returns the member a sourceless transition leaves: the closest before it, past other sourceless transitions (SysML v2 §7.18.3); nil when none precedes it.
func NodeBodyMembers ¶
NodeBodyMembers returns the members of the body an action node declares, and nil for a node that declares no body or admits none.
func StateEntryActions ¶
StateEntryActions returns the entry actions of a state declaration, whichever shape it was parsed into: a state node's entry behavior or a body's `entry`.
func ValuePartOf ¶ added in v0.12.0
ValuePartOf is the value part a declaration writes (KerML 8.3.3.3.5 FeatureValue): the expression, and whether its operator is `default` or `:=`. ok is false for a node that declares no value.
type NodeBase ¶
NodeBase is embedded by every concrete node to provide span + trivia storage and satisfy the Node interface's accessor methods.
func (*NodeBase) LeadingTrivia ¶
func (*NodeBase) SetLeadingTrivia ¶
func (*NodeBase) SetTrailingTrivia ¶
func (*NodeBase) TrailingTrivia ¶
type ObjectFlowEdge ¶
type ObjectFlowEdge struct {
NodeBase
Source *QualifiedName // source pin/parameter
Target *QualifiedName // target pin/parameter
}
ObjectFlowEdge is data flow between action parameters/pins (Tier 5).
type OperatorExpr ¶
type OperatorExpr struct {
NodeBase
Operator OperatorKind
Operands []Node
TypeRef *QualifiedName // classification/cast RHS, else nil
}
OperatorExpr is any operator application. Operands has 3 elements for OpConditional (cond, then, else), 1 for unary/extent, 2 otherwise. For OpAt/OpMetaAt/OpAs/OpMeta the RHS type reference is stored in TypeRef.
type OperatorKind ¶
type OperatorKind int
OperatorKind enumerates every operator in the KerMLExpressions ladder, used by OperatorExpr regardless of arity.
const ( OpInvalid OperatorKind = iota OpConditional // if C ? A else B OpNullCoalesce // ?? OpImplies // implies OpOr // | OpConditionalOr // or OpXor // xor OpAnd // & OpConditionalAnd // and OpEq // == OpNeq // != OpEqEqEq // === OpNeqEqEq // !== OpHasType // hastype OpIsType // istype OpAt // @ OpMetaAt // @@ OpAs // as OpMeta // meta OpLt // < OpGt // > OpLe // <= OpGe // >= OpRange // .. OpAdd // + OpSub // - OpMul // * OpDiv // / OpMod // % OpPow // ** or ^ OpNeg // unary - OpPos // unary + OpBitNot // unary ~ OpNot // unary not OpAll // extent: all OpIndex // [ ... ] )
func (OperatorKind) String ¶
func (k OperatorKind) String() string
type OwnedConstraint ¶
type OwnedConstraint struct {
Ident Identification
DeclSpan source.Span
Relationships []*Relationship
Multiplicity *Multiplicity
Value Node
ValueOperatorSpan source.Span
ValueIsDefault bool
ValueIsInitial bool
Body []Node
}
OwnedConstraint is the constraint usage an assume or require member declares with the `constraint` keyword (SysML.xtext RequirementConstraintUsage).
func OwnedConstraintOf ¶
func OwnedConstraintOf(n Node) (OwnedConstraint, bool)
OwnedConstraintOf returns the constraint an assume or require member declares, or false for one that references a requirement or states a condition instead.
func (OwnedConstraint) EffectiveName ¶
func (c OwnedConstraint) EffectiveName() (string, source.Span)
EffectiveName returns the name the constraint answers to: its declared name, else the name its naming feature supplies.
func (OwnedConstraint) NamingFeature ¶
func (c OwnedConstraint) NamingFeature() *Relationship
NamingFeature returns the relationship naming a constraint declared without a name: a requirement constraint is named by the constraint it references (SysML ConstraintUsage::namingFeature); a redefinition leaves it anonymous.
type Package ¶
type Package struct {
NodeBase
Prefixes []*PrefixMetadata
Ident Identification
IsLibrary bool
IsStandard bool
Members []Node
HasBody bool
}
Package is `package <id> { ... }`. Library/Standard flags cover `library package` and `standard library package`.
type PerformActionNode ¶
type PerformActionNode struct {
NodeBase
ActionRef Node // qualified name or invocation expression
}
PerformActionNode represents a perform statement: perform action;
func (*PerformActionNode) PerformedInvocation ¶
func (n *PerformActionNode) PerformedInvocation() *InvocationExpr
PerformedInvocation is the call the statement performs (`perform tag(x);`); nil when it names the action without arguments.
type PortionKind ¶
type PortionKind int
PortionKind is the portion an occurrence usage declares of its type (OccurrenceUsage::portionKind, SysML v2 8.3.9.11).
const ( PortionNone PortionKind = iota PortionSnapshot PortionTimeslice )
func (PortionKind) Keyword ¶
func (k PortionKind) Keyword() string
Keyword returns the notation for the portion kind, empty for PortionNone.
type PrefixMetadata ¶
type PrefixMetadata struct {
NodeBase
// Ident names the usage when it declares one before its typing:
// `@ m : Meta;`, `@ : Meta;` (SysML.xtext MetadataUsageDeclaration).
Ident Identification
Type *QualifiedName
Body []Node // optional body with property initializers: @Meta{prop = value;}
// HasBody records that the usage was written with braces, which an empty
// body does not otherwise show.
HasBody bool
// Elements the usage annotates: `@Meta about a, b;` (SysML.xtext:145-147).
About []*QualifiedName
// TypedBy spans the `typed by` the typing was spelled with (KerML.xtext:1091);
// zero for `:` or `defined by`.
TypedBy source.Span
}
PrefixMetadata records a `# QualifiedName` metadata annotation reference.
type PseudostateKind ¶
type PseudostateKind int
PseudostateKind discriminates pseudostate types.
const ( PseudostateChoice PseudostateKind = iota // conditional branch PseudostateJunction // merge point PseudostateFork // parallel split PseudostateJoin // parallel sync // PseudostateShallowHistory re-enters the substate of its composite state // that was active when that state was last exited. PseudostateShallowHistory // PseudostateDeepHistory re-enters the innermost substate that was active // when its composite state was last exited. PseudostateDeepHistory )
func (PseudostateKind) String ¶
func (k PseudostateKind) String() string
type PseudostateNode ¶
type PseudostateNode struct {
NodeBase
Kind PseudostateKind
Name string
// Keyword is the notation the pseudostate was written with (`choice`,
// `deep history`, `fork`).
Keyword string
}
PseudostateNode is a transient state for control flow.
type QualifiedName ¶
type QualifiedName struct {
NodeBase
Global bool
Parts []NameSegment
// contains filtered or unexported fields
}
QualifiedName is an unresolved dotted/`::`-separated name reference. Global is true when the name began with `$::`.
func AsQualifiedName ¶
func AsQualifiedName(node Node) *QualifiedName
AsQualifiedName unwraps the two forms a name reference parses to: a bare QualifiedName, or one wrapped in a FeatureReference. It returns nil for anything else.
func QualifiedNameOf ¶
func QualifiedNameOf(segments ...string) *QualifiedName
QualifiedNameOf is the name a reference written as segments joined by "::" parses to, without positions.
func ReceiverChain ¶ added in v0.12.0
func ReceiverChain(receiver Node) []*QualifiedName
ReceiverChain is the feature chain a call reached through its receiver names its function by (`q.p.f(1)`: q, p, f), one single-segment name per link; nil when any link is an expression rather than a name.
func (*QualifiedName) SetSingleton ¶
func (q *QualifiedName) SetSingleton(seg NameSegment)
SetSingleton makes seg the name's only part, backed by the node's own storage. The slice is capped so appending a later segment copies out.
func (*QualifiedName) Text ¶
func (q *QualifiedName) Text() string
Text renders the name as written, "A::B::C", and "" for a nil name.
type Relationship ¶
type Relationship struct {
NodeBase
Kind RelationshipKind
Target Node // QualifiedName or Expression (e.g., FeatureChainExpr for interfacingPorts.incomingTransfers)
// Conjugated records the `~` of a ConjugatedPortTyping (SysML v2
// 8.3.12.3): the type is the conjugate of Target, which reverses the
// directions of the target port definition's features.
Conjugated bool
// Multiplicity is the end multiplicity written ahead of a connector end this
// relationship states: the `[0..1]` of `bind [0..1] a = b` (SysML.xtext:1020).
Multiplicity *Multiplicity
// TypedBy spans the `typed by` a typing was spelled with (KerML.xtext:600);
// zero for `:` or `defined by`, and on later targets of the same clause.
TypedBy source.Span
}
Relationship is one specialization/typing edge: exactly one Target. A clause with multiple targets (`specializes A, B`) produces multiple Relationship entries sharing the same Kind.
func DeclNamingFeature ¶
func DeclNamingFeature(decl Node) *Relationship
DeclNamingFeature is NamingFeature over every declaration that may borrow its name: a usage, a requirement subject or an assume/require constraint.
func NamingFeature ¶
func NamingFeature(u *Usage) *Relationship
NamingFeature returns the relationship that names a usage lacking a declared name (KerML 7.3.4.5): its first redefinition, or for the SysML members named by what they reference (Usage.NamedByReference) that reference. A declared short name is a declaration too: the feature then derives no name. A requirement's assume/require/verify member is named by its reference alone (SysML ConstraintUsage::namingFeature): a redefinition leaves it anonymous.
func SplitRedefinitions ¶
func SplitRedefinitions(rels []*Relationship) (redefines, others []*Relationship)
SplitRedefinitions partitions rels into the redefinitions and the rest, which resolve in different scopes when owned by a connector end.
type RelationshipKind ¶
type RelationshipKind int
RelationshipKind discriminates a specialization/typing edge at a definition or usage declaration head.
const ( RelTyping RelationshipKind = iota // ':' / 'defined by' RelSpecializes // 'specializes' / ':>' RelSubsets // 'subsets' / ':>' RelRedefines // 'redefines' / ':>>' // RelReferences models a KerML ReferenceSubsetting: the single owned // subsetting a feature may syntactically distinguish with 'references' / // '::>' (KerML 8.3.3.3.9). The 'via', 'about' and 'by' clauses of accept // actions, metadata usages and satisfy usages name related elements // without subsetting them, so they carry their own kinds below. RelReferences // 'references' / '::>' RelCrosses // 'crosses' / '=>' RelDisjoint // 'disjoint from' RelIntersects // 'intersects' RelInverseOf // 'inverse of' RelUnions // 'unions' RelChains // 'chains' RelIncludes // 'includes' (use case inclusion) RelVia // 'via' (accept action receiving port) RelAnnotates // 'about' (metadata annotated element) RelSubject // 'by' (satisfy/verify subject) // RelFeaturedBy models a KerML TypeFeaturing written in a feature // declaration: `featured by T` states a type the feature is a feature of // (KerML.xtext TypeFeaturingPart, 8.3.3.1.4). KerML notation only. RelFeaturedBy // 'featured by' RelDifferences // 'differences' )
func (RelationshipKind) ReferenceSubsets ¶
func (k RelationshipKind) ReferenceSubsets() bool
ReferenceSubsets reports whether k is a ReferenceSubsetting: `::>` or a use case inclusion, an OwnedReferenceSubsetting in SysML.xtext IncludeUseCaseUsage.
func (RelationshipKind) String ¶
func (k RelationshipKind) String() string
type RelationshipMember ¶
type RelationshipMember struct {
NodeBase
Ident Identification
Kind RelationshipKind
// Keyword is the relationship keyword as written (`subtype`, `subclassifier`),
// and PrefixKeyword the one that may precede it (`specialization`).
Keyword string
PrefixKeyword string
Source Node // the specific/subsetting/featured end
Target Node // the general/subsetted/featuring end
// Conjugated marks a Conjugation, whose target is the conjugate of Source.
Conjugated bool
Visibility Visibility
Members []Node
HasBody bool
}
RelationshipMember is a KerML relationship written keyword-first as a member of its own: `specialization Gen subtype A specializes B;` (KerML.xtext:390). Its two ends are ordered — Source relates to Target, never the reverse.
type RequireMember ¶
type RequireMember struct {
NodeBase
// Prefix metadata written before the declaration: `require #goal r;`.
Prefixes []*PrefixMetadata
Expression Node // the reference the member states, when written as one
Reference *QualifiedName // referenced requirement (reference-subsetting form, SysML v2 §7.20)
Body []Node // nested members: ConstraintMembers for the braced form, requirement members for the reference form
// Declaration of the constraint the member owns, when it is written with
// one: `require constraint <c> c1 : C;`. DeclSpan covers it from `constraint` on.
Ident Identification
DeclSpan source.Span
Relationships []*Relationship
Multiplicity *Multiplicity
Value Node
// ValueOperatorSpan covers the value operator; ValueIsDefault and
// ValueIsInitial are its `default` and `:=` (KerML FeatureValue).
ValueOperatorSpan source.Span
ValueIsDefault bool
ValueIsInitial bool
// HasBody records that the member was written with braces, which an empty
// body does not otherwise show.
HasBody bool
}
RequireMember represents a requirement constraint. Syntax: require <reference>; OR require constraint { <expression>... } OR require <Q::r> { body }
type RootNamespace ¶
type RootNamespace struct {
NodeBase
Members []Node // *Membership | *Import | *Alias | *ErrorNode
// UndefinedOperators are the `~` operator expressions of the document in
// source order: KerML leaves DataFunctions::'~' undefined, so a tool warns at each.
UndefinedOperators []*OperatorExpr
// TypedBy counts the typings the document spells `typed by` (KerML.xtext:600),
// on declarations, prefix metadata and body-expression parameters alike.
TypedBy int
}
RootNamespace is the top of every parsed file: a flat list of members.
type SelectExpr ¶
SelectExpr is `operand .? body`.
type SendStatement ¶
type SendStatement struct {
NodeBase
Message Node // message expression (often NewExpression); nil when the send declared none
Target Node // target expression: the receiver (`to`) or the sending port (`via`)
IsVia bool // the target is a port to route through, not a receiver
// Receiver is the receiver of a send that states both clauses (`send x via p
// to r`), which SysML.xtext SenderReceiverPart allows.
Receiver Node
// Members and HasBody carry the body SysML.xtext SendNode ends in, where the
// message a send with no argument carries is declared (`send { in :>> payload
// = s; }`).
Members []Node
HasBody bool
}
SendStatement sends a message to a target. Syntax: send <message> to <target>; | send <message> via <port>;
The two forms address different things and are not interchangeable: `to` names the receiver directly, while `via` names a port of the sender, and the message reaches whatever that port is connected to. IsVia records which form was written so routing can tell them apart.
type SequenceExpr ¶
SequenceExpr is a comma-separated list of expressions (flattened).
type StateNode ¶
type StateNode struct {
NodeBase
Name string
Entry []Node // entry behaviors (action sequence)
Do []Node // do action (ongoing action)
Exit []Node // exit behaviors (action sequence)
Substates []Node // nested states (hierarchical)
Regions []*StateRegion // orthogonal regions (parallel)
}
StateNode represents a state in a state machine (simple, composite, or orthogonal).
type StateRegion ¶
StateRegion is an orthogonal region within a composite state.
type SubjectMember ¶
type SubjectMember struct {
NodeBase
// Prefixes are the metadata written after the keyword: the `#B` of
// `subject #B s` (SysML.xtext SubjectUsage UsageExtensionKeyword).
Prefixes []*PrefixMetadata
Ident Identification // `<short> name`, either or both optional (SysML.xtext Identification)
TypeRef *QualifiedName // subject type (for declaration form)
Multiplicity *Multiplicity // optional multiplicity
Relationships []*Relationship // specializations written after the type (`:>> RequirementCheck::subj`)
Body []Node // optional nested members
BindingExpr Node // value part: `subject = <expr>;` or a declaration's `= expr` / `default expr`
// ValueOperatorSpan, ValueIsDefault and ValueIsInitial describe BindingExpr's
// operator as Usage's fields of the same names do.
ValueOperatorSpan source.Span
ValueIsDefault bool
ValueIsInitial bool
// HasBody records that the declaration was written with braces, which an
// empty body does not otherwise show.
HasBody bool
}
SubjectMember represents the subject declaration in a requirement body. Syntax: subject [<short>] [name] : <Type>; OR subject = <expr>;
func (*SubjectMember) EffectiveName ¶
func (m *SubjectMember) EffectiveName() (string, source.Span)
EffectiveName returns the name the subject answers to: its declared name, else the name its naming feature supplies.
func (*SubjectMember) NamingFeature ¶
func (m *SubjectMember) NamingFeature() *Relationship
NamingFeature returns the relationship naming a subject declared without a name: its first redefinition, as for a usage (`subject :>> vehicle;` answers to `vehicle`); a subject that merely references a feature stays anonymous.
type SubstateMember ¶
type SubstateMember struct {
NodeBase
Name string // substate name
NameSpan source.Span // span of Name, empty for an unnamed node
}
SubstateMember represents a nested state declaration. Syntax: state <name>;
type SuccessionEdge ¶
type SuccessionEdge struct {
NodeBase
Source *QualifiedName // source action node
Target *QualifiedName // target action node
// SourceMultiplicity is the source-end multiplicity of an action succession
// (SysML.xtext:878, 887, 1703; formal/2026-03-02): the `[m]` written before
// `then` (`[m] then b;`), or after it ahead of the member a member-attached
// `then` declares (`then [m] action b;`).
SourceMultiplicity *Multiplicity
// TargetMultiplicity is the crossing multiplicity written ahead of the
// target a `then` references (`then [m] b;`, SysML.xtext:1705
// TargetSuccession, whose ConnectorEnd takes one): the same end
// `succession first a then [m] b;` states.
TargetMultiplicity *Multiplicity
// SourceMember and TargetMember are the members a member-attached `then`
// (SysML.xtext EmptySuccessionMember) sequences when the member declares no
// name a reference could use — `then send fullyCharged() to self;`, `then
// loop action { … } until c;`. The notation binds such an end by position, so
// the end is that member itself rather than a name; they are the members
// beside the keyword as written, set once when the body is parsed.
SourceMember Node
TargetMember Node
// SourceImplied and TargetImplied mark an end the notation supplied rather
// than the author writing it: the source a one-name `then <target>;` takes
// from the member before it, and the ends of the edge a member-attached
// `then` desugars to. Such a name is a member's own, not a reference written
// in the model.
SourceImplied bool
TargetImplied bool
// Members are the body an action target succession carries
// (SysML.xtext:1698 ActionTargetSuccession ends in a UsageBody), and
// HasBody that it was written with one rather than ended by ';'.
Members []Node
HasBody bool
}
SuccessionEdge is sequential control flow in actions (source then target).
type TerminateStatement ¶
type TerminateStatement struct {
NodeBase
Target Node // occurrence to terminate; nil terminates the performing occurrence
}
TerminateStatement terminates an action or lifecycle. Syntax: terminate [<target>];
type TextualRepresentation ¶
type TextualRepresentation struct {
NodeBase
Ident Identification
Language string
BodySpan source.Span
}
TextualRepresentation is `[rep <id>] language s /* ... */`.
type TimeEvent ¶
type TimeEvent struct {
NodeBase
Duration Node // time expression (literal or variable)
Absolute bool // true for `at`, false for `after`
}
TimeEvent fires at a point in time. Absolute distinguishes `accept at <time>`, which fires at the given instant, from `accept after <duration>`, which fires that far after the source state is entered.
type TransitionEdge ¶
type TransitionEdge struct {
NodeBase
Source *QualifiedName // source state
Target *QualifiedName // target state
Trigger TriggerEvent // event that fires transition (interface, see below)
Guard Node // optional guard expression
Effect []Node // optional effect actions
}
TransitionEdge is a state machine transition.
type TransitionMember ¶
type TransitionMember struct {
NodeBase
Name string // the transition's own name, empty when anonymous
NameSpan source.Span // span of Name, empty for an anonymous transition
Source *QualifiedName // source state
Target *QualifiedName // target state
Trigger Node // optional trigger event (TimeEvent/ChangeEvent/etc)
// TriggerSpan spans the accepter the trigger keyword introduces
// (`accept A`), which is the element the accepter rules are about.
TriggerSpan source.Span
Guard Node // optional guard expression
// Effect holds the one action the `do` performs (SysML.xtext
// EffectBehaviorUsage): a declaration, a statement, or for `do { … }` the
// anonymous action usage whose Members are the block's items.
Effect []Node
HasEffect bool // a `do` was written, even one whose braces hold nothing
// Via is the port the trigger's message must arrive at
// (`accept :> ping via commPort`), nil when the trigger named none.
Via *QualifiedName
// TargetMultiplicity is the written target end of `then [m] target`,
// admitted on a guarded succession in an action body; nil where none is
// written.
TargetMultiplicity *Multiplicity
// Members and HasBody carry the body a transition may declare, since both
// TransitionUsage and TargetTransitionUsage end in ActionBody
// (`then starting { … }`).
Members []Node
HasBody bool
// IsSuccession records the GuardedSuccession form (SysML.xtext), the one
// an action body admits: `succession first a if g then b;`, or the same
// without its optional `succession`.
IsSuccession bool
}
TransitionMember represents a state transition in textual form, in either the standard spelling (SysML.xtext `TransitionUsage`)
transition [<name>] first <source> [accept <trigger>] [if <guard>]
[do <effect>] then <target>;
or the `transition <source> to <target> …` spelling OpenSysML also accepts.
type TriggerEvent ¶
type TriggerEvent interface {
Node
// contains filtered or unexported methods
}
TriggerEvent is the interface for state transition triggers.
type Trivia ¶
type Trivia struct {
Kind TriviaKind
Span source.Span
}
Trivia is a non-semantic token (notes/free comments) attached to a node for features like doc-comment hover and future formatting. Whitespace carries nothing a consumer reads and is not recorded.
type TriviaKind ¶
type TriviaKind int
TriviaKind classifies a trivia token attached to a node.
const ( TriviaComment TriviaKind = iota // REGULAR_COMMENT that is not a comment/doc/rep body TriviaLineNote // SL_NOTE TriviaBlockNote // ML_NOTE )
type Usage ¶
type Usage struct {
NodeBase
Prefixes []*PrefixMetadata
Kind UsageKind
// Keyword is the kind keyword as written. Several synonyms map to one Kind
// (`datatype`, `feature` and `attribute` all give UsageAttribute), so it is
// kept to tell those spellings apart. Empty where none was written: the
// anonymous action of a braced `entry { … }` or transition `do { … }`.
Keyword string
// PrefixKeyword is the keyword written ahead of the kind keyword to qualify
// it rather than to name the declaration: the `assert` of
// `assert constraint c : C` (SysML.xtext AssertConstraintUsage).
PrefixKeyword string
IsAbstract bool
IsVariation bool // 'variation' modifier: the usage is a variation point
IsVariant bool // declared with 'variant': a variant of the enclosing variation
IsReference bool
IsVariable bool // 'var' feature modifier
IsAll bool // 'all' multiplicity propagation modifier
IsEnd bool // 'end' feature modifier
IsChain bool // 'chain' feature modifier
IsConstant bool // 'constant' feature modifier
IsEvent bool // 'event' modifier for event-driven occurrences
IsIndividual bool // 'individual' modifier: OccurrenceUsage::isIndividual
// IndividualKeyword spans the `individual` written, zero when none was.
IndividualKeyword source.Span
// Portion is the `snapshot` or `timeslice` prefix of an occurrence usage
// (OccurrenceUsage::portionKind, SysML v2 8.3.9.11).
Portion PortionKind
IsAccept bool // 'accept' action for message consumption
// IsBodyParameter marks the `action [<name>] { … }` a loop or branch body is
// written as (SysML.xtext ActionBodyParameter), not a nested action node.
IsBodyParameter bool
// IsActionNode marks an action written as one node with its statement
// (`action s send x to r;`, SysML.xtext SendNode): Members hold that statement, not a body.
IsActionNode bool
// IsTerminate marks a terminate action usage (`action stop terminate;`,
// SysML.xtext TerminateActionUsage): a token reaching it ends the containing performance.
IsTerminate bool
// Terminates is the occurrence a terminate action usage names after its
// `terminate` (`action stop terminate process;`, SysML.xtext TerminateNode's
// NodeParameterMember); nil when it terminates the occurrence containing it.
Terminates *TerminateStatement
IsResult bool // declared with 'return': the result parameter of a calculation/expression
// IsNegated is the `not` of `assert not constraint { … }` and
// `assert not satisfy … by …`: the conditions are asserted to be false
// (Invariant::isNegated, SysML v2 §8.3.21.10).
IsNegated bool
// DeclaresRequirement is the `requirement` of `satisfy requirement r by v`:
// the satisfy/verify usage declares its requirement rather than referencing one.
DeclaresRequirement bool
Visibility Visibility
Direction FeatureDirection
IsComposite bool
// IsPortion is the `portion` of `portion feature p`: the feature's values
// are portions of its featuring instances (KerML Feature::isPortion).
IsPortion bool
// IsParallel is the `parallel` before a state body (StateUsage::isParallel).
IsParallel bool
IsDerived bool
IsOrdered bool
IsNonunique bool
Ident Identification
Relationships []*Relationship
Multiplicity *Multiplicity
// CrossFeature is the cross feature an end declares inline ahead of its own
// declaration (KerML.xtext OwnedCrossFeatureMember).
CrossFeature *CrossFeatureMember
Value Node
ValueOperatorSpan source.Span
// ValueIsDefault and ValueIsInitial are the `default` and `:=` of the value
// part (KerML FeatureValue::isDefault, isInitial).
ValueIsDefault bool
ValueIsInitial bool
Members []Node
HasBody bool
// Tier B connection/flow/port grammar. These are nil/zero for kinds
// that do not use them.
ConnectorEnds []*ConnectorEnd // connection / interface / allocation usage ends
FlowEnds *FlowEnds // flow usage ends
}
Usage is a `part` / `attribute` usage node (and all other usage kinds).
func (*Usage) ConjugatedTyping ¶
func (u *Usage) ConjugatedTyping() (*Relationship, bool)
ConjugatedTyping returns the usage's conjugated port typing (`: ~P`), if any.
func (*Usage) HasConjugatedTyping ¶
HasConjugatedTyping reports whether the usage declares a `: ~P` typing.
func (*Usage) IsAssumedConstraint ¶ added in v0.12.0
IsAssumedConstraint reports whether the usage is a requirement's `assume` constraint (a RequirementConstraintMembership of kind assumption).
func (*Usage) IsExhibitedState ¶
IsExhibitedState reports whether the usage is an `exhibit state s : S;` or an `exhibit s;`: a state the owner exhibits (SysML v2 ExhibitStateUsage).
func (*Usage) IsIncludedUseCase ¶
IsIncludedUseCase reports whether the usage is an `include use case u : U;` or an `include u;`: a use case the owner includes (SysML v2 IncludeUseCaseUsage).
func (*Usage) IsPerformedAction ¶
IsPerformedAction reports whether the usage is a `perform action a : A;` or a `perform a;`: an action the owner performs (SysML v2 PerformActionUsage).
func (*Usage) IsRequirementConstraint ¶
IsRequirementConstraint reports whether the usage is a requirement's `assume`/`require` constraint (SysML v2 RequirementConstraintMembership).
func (*Usage) IsStateAction ¶
IsStateAction reports whether the usage is a state's `entry a;`, `do a;` or `exit a;`, or the `entry action ...` form of one, each a performed action (SysML v2 StateSubactionMembership).
func (*Usage) IsSuccessionFlow ¶
IsSuccessionFlow reports whether the usage is a `succession flow`: a flow that also orders its ends (SysML v2 SuccessionFlowUsage).
func (*Usage) IsVariantReference ¶
IsVariantReference reports a bare `variant x;` (SysML.xtext VariantReference), a reference to an existing feature rather than a declaration of a new one. A VariantReference takes no usage prefix: `variant ref x;` declares the reference usage x (SysML-textual-bnf VariantUsageElement → ReferenceUsage).
func (*Usage) IsVerifiedRequirement ¶
IsVerifiedRequirement reports whether the usage is an objective's `verify r;` (SysML v2 RequirementVerificationMembership).
func (*Usage) NamedByReference ¶
NamedByReference reports whether an unnamed usage takes its name from the feature it references: the members whose membership kind makes the reference their naming feature in SysML v2 (perform, exhibit, include, assume/require, verify, frame, render, variant), never a plain reference subsetting like `assert q;` or `satisfy r;`.
func (*Usage) PerformedInvocation ¶
func (u *Usage) PerformedInvocation() *InvocationExpr
PerformedInvocation is the call an action usage performs as its value (`action a = tag(x);`); nil for any other usage or value.
func (*Usage) ReferenceSubsetting ¶
func (u *Usage) ReferenceSubsetting() *Relationship
ReferenceSubsetting returns the usage's OwnedReferenceSubsetting clause, or nil. The reference form of satisfy/verify (`satisfy r;`) is parsed as a plain subsetting of the requirement it names (SysML.xtext:2119, 2272).
type UsageKind ¶
type UsageKind int
UsageKind discriminates the concrete usage taxonomy element.
const ( UsagePart UsageKind = iota UsageAttribute // Tier A. UsageItem UsageOccurrence UsageIndividual UsageMetadata UsageEnumeration UsageView UsageViewpoint UsageRendering // UsageViewRendering is the rendering a view body names with `render` // (SysML.xtext ViewRenderingMember/ViewRenderingUsage, SysML v2 §8.3.26): a // RenderingUsage owned by a ViewRenderingMembership, which either references // an existing rendering (`render asTreeDiagram;`) or declares one // (`render rendering r : AsTree;`). UsageViewRendering UsageConcern // UsageFramedConcern is the concern a requirement, concern or viewpoint body // frames with `frame` (SysML.xtext FramedConcernMember/FramedConcernUsage, // SysML v2 §8.3.20): a ConcernUsage owned by a FramedConcernMembership, // either referencing an existing concern (`frame 'system breakdown';`) or // declaring one (`frame concern c : SafetyConcern;`). UsageFramedConcern // Tier B. UsageConnection UsageConnector UsageSuccession UsageFlow UsagePort UsageInterface UsageInteraction UsageAllocation UsageBinding // Tier C. UsageAction UsageState UsageTransition UsageStep UsageCalc UsageExpr UsageConstraint UsageRequirement UsageSatisfy // satisfy requirement ... by ... UsageSubject // UsageActor is an actor of a requirement, use case or viewpoint // (SysML.xtext ActorMember/ActorUsage, SysML v2 §8.3.19): a PartUsage owned // by an ActorMembership. The notation declares it; it has no reference form. UsageActor // UsageStakeholder is a stakeholder of a requirement, concern or viewpoint // (SysML.xtext StakeholderMember/StakeholderUsage, SysML v2 §8.3.19): a // PartUsage owned by a StakeholderMembership, declared like an actor. UsageStakeholder UsageObjective UsageCase UsageAnalysisCase UsageVerificationCase UsageUseCase // KerML structural kinds UsageBehavior UsageAssoc UsageStruct UsageClass UsagePredicate UsageBool )
func (UsageKind) IsAction ¶ added in v0.11.0
IsAction reports whether a usage of the kind is an action usage: an action, or a use case, which is a case, a calculation and so an action usage (SysML v2 §7.17, §7.19) whose body is an action body. An analysis or verification case is run as the calculation it is, not as an action.
type Visibility ¶
type Visibility int
Visibility mirrors SysML VisibilityKind.
const ( VisibilityDefault Visibility = iota // no explicit indicator VisibilityPublic VisibilityPrivate VisibilityProtected )
type WhileLoopActionNode ¶
type WhileLoopActionNode struct {
NodeBase
Kind LoopKind
Condition Node // boolean expression; nil for `for` and for `loop` without `until`
Body []Node // statements in loop body
// Until is the condition an `until` clause of a `while` loop tests after each
// iteration (`while c { … } until d;`), nil otherwise. A `loop` form records
// its own `until` condition in Condition.
Until Node
// Variable is the iteration variable a `for` loop declares. It is a member of
// the loop's own body scope, never of the enclosing behavior. Zero for the
// other loop forms.
Variable Identification
// VariableRelationships are the specializations the iteration variable was
// declared with (`for n : ScalarValues::Integer in …`), empty when it stated
// none: SysML.xtext ForVariableDeclaration is a full UsageDeclaration.
VariableRelationships []*Relationship
// Collection is the expression a `for` loop iterates over, nil otherwise.
Collection Node
}
WhileLoopActionNode represents a loop in an action body, in any of the three forms LoopKind names: `while c { … }`, `loop { … } until c;`, `for x in c { … }`.