Ejemplo n.º 1
0
 def elements(self, ast):
     elements = [e for e in ast if e is not None]
     if not elements:
         return model.Void()
     elif len(elements) == 1:
         return elements[0]
     else:
         return model.Sequence(AST(sequence=elements))
Ejemplo n.º 2
0
 def negative(self, ast):
     neg = model.NegativeLookahead(ast)
     any = model.Pattern('.')
     return model.Sequence(AST(sequence=[neg, any]))
Ejemplo n.º 3
0
 def negative(self, ast):
     neg = model.LookaheadNot(ast)
     any = model.Pattern('.')
     return model.Sequence([neg, any])
Ejemplo n.º 4
0
 def sequence(self, ast, *args):
     seq = ast.sequence
     assert isinstance(seq, list), str(seq)
     if len(seq) == 1:
         return seq[0]
     return grammars.Sequence(ast)