• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..01-Nov-2020-

LightSwitch.rpyH A D27-Dec-201826.6 KiB1,0251,022

README.mdH A D02-Dec-2019968 3522

rhapsody.txH A D02-Dec-2019336 2518

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