diff --git a/concrete_syntax/plantuml.py b/concrete_syntax/plantuml/renderer.py similarity index 99% rename from concrete_syntax/plantuml.py rename to concrete_syntax/plantuml/renderer.py index b291007..3cdeeac 100644 --- a/concrete_syntax/plantuml.py +++ b/concrete_syntax/plantuml/renderer.py @@ -1,3 +1,5 @@ +# PlantUML renderer + from services import scd, od from services.bottom.V0 import Bottom from transformation import ramify diff --git a/concrete_syntax/textual_cd/parser.py b/concrete_syntax/textual_cd/parser.py new file mode 100644 index 0000000..034b523 --- /dev/null +++ b/concrete_syntax/textual_cd/parser.py @@ -0,0 +1,28 @@ +grammar = r""" +%import common.WS_INLINE +%ignore WS_INLINE +%ignore COMMENT + +%declare _INDENT _DEDENT + +?start: (_NL | object )* + +IDENTIFIER: /[A-Za-z_][A-Za-z_0-9]*/ +COMMENT: /#.*/ + +# newline +_NL: /(\r?\n[\t ]*)+/ + +literal: INT + | STR + | BOOL + +INT: /[0-9]+/ +STR: /"[^"]*"/ + | /'[^']*'/ +BOOL: "True" | "False" + +object: [IDENTIFIER] ":" IDENTIFIER [link] _NL [_INDENT slot+ _DEDENT] +link: "(" IDENTIFIER "->" IDENTIFIER ")" +slot: IDENTIFIER "=" literal _NL +""" diff --git a/concrete_syntax/textual_od/parser.py b/concrete_syntax/textual_od/parser.py index f55f78b..736d64e 100644 --- a/concrete_syntax/textual_od/parser.py +++ b/concrete_syntax/textual_od/parser.py @@ -30,8 +30,8 @@ STR: /"[^"]*"/ | /'[^']*'/ BOOL: "True" | "False" -object: [IDENTIFIER] ":" IDENTIFIER [link] _NL [_INDENT slot+ _DEDENT] -link: "(" IDENTIFIER "->" IDENTIFIER ")" +object: [IDENTIFIER] ":" IDENTIFIER [link_spec] _NL [_INDENT slot+ _DEDENT] +link_spec: "(" IDENTIFIER "->" IDENTIFIER ")" slot: IDENTIFIER "=" literal _NL """ @@ -75,7 +75,7 @@ def parse_od(state, cs_text, mm): def literal(self, el): return el[0] - def link(self, el): + def link_spec(self, el): [src, tgt] = el return (src, tgt) diff --git a/experiments/exp_scd.py b/experiments/exp_scd.py index c924d2a..c59de90 100644 --- a/experiments/exp_scd.py +++ b/experiments/exp_scd.py @@ -11,7 +11,7 @@ from transformation.ramify import ramify from transformation import rewriter from services.bottom.V0 import Bottom from services.primitives.integer_type import Integer -from concrete_syntax import plantuml +from concrete_syntax.plantuml import renderer as plantuml from concrete_syntax.textual_od import parser, renderer import sys @@ -30,6 +30,12 @@ def main(): int_mm_id = UUID(state.read_value(state.read_dict(state.read_root(), "Integer"))) string_mm_id = UUID(state.read_value(state.read_dict(state.read_root(), "String"))) + conf = Conformance(state, scd_mm_id, scd_mm_id) + print("Conformance SCD_MM -> SCD_MM?", conf.check_nominal(log=True)) + # print("--------------------------------------") + # print(renderer.render_od(state, scd_mm_id, scd_mm_id, hide_names=False)) + # print("--------------------------------------") + def create_dsl_mm_api(): # Create DSL MM with SCD API dsl_mm_id = state.create_node() @@ -64,7 +70,6 @@ Man_weight:AttributeLink (Man -> Integer) name = "weight" optional = False afraidOf:Association (Man -> Animal) - source_lower_cardinality = 0 target_lower_cardinality = 1 Man_inh_Animal:Inheritance (Man -> Animal) Bear_inh_Animal:Inheritance (Bear -> Animal) diff --git a/services/od.py b/services/od.py index d0898ae..dd56143 100644 --- a/services/od.py +++ b/services/od.py @@ -333,5 +333,5 @@ def read_primitive_value(bottom, modelref: UUID, mm: UUID): elif typ_name == "Boolean": return Boolean(referred_model, bottom.state).read() else: - raise Exception("Unimplemented type:", host_type_name) + raise Exception("Unimplemented type:", typ_name)