scrall 0.5.0__tar.gz → 0.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scrall might be problematic. Click here for more details.

Files changed (26) hide show
  1. {scrall-0.5.0/src/scrall.egg-info → scrall-0.6.1}/PKG-INFO +3 -2
  2. {scrall-0.5.0 → scrall-0.6.1}/pyproject.toml +1 -1
  3. scrall-0.6.1/src/scrall/__init__.py +1 -0
  4. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/__main__.py +4 -1
  5. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/parse/scrall.peg +15 -13
  6. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/parse/visitor.py +21 -50
  7. {scrall-0.5.0 → scrall-0.6.1/src/scrall.egg-info}/PKG-INFO +3 -2
  8. {scrall-0.5.0 → scrall-0.6.1}/src/scrall.egg-info/SOURCES.txt +1 -0
  9. scrall-0.6.1/tests/test_delete.py +22 -0
  10. {scrall-0.5.0 → scrall-0.6.1}/tests/test_ping_actions.py +7 -8
  11. scrall-0.5.0/src/scrall/__init__.py +0 -1
  12. {scrall-0.5.0 → scrall-0.6.1}/LICENSE +0 -0
  13. {scrall-0.5.0 → scrall-0.6.1}/MANIFEST.in +0 -0
  14. {scrall-0.5.0 → scrall-0.6.1}/README.md +0 -0
  15. {scrall-0.5.0 → scrall-0.6.1}/setup.cfg +0 -0
  16. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/exceptions.py +0 -0
  17. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/log.conf +0 -0
  18. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/parse/__init__.py +0 -0
  19. {scrall-0.5.0 → scrall-0.6.1}/src/scrall/parse/parser.py +0 -0
  20. {scrall-0.5.0 → scrall-0.6.1}/src/scrall.egg-info/dependency_links.txt +0 -0
  21. {scrall-0.5.0 → scrall-0.6.1}/src/scrall.egg-info/entry_points.txt +0 -0
  22. {scrall-0.5.0 → scrall-0.6.1}/src/scrall.egg-info/requires.txt +0 -0
  23. {scrall-0.5.0 → scrall-0.6.1}/src/scrall.egg-info/top_level.txt +0 -0
  24. {scrall-0.5.0 → scrall-0.6.1}/tests/test_selection.py +0 -0
  25. {scrall-0.5.0 → scrall-0.6.1}/tests/test_signals.py +0 -0
  26. {scrall-0.5.0 → scrall-0.6.1}/tests/test_state_actions.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: scrall
3
- Version: 0.5.0
3
+ Version: 0.6.1
4
4
  Summary: Starr's Concise Relational Action Language - For Shlaer-Mellor Executable UML
5
5
  Author-email: Leon Starr <leon_starr@modelint.com>
6
6
  License: MIT License
@@ -42,6 +42,7 @@ Requires-Dist: twine; extra == "build"
42
42
  Provides-Extra: dev
43
43
  Requires-Dist: bump2version; extra == "dev"
44
44
  Requires-Dist: pytest; extra == "dev"
45
+ Dynamic: license-file
45
46
 
46
47
  # Scrall Action Language
47
48
  Scrall = Starr's Concise Relational Action Language
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scrall"
7
- version = "0.5.0"
7
+ version = "0.6.1"
8
8
  description = "Starr's Concise Relational Action Language - For Shlaer-Mellor Executable UML"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Leon Starr", email = "leon_starr@modelint.com" }]
@@ -0,0 +1 @@
1
+ version = "0.6.1"
@@ -4,11 +4,14 @@ __main__.py
4
4
  Scrall Parser
