Parsing & building¶
longeron.parser¶
Parsing front-end: SysML v2 and KerML text -> ANTLR parse trees.
- longeron.parser.Language¶
the two grammars this front-end parses (inferred from the file suffix by
parse_file()when not given explicitly)alias of
Literal[‘sysml’, ‘kerml’]
- class longeron.parser.ParseResult(tree, parser, tokens, language, source_name)[source]¶
Bases:
objectA parse tree plus the machinery needed to interpret it.
- longeron.parser.parse_sysml_text(text, source_name='<text>')[source]¶
Parse SysML v2 textual notation; raises
ParseErroron errors.- Return type:
- longeron.parser.parse_kerml_text(text, source_name='<text>')[source]¶
Parse KerML textual notation; raises
ParseErroron errors.KerML support is syntactic: you get a validated parse tree, not a model.
- Return type:
- longeron.parser.parse_file(path, language=None)[source]¶
Parse a
.sysmlor.kermlfile (language inferred from suffix).- Return type:
longeron.builder¶
Transform ANTLR parse trees of SysML v2 text into longeron.model objects.
The builder covers the full textual notation: packages, imports/aliases,
comments/docs, every definition and usage kind (including views,
interfaces, flows, allocations, and metadata), expressions, calculations,
constraints, requirements, actions (assign / if / loops / send / accept /
perform / successions) and state machines. There is no lossy fallback:
every construct maps to a typed model element, and the test suite asserts
that building produces zero Unsupported elements.
Unsupported survives only as a defensive dead-end for grammar rules
the dispatch fails to claim.
- longeron.builder.build_model(result)[source]¶
Build a model from a
ParseResult(SysML only).- Return type: