Пример #1
0
 def parse_concatenation(self):
     """
     Parse the string from its current index into a concatenation or an expression that can be contained by an concatenation.
     @return: a visitable regular expression object from the Regex package.
     """
     repetitions = [self.parse_qualified()]
     while self.next_is_not(u'|)'):
         repetitions.append(self.parse_qualified())
     if len(repetitions) > 1:
         return Regex.Concatenation(repetitions)
     else:
         return repetitions[0]
Пример #2
0
 def visit_concatenation(self, concatenation):
     new_concatenation = Regex.Concatenation([])
     for child in concatenation.children:
         child.accept(self)
         new_concatenation.children.append(self.stack.pop())
     self.stack.append(new_concatenation)