5
5
  """
6
6
 
7
+ # System
7
8
  import logging
8
9
  import logging.config
9
10
  import sys
10
11
  import argparse
11
12
  from pathlib import Path
13
+
14
+ # Scrall
12
15
  from scrall import version
13
16
  from scrall.parse.parser import ScrallParser
14
17
 
@@ -66,7 +69,7 @@ def main():
66
69
  d = args.debug
67
70
  result = ScrallParser.parse_file(file_input=fpath, debug=d)
68
71
 
69
- logger.info("No problemo") # We didn't die on an exception, basically
72
+ # logger.info("No problemo") # We didn't die on an exception, basically
70
73
  print("\nNo problemo")
71
74
 
72
75
 
@@ -1,12 +1,10 @@
1
1
  activity = LINEWRAP* execution_unit* EOF
2
- execution_unit = LINEWRAP* (output_flow / (statement_set sequence_token?)) EOL+
3
- output_flow = OUTPUT SP+ scalar_expr
4
- OUTPUT = '=>>'
2
+ execution_unit = LINEWRAP* statement_set sequence_token? LINEWRAP+
5
3
  statement_set = SP* sequenced_statement_set / component_statement_set
6
4
  sequenced_statement_set = sequence_token* (block / statement)
7
5
  component_statement_set = block / LINEWRAP* statement
8
6
  block = SP* '{' execution_unit* '}'
9
- statement = table_assignment / new_lineage / new_instance / update_ref / delete / migration / scalar_assignment / signal_action / switch / decision / inst_assignment / call / iteration
7
+ statement = table_assignment / new_lineage / new_instance / update_ref / delete / migration / scalar_assignment / signal_action / switch / decision / inst_assignment / call / iteration / output_flow
10
8
 
11
9
  // Explicit sequence using control flow inputs and outputs
12
10
  sequence_token = SP* '<' token_name '>' SP* // Named control flow
@@ -47,7 +45,7 @@ RENAME = '>>'
47
45
  // Decision action
48
46
  decision = scalar_expr SP* true_result false_result? // Control flow version of an if-then
49
47
  true_result = DECISION_OP SP* component_statement_set
50
- false_result = SP* FALSE_RESULT_OP SP* component_statement_set // Else
48
+ false_result = (LINEWRAP* / SP*) FALSE_RESULT_OP SP* component_statement_set // Else
51
49
  FALSE_RESULT_OP = ':'
52
50
 
53
51
  // Switch action
@@ -60,9 +58,8 @@ enum_value = '_' name // Scalar switch has enum value cases
60
58
  DECISION_OP = '?'
61
59
 
62
60
  // Signal action
63
- signal_action = signal_choice / signal
61
+ signal_action = signal_spec SP+ (signal_dest / ee_dest)
64
62
  signal = signal_spec SP+ (signal_dest / ee_dest)
65
- signal_choice = scalar_expr SP* DECISION_OP (LINEWRAP? / SP+) signal_spec SP* SIGNAL_OP SP* '|' SP+ signal_spec SP* signal_dest
66
63
  signal_spec = name supplied_params?
67
64
  signal_dest = SIGNAL_OP (LINEWRAP / SP+) instance_set assigner_partition? (SP+ delay)?
68
65
  ee_dest = ASYNCH SP* name
@@ -89,6 +86,10 @@ migration = instance_set? SP* '>>' SP* new_inst_init
89
86
  // Iteration
90
87
  iteration = '<<' SP* instance_set SP* '>>' SP* component_statement_set
91
88
 
89
+ // Output flow action
90
+ output_flow = OUTPUT SP+ scalar_expr
91
+ OUTPUT = '=>>'
92
+
92
93
  // Instance set
93
94
  instance_set = new_instance / ((operation / prefix_name / path) (reflexive_selection / selection / operation / path)*)
94
95
  selection = '(' SP* select_phrase SP* ')'
@@ -108,13 +109,13 @@ attr_init = '(' SP* (attr_value_init (',' SP+ attr_value_init)* SP*)? ')' // all
108
109
  attr_value_init = (name SP? ':' SP+ scalar_expr )*
109
110
  update_ref = (instance_set SP+)? to_ref // relate or unrelated to me or explicit instance_set
110
111
  to_ref = '&' rnum SP+ instance_set (',' SP+ instance_set)? // non-associative or associative reference
111
- delete = '!*' SP* instance_set
112
+ delete = '!*' SP* instance_set (',' SP+ instance_set) // supports multi-delete transaction
112
113
 
113
114
  // Scalar call
114
115
  //scalar_call = scalar_expr
115
116
 
116
117
  // math and boolean operator precedence
117
- scalar_assignment = scalar_output_set SP* SCALAR_ASSIGN SP* scalar_expr projection?
118
+ scalar_assignment = scalar_output_set SP* SCALAR_ASSIGN SP* (scalar_expr projection?) (',' SP* scalar_expr projection?)*
118
119
  scalar_output_set = flow_output (',' SP* flow_output)*
119
120
  flow_output = name (TYPE_ASSIGN name)?
120
121
  projection = '.' (name / '(' ( (ALL / (name (',' SP+ name)*) )? ')'))
@@ -139,7 +140,7 @@ prefix_name = ORDER? name
139
140
  scalar_op = name supplied_params
140
141
 
141
142
  // name of type and name of value selected
142
- type_selector = name '[' SP* (name SP*)? ']'
143
+ type_selector = name '[' SP* selected_value? SP* ']'
143
144
 
144
145
  reflexive_selection = HIPPITY_HOP scalar_expr (SP* '|' COMPARE '|')?
145
146
  HIPPITY_HOP = FAR_HOP / NEAR_HOP
@@ -147,9 +148,9 @@ NEAR_HOP = '/~/'
147
148
  FAR_HOP = '/~|'
148
149
 
149
150
  SCALAR_ASSIGN = '='
150
- OR = 'or' / 'OR'
151
- AND = 'and' / 'AND' / ';' // ; shorthand for anding attr comparisons in a selection phrase
152
- NOT = '!' / 'not' / 'NOT'
151
+ OR = 'OR'
152
+ AND = 'AND' / ';' // ; shorthand for anding attr comparisons in a selection phrase
153
+ NOT = '!' / 'NOT'
153
154
  EQUAL = '==' / '!=' / ':'
154
155
  COMPARE = '>=' / '>' / '<=' / '<'
155
156
  UNARY_MINUS = "-"
@@ -165,6 +166,7 @@ path = hop+ // path to some instance set
165
166
  hop = '/' (rnum / name) // just a sequence of rels and phrase or class names
166
167
 
167
168
  // Names
169
+ selected_value = r'[^[\]\s]+' // any non-whitespace character except square brackets
168
170
  name = first_word (NAME_GLUE word)* // One word or a sequence of delimited words (name used for most model elements)
169
171
  NAME_GLUE = r'[ _]' // delmits words within a name
170
172
  rnum = r'O?R[1-9][0-9]*' // Relationship number (name used for relationships)
@@ -29,7 +29,7 @@ Execution_Unit_a = namedtuple('Execution_Unit_a', 'statement_set output_token')
29
29
  Seq_Statement_Set_a = namedtuple('Seq_Statement_Set_a', 'input_tokens statement block')
30
30
  Comp_Statement_Set_a = namedtuple('Comp_Statement_Set_a', 'statement block')
31
31
  Decision_a = namedtuple('Decision_a', 'input true_result false_result')
32
- Delete_Action_a = namedtuple('Delete_Action_a', 'instance_set')
32
+ Delete_Action_a = namedtuple('Delete_Action_a', 'instance_sets')
33
33
  Case_a = namedtuple('Case_a', 'enums comp_statement_set')
34
34
  Switch_a = namedtuple('Switch_a', 'input_flow cases')
35
35
  MATH_a = namedtuple('MATH_a', 'op operands')
@@ -166,14 +166,11 @@ class ScrallVisitor(PTNodeVisitor):
166
166
 
167
167
  Every execution unit is terminated by a new line.
168
168
  """
