pyfcstm.model.base
Exportable interface definitions for AST and PlantUML representations.
This module defines lightweight abstract interfaces for model objects that can be exported into two target formats used throughout the package:
AstExportable- Interface for objects that can be converted topyfcstm.dsl.node.ASTNodeinstances.PlantUMLExportable- Interface for objects that can be rendered as PlantUML diagram syntax.
The interfaces are intentionally minimal and provide a clear contract for implementations that participate in AST serialization or diagram generation.
Example:
>>> from pyfcstm.model.base import AstExportable, PlantUMLExportable
>>> class MyNode(AstExportable, PlantUMLExportable):
... def to_ast_node(self):
... from pyfcstm.dsl import node as dsl_nodes
... return dsl_nodes.Name("example")
...
... def to_plantuml(self):
... return "state example"
>>> node = MyNode()
>>> str(node.to_ast_node())
'example'
>>> node.to_plantuml()
'state example'
AstExportable
- class pyfcstm.model.base.AstExportable[source]
Abstract base class for objects that can be exported to AST nodes.
Implementations should provide a concrete
to_ast_node()method that converts the object into apyfcstm.dsl.node.ASTNodeinstance.- Raises:
NotImplementedError – If the subclass does not implement
to_ast_node().
- to_ast_node() ASTNode[source]
Convert the object to an AST node representation.
- Returns:
An AST node representing this object.
- Return type:
- Raises:
NotImplementedError – This method must be implemented by subclasses.
Example:
>>> class Example(AstExportable): ... def to_ast_node(self): ... from pyfcstm.dsl import node as dsl_nodes ... return dsl_nodes.Name("example") >>> Example().to_ast_node() Name(name='example')
PlantUMLExportable
- class pyfcstm.model.base.PlantUMLExportable[source]
Abstract base class for objects that can be exported to PlantUML format.
Implementations should provide a concrete
to_plantuml()method that returns PlantUML diagram syntax as a string.- Raises:
NotImplementedError – If the subclass does not implement
to_plantuml().
- to_plantuml() str[source]
Convert the object to a PlantUML diagram representation.
- Returns:
A string containing PlantUML syntax representing this object.
- Return type:
str
- Raises:
NotImplementedError – This method must be implemented by subclasses.
Example:
>>> class Example(PlantUMLExportable): ... def to_plantuml(self): ... return "state example" >>> Example().to_plantuml() 'state example'