Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 01-Nov-2020 | - | ||||
LightSwitch.rpy | H A D | 27-Dec-2018 | 26.6 KiB | 1,025 | 1,022 | |
README.md | H A D | 02-Dec-2019 | 968 | 35 | 22 | |
rhapsody.tx | H A D | 02-Dec-2019 | 336 | 25 | 18 |
README.md
1# IBM Rational Rhapsody example 2 3See: 4 - https://www.reddit.com/r/Python/comments/4k50gf/textx_13_a_libtool_for_building_dsls_and_parsers/ 5 - http://stackoverflow.com/questions/36524566/pyparsing-recursion-of-values-list-ibm-rhapsody 6 7Example taken from https://github.com/mansam/exploring-rhapsody/blob/master/LightSwitch/LightSwitch.rpy 8 9 10To check and visualize meta-model and test model: 11 12 $ textx generate rhapsody.tx --target dot 13 $ textx generate LightSwitch.rpy --grammar rhapsody.tx --target dot 14 $ dot -Tpdf -O *dot 15 16Load from code: 17 18```python 19from textx import metamodel_from_file 20 21meta = metamodel_from_file('rhapsody.tx') 22model = meta.model_from_file('LightSwitch.rpy') 23``` 24 25 26`model` will be an instance of `RhapsodyModel` class described by the grammar. 27Each object attribute will be of a proper class defined by the grammar. 28 29```python 30print(model.root.name) 31for property in model.root.properties: 32 print(property.name, property.values) 33``` 34 35