169
- _logger.info('execution_unit = LINEWRAP* (output_flow / (statement_set sequence_token?)) EOL+')
169
+ _logger.info('LINEWRAP* statement_set sequence_token? LINEWRAP+')
170
170
  _logger.info(f' :: {node.value}')
171
171
  _logger.info(f">> {[k for k in children.results.keys()]}")
172
172
 
173
173
  _logger.info(f" < {children}")
174
- oflow = getresult('output_flow', children)
175
- if oflow:
176
- return Output_Flow_a(oflow[0])
177
174
  output_token = getresult('sequence_token', children)
178
175
  st_set = getresult('statement_set', children)
179
176
  result = Execution_Unit_a(output_token=output_token, statement_set=st_set)
@@ -641,21 +638,8 @@ class ScrallVisitor(PTNodeVisitor):
641
638
  # """
642
639
  # result = Asynch_a(*children)
643
640
 
644
- # Signal action
645
641
  @classmethod
646
642
  def visit_signal_action(cls, node, children):
647
- """
648
- """
649
- _logger.info("signal_action = signal_choice / signal")
650
- _logger.info(f' :: {node.value}')
651
-
652
- _logger.info(f" < {children}")
653
- result = children[0]
654
- _logger.info(f" > {result}")
655
- return result
656
-
657
- @classmethod
658
- def visit_signal(cls, node, children):
659
643
  """
660
644
  """
