Runtime services for the KerML and SysML v2 metamodels defined in hcf-models: textual parser, writer, expression evaluator, behavior execution engine, parametric (Z3/SMT) analysis, indexing, and document generation. Built on HMF.
org.openmbee.hivecore/
├── settings/ # Runtime configuration / settings
├── kerml/
│ ├── parser/ visitors/base/ # ANTLR-driven KerML textual parser
│ ├── generator/ base/ # KerML textual writer
│ ├── eval/ lib/ # KerML expression evaluator + kernel
│ │ # function libraries (Base, Data,
│ │ # Control, Sequence, Numerical,
│ │ # Boolean, String, Integer, Real,
│ │ # Rational, Natural, Collection, Trig)
│ ├── exec/ # Token-passing behavior execution
│ ├── analysis/ # Z3/SMT parametric analysis
│ ├── index/ # Element and name indexes
│ ├── io/ # KerML file I/O helpers
│ └── docgen/ # KerML-driven document generation
└── sysml/
└── parser/ visitors/base/ # SysML v2 textual parser
ANTLR-based parser with the visitor pattern:
- High-level
KerMLModelAPI:parseString(...),parseFile(...). - Custom
KerMLErrorListenercollects parse errors with file/line/column. ReferenceCollector+ReferenceResolverperform deferred resolution of forward references after a parse pass.- ~80 visitor classes grouped by metaclass domain over base visitors.
- Deterministic UUIDs for library elements (UUID v5 from qualified names), so library cross-references remain stable across runs.
Generates KerML textual notation from HMFObject model graphs:
KerMLWritertop-level API:write(namespace),writeToFile(...).GeneratorFactoryroutes eachHMFObjectto a type-specific generator.- Base generators for Element, Feature, Classifier, Type.
Native tree-walking evaluator over KerML Expression model elements
(distinct from textual-OCL evaluation). Dispatches on metaclass:
LiteralExpression→Sequence{self}.OperatorExpression→ evaluate arguments, apply viaKernelFunctionLibrary.InvocationExpression→ bind arguments to parameters, evaluate body.FeatureReferenceExpression/FeatureChainExpression→ navigate.SelectExpression/CollectExpression/IndexExpression→ collection ops.NullExpression→ empty sequence.
Function libraries under eval/lib mirror the KerML Kernel Function Library
files: arithmetic and comparison, boolean (and, or, not, xor,
implies), strings, sequences, numerics, trig, and control flow (if, ??,
collect, select, reject, forAll, exists, reduce, …).
KerMLExpressionOperationHandler wires the evaluator into HMFEngine by
replacing the corresponding metaclass operations with native handlers.
Token-passing execution semantics for Behaviors composed of Steps connected by Successions, with data transfer via Flows:
- Tokens:
ControlToken,ObjectToken. - Step state machine: WAITING → READY → EXECUTING → COMPLETED.
ExecutionGraphbuilds topology from Steps + SuccessionEdges + FlowEdges.ExecutionContextprovides lexical scoping with parent chains for nested invocations.BehaviorExecutionEngine.execute(behavior, inputs)runs to completion with amaxStepscap; outgoing Successions evaluate guard conditions via the expression evaluator before propagation.
KerML-aware wrapper over the Z3/SMT solver in hmf-runtime:
ParametricAnalysisServiceextracts constraints fromInvariantelements, infers Z3 sorts from Feature types (Integer → INT, Real → REAL, Boolean → BOOL), and exposes:solveConstraints— find satisfying assignments.checkRequirementConsistency— detect conflicting requirements.tradeStudy— optimize an objective subject to constraints.
- Inherited-feature semantics: direct constraints on inherited features
throw
InheritedFeatureConstraintError; redefinitions must be created explicitly in the subtype.
Generates documents from a model using KerML view definitions.
Indexes elements by qualified name and other lookup keys to accelerate resolution.
ANTLR-based parser for SysML v2 textual notation, structured analogously to the KerML parser.
Bundled standard libraries under src/main/resources/:
kerml-library/— Kernel Semantic Library, Kernel Function Library, Kernel Data Type Library, DocGen Library, Views Library.sysml-library/— Quantities and Units, Systems Library, Analysis, Cause and Effect, Geometry, Metadata.
./gradlew build --no-configuration-cache
./gradlew test --no-configuration-cache
# Regenerate ANTLR sources after grammar changes
./gradlew generateGrammarSource --no-configuration-cacheRequires JDK 21 and Gradle 9.x.
- hmf — base framework: HMFEngine, OCL, Z3 solver, mounts.
- hcf-models — KerML / SysML metamodels and generated APIs.
- hcf-server — REST API that wraps this runtime.
- hcf-intellij — IntelliJ plugin that embeds this runtime.