DSM Introspection¶
DSM classes provide parsing and introspection of Digital Substrate Model files.
When to use: Use DSMBuilder to parse .dsm files and introspect
the resulting definitions (structures, enumerations, attachments, functions).
Quick Start¶
from dsviper import DSMBuilder
# Parse DSM file
builder = DSMBuilder.assemble("model.dsm")
report, dsm_defs, defs = builder.parse()
# Check for parse errors
if report.has_error():
for err in report.errors():
print(f"Line {err.line()}: {err.message()}")
raise RuntimeError("DSM parse failed")
# Introspect structures
for struct in dsm_defs.structures():
print(f"Struct: {struct.type_name()}")
for field in struct.fields():
print(f" {field.name()}: {field.type_reference()}")
# Introspect attachments
for att in dsm_defs.attachments():
print(f"Attachment: {att.type_name()}")
print(f" Key: {att.key_type()}, Doc: {att.document_type()}")
# Inject constants for runtime use
defs.inject() # Creates MYAPP_A_*, MYAPP_S_*, etc.
Parsing¶
A class used to assemble a collection of DSM Definitions from various sources. |
|
A class used to represent a part of the assembled definitions. |
|
A class used to represent DSM definitions. |
|
DSMDefinitionsInspector(definitions). |
|
A class used to collect the error occurred while parsing the assembled definitions. |
|
A class used to represent a parse error. |
Model Elements¶
A class used to represent the definition of a concept. |
|
A class used to represent the definition of a club. |
|
A class used to represent the definition of a struct. |
|
A class used to represent the definition of a field for a struct. |
|
A class used to represent the definition of an enum. |
|
A class used to represent the definition of a case for an enum. |
|
A class used to represent the definition of an attachment. |
DSM Types¶
A class used to represent the type key<element_type>. |
|
A class used to represent the type vector<element_type>. |
|
A class used to represent the type set<element_type>. |
|
A class used to represent the type map<key_type, element_type>. |
|
A class used to represent the type xarray<element_type>. |
|
A class used to represent the type optional<element_type>. |
|
A class used to represent the type tuple<T0, ...>. |
|
A class used to represent the type vec<element_type, size>. |
|
A class used to represent the type vec<element_type, columns, rows>. |
|
A class used to represent the type variant<T0, ...>. |
|
A class used to represent a reference to a type. |
Functions¶
A class used to represent the definition of a function. |
|
A class used to represent the definition of a function pool. |
|
A class used to represent the definition of a function prototype. |
|
A class used to represent the definition of an attachment function. |
|
A class used to represent the definition of an attachment function pool. |
Literals¶
A class used to represent the definition of a literal value. |
|
A class used to represent the definition of a literal list. |