661
645
  _logger.info("signal = signal_spec (signal_dest / ee_dest)")
@@ -678,35 +662,6 @@ class ScrallVisitor(PTNodeVisitor):
678
662
  _logger.info(f" > {result}")
679
663
  return result
680
664
 
681
- @classmethod
682
- def visit_signal_choice(cls, node, children):
683
- """
684
- scalar_expr DECISION_OP signal_spec ':' signal_spec signal_dest
685
- """
686
- _logger.info("signal_choice = ")
687
- _logger.info(f' :: {node.value}')
688
-
689
- _logger.info(f" < {children}")
690
- expr = children[0]
691
- # Both signals in a choice always have the same destination and delay
692
- true_signal = Signal_a(
693
- event=children[1]['name'],
694
- supplied_params=children[1]['params'],
695
- dest=children[3]
696
- )
697
- false_signal = Signal_a(
698
- event=children[2]['name'],
699
- supplied_params=children[2]['params'],
700
- dest=children[3]
701
- )
702
- result = Signal_Choice_a(
703
- decision=expr,
704
- true_signal=true_signal,
705
- false_signal=false_signal,
706
- )
707
- _logger.info(f" > {result}")
708
- return result
709
-
710
665
  @classmethod
711
666
  def visit_signal_spec(cls, node, children):
712
667
  """
@@ -888,7 +843,7 @@ class ScrallVisitor(PTNodeVisitor):
888
843
  s = s if len(s) > 1 else s[0]
889
844
  p = children.results.get('name')
890
845
  if not p and not (isinstance(s, N_a) or isinstance(s, IN_a)):
891
- _logger.error(f"Paramenter name not supplied with expression value: [{children.results}]")
846
+ _logger.error(f"Parameter name not supplied with expression value: [{children.results}]")
892
847
  raise ScrallMissingParameterName(children.results)
893
848
  result = Supplied_Parameter_a(pname=s.name if not p else p[0].name, sval=s)
894
849
  _logger.info(f" > {result}")
@@ -923,6 +878,21 @@ class ScrallVisitor(PTNodeVisitor):
923
878
  _logger.info(f" > {result}")
924
879
  return result
925
880
 
881
+ # Output flow
882
+ def visit_output_flow(cls, node, children):
883
+ """
884
+ Final output of a synchronous activity (method, operation)
885
+ """
886
+ _logger.info("output_flow = OUTPUT SP+ scalar_expr")
887
+ _logger.info(f' :: {node.value}')
888
+
889
+ _logger.info(f" < {children}")
890
+
891
+ result = Output_Flow_a(children[0])
892
+ _logger.info(f" > {result}")
893
+ return result
894
+
895
+
926
896
  # Instance set
927
897
  @classmethod
928
898
  def visit_instance_set(cls, node, children):
@@ -1075,13 +1045,14 @@ class ScrallVisitor(PTNodeVisitor):
1075
1045
  @classmethod
1076
1046
  def visit_delete(cls, node, children):
1077
1047
  """
