From e1fb066d8e932de1a2b721295b1a465c94183701 Mon Sep 17 00:00:00 2001 From: Marketa Opichalova <514349@mail.muni.cz> Date: Wed, 31 Jan 2024 09:50:03 +0100 Subject: [PATCH 1/4] enable direct usage of complexes --- eBCSgen/Parsing/ParseBCSL.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eBCSgen/Parsing/ParseBCSL.py b/eBCSgen/Parsing/ParseBCSL.py index 69915b4..1e4c43a 100644 --- a/eBCSgen/Parsing/ParseBCSL.py +++ b/eBCSgen/Parsing/ParseBCSL.py @@ -137,9 +137,9 @@ def to_side(self): EXTENDED_GRAMMAR = """ abstract_sequence: atomic_complex | atomic_structure_complex | structure_complex - atomic_complex: atomic ":" (cmplx_name|VAR) - atomic_structure_complex: atomic ":" structure ":" (cmplx_name|VAR) - structure_complex: structure ":" (cmplx_name|VAR) + atomic_complex: atomic ":" (VAR | value) + atomic_structure_complex: atomic ":" structure ":" (VAR | value) + structure_complex: structure ":" (VAR | value) variable: VAR "=" "{" cmplx_name ("," cmplx_name)+ "}" VAR: "?" From dcd488aee43f39a9a7e8b4c41507a675433511bb Mon Sep 17 00:00:00 2001 From: Marketa Opichalova <514349@mail.muni.cz> Date: Tue, 13 Feb 2024 09:50:10 +0100 Subject: [PATCH 2/4] zooming inserting --- eBCSgen/Parsing/ParseBCSL.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eBCSgen/Parsing/ParseBCSL.py b/eBCSgen/Parsing/ParseBCSL.py index 1e4c43a..406cf8f 100644 --- a/eBCSgen/Parsing/ParseBCSL.py +++ b/eBCSgen/Parsing/ParseBCSL.py @@ -348,6 +348,10 @@ def insert_struct_to_complex(self, struct, complex): if self.get_name(struct) == self.get_name(complex.children[i].children[0]): complex.children[i] = Tree('agent', [struct]) break + elif isinstance(complex.children[0].children[0].children[0].children[0], Tree): + complex.children[i].children[0] = Tree('agent', [struct]) + break + return complex def insert_atomic_to_complex(self, atomic, complex): From 7432dd57a692ae0064cce46be4fa5f0ffce01f83 Mon Sep 17 00:00:00 2001 From: Marketa Opichalova <514349@mail.muni.cz> Date: Tue, 13 Feb 2024 09:59:29 +0100 Subject: [PATCH 3/4] test cases for complexes in abstract sequence --- Testing/models/model_cmplx_in_abstr_seq1.txt | 5 +++++ Testing/models/model_cmplx_in_abstr_seq2.txt | 2 ++ Testing/parsing/test_cmplx_in_abstr_seq.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 Testing/models/model_cmplx_in_abstr_seq1.txt create mode 100644 Testing/models/model_cmplx_in_abstr_seq2.txt create mode 100644 Testing/parsing/test_cmplx_in_abstr_seq.py diff --git a/Testing/models/model_cmplx_in_abstr_seq1.txt b/Testing/models/model_cmplx_in_abstr_seq1.txt new file mode 100644 index 0000000..f03c61d --- /dev/null +++ b/Testing/models/model_cmplx_in_abstr_seq1.txt @@ -0,0 +1,5 @@ +#! rules +S{i}:A():A2::cell => A()::cell + +#! complexes +A2 = A().A() diff --git a/Testing/models/model_cmplx_in_abstr_seq2.txt b/Testing/models/model_cmplx_in_abstr_seq2.txt new file mode 100644 index 0000000..801026b --- /dev/null +++ b/Testing/models/model_cmplx_in_abstr_seq2.txt @@ -0,0 +1,2 @@ +#! rules +S{i}:A():A().A()::cell => A()::cell diff --git a/Testing/parsing/test_cmplx_in_abstr_seq.py b/Testing/parsing/test_cmplx_in_abstr_seq.py new file mode 100644 index 0000000..068f47d --- /dev/null +++ b/Testing/parsing/test_cmplx_in_abstr_seq.py @@ -0,0 +1,17 @@ +import pytest + +from Testing.models.get_model_str import get_model_str +import Testing.objects_testing as objects + + +def test_complexes_in_abstract_sequence(): + # is allowed + model = get_model_str("model_cmplx_in_abstr_seq1") + ret1 = objects.model_parser.parse(model) + assert ret1.success + + # should be allowed + model = get_model_str("model_cmplx_in_abstr_seq2") + ret2 = objects.model_parser.parse(model) + assert ret2.success + assert ret1.data == ret2.data From ef609a7c007b001c082b3d83d97c6065b36701e3 Mon Sep 17 00:00:00 2001 From: Marketa Opichalova <514349@mail.muni.cz> Date: Mon, 26 Feb 2024 20:37:36 +0100 Subject: [PATCH 4/4] fix incorrect parsed object comparison in TransformAbstractSyntax --- eBCSgen/Parsing/ParseBCSL.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eBCSgen/Parsing/ParseBCSL.py b/eBCSgen/Parsing/ParseBCSL.py index 651494c..e70646c 100644 --- a/eBCSgen/Parsing/ParseBCSL.py +++ b/eBCSgen/Parsing/ParseBCSL.py @@ -412,12 +412,12 @@ def insert_struct_to_complex(self, struct, complex): # search same name structs - if they contain atomics with matching names, they are considered incompatible for j in range(len(struct.children[1].children)): for k in range( - len(complex.children[i].children[0].children[1].children) + len(search.children[i].children[0].children[1].children) ): if self.get_name( struct.children[1].children[j] ) == self.get_name( - complex.children[i].children[0].children[1].children[k] + search.children[i].children[0].children[1].children[k] ): struct_found = False break