Beispiel #1
0
    def test_name_generation(self):
        size = 10
        names = set()
        for i in range(0, size):
            names.add(MergeRule.get_merge_name())

        self.assertTrue(len(names) == size)
Beispiel #2
0
    def test_name_generation(self):
        size = 10
        names = set()
        for i in range(0, size):
            names.add(MergeRule.get_merge_name())

        self.assertTrue(len(names) == size)
Beispiel #3
0
 def _create_repeat_rule(self, rule):
     ORIGINAL, SEQ, TERMINAL = "original", "caster_base_sequence", "terminal"
     alts = [RuleRef(rule=rule)]#+[RuleRef(rule=sm) for sm in selfmod]
     single_action = Alternative(alts)
     max = settings.SETTINGS["miscellaneous"]["max_ccr_repetitions"]
     sequence = Repetition(single_action, min=1, max=max, name=SEQ)
     original = Alternative(alts, name=ORIGINAL)
     terminal = Alternative(alts, name=TERMINAL)
     class RepeatRule(CompoundRule):
         spec = "[<"+ORIGINAL+"> original] [<" + SEQ + ">] [terminal <"+TERMINAL+">]"
         extras = [ sequence, original, terminal ] 
         def _process_recognition(self, node, extras):
             original = extras[ORIGINAL] if ORIGINAL in extras else None
             sequence = extras[SEQ] if SEQ in extras else None
             terminal = extras[TERMINAL] if TERMINAL in extras else None
             if original is not None: original.execute()
             if sequence is not None:
                 for action in sequence:
                     action.execute()
             if terminal is not None: terminal.execute()
     return RepeatRule(name="Repeater"+MergeRule.get_merge_name())
Beispiel #4
0
 def _create_repeat_rule(self, rule):
     ORIGINAL, SEQ, TERMINAL = "original", "caster_base_sequence", "terminal"
     alts = [RuleRef(rule=rule)]#+[RuleRef(rule=sm) for sm in selfmod]
     single_action = Alternative(alts)
     max = settings.SETTINGS["miscellaneous"]["max_ccr_repetitions"]
     sequence = Repetition(single_action, min=1, max=max, name=SEQ)
     original = Alternative(alts, name=ORIGINAL)
     terminal = Alternative(alts, name=TERMINAL)
     class RepeatRule(CompoundRule):
         spec = "[<"+ORIGINAL+"> original] [<" + SEQ + ">] [terminal <"+TERMINAL+">]"
         extras = [ sequence, original, terminal ] 
         def _process_recognition(self, node, extras):
             original = extras[ORIGINAL] if ORIGINAL in extras else None
             sequence = extras[SEQ] if SEQ in extras else None
             terminal = extras[TERMINAL] if TERMINAL in extras else None
             if original is not None: original.execute()
             if sequence is not None:
                 for action in sequence:
                     action.execute()
             if terminal is not None: terminal.execute()
     return RepeatRule(name="Repeater"+MergeRule.get_merge_name())