1048
+ '!*' SP* instance_set (',' SP+ instance_set)
1078
1049
  """
1079
- _logger.info("delete = '!*' instance_set")
1050
+ _logger.info("delete = '!*' SP* instance_set (',' SP+ instance_set)")
1080
1051
  _logger.info(f' :: {node.value}')
1081
1052
 
1082
1053
  _logger.info(f" < {children}")
1083
1054
  iset = children.results.get('instance_set')
1084
- result = Delete_Action_a(instance_set=iset)
1055
+ result = Delete_Action_a(instance_sets=iset)
1085
1056
  _logger.info(f" > {result}")
1086
1057
  return result
1087
1058
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: scrall
3
- Version: 0.5.0
3
+ Version: 0.6.1
4
4
  Summary: Starr's Concise Relational Action Language - For Shlaer-Mellor Executable UML
5
5
  Author-email: Leon Starr <leon_starr@modelint.com>
6
6
  License: MIT License
@@ -42,6 +42,7 @@ Requires-Dist: twine; extra == "build"
42
42
  Provides-Extra: dev
43
43
  Requires-Dist: bump2version; extra == "dev"
44
44
  Requires-Dist: pytest; extra == "dev"
45
+ Dynamic: license-file
45
46
 
46
47
  # Scrall Action Language
47
48
  Scrall = Starr's Concise Relational Action Language
@@ -16,6 +16,7 @@ src/scrall/parse/__init__.py
16
16
  src/scrall/parse/parser.py
17
17
  src/scrall/parse/scrall.peg
18
18
  src/scrall/parse/visitor.py
19
+ tests/test_delete.py
19
20
  tests/test_ping_actions.py
20
21
  tests/test_selection.py
21
22
  tests/test_signals.py
@@ -0,0 +1,22 @@
1
+ # test delete action
2
+
3
+ import pytest
4
+ from scrall.parse.parser import ScrallParser
5
+ from scrall.parse.visitor import Execution_Unit_a, N_a, INST_a, PATH_a, R_a, Seq_Statement_Set_a, Delete_Action_a
6
+
7
+ actions = [
8
+ ("!* siamese, /R1/Cat",
9
+ Execution_Unit_a(statement_set=Seq_Statement_Set_a(
10
+ input_tokens=None, statement=Delete_Action_a(
11
+ instance_sets=[N_a(name='siamese'),
12
+ INST_a(components=[PATH_a(hops=[R_a(rnum='R1'),
13
+ N_a(name='Cat')])])]), block=None), output_token=None)
14
+ ),
15
+ ]
16
+
17
+
18
+ @pytest.mark.parametrize("text, expected", actions)
19
+ def test_delete_action(text, expected):
20
+ parse = ScrallParser.parse_text(scrall_text=text, debug=False)[0]
21
+ print(parse)
22
+ assert parse[0] == expected
@@ -85,16 +85,15 @@ actions = [
85
85
  X=(0, 58)), block=None), output_token=None)
86
86
  ),
87
87
  ("=>> Accessible Shaft Level( Floor: nearest dest.Floor; Shaft )",
88
- Output_Flow_a(output=
89
- INST_a(components=[N_a(name='Accessible Shaft Level'),
88
+ Execution_Unit_a(statement_set=Seq_Statement_Set_a(input_tokens=None, statement=Output_Flow_a(
89
+ output=INST_PROJ_a(iset=INST_a(components=[N_a(name='Accessible Shaft Level'),
90
90
  Selection_a(card='*', criteria=BOOL_a(op='AND', operands=[
91
- BOOL_a(op='==', operands=[
92
- N_a(name='Floor'),
93
- INST_PROJ_a(iset=N_a(name='nearest dest'), projection=
94
- Projection_a(expand=None, attrs=[N_a(name='Floor')]))]),
95
- N_a(name='Shaft')]))]))
91
+ BOOL_a(op='==', operands=[N_a(name='Floor'),
92
+ INST_PROJ_a(iset=N_a(name='nearest dest'),
93
+ projection=Projection_a(expand=None, attrs=[N_a(name='Floor')]))]),
94
+ N_a(name='Shaft')]))]), projection=None)), block=None), output_token=None
95
+ )
96
96
  ),
97
-
98
97
  ]
99
98
 
100
99
 
@@ -1 +0,0 @@
1
- version = "0.5.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes