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))
def negative(self, ast): neg = model.NegativeLookahead(ast) any = model.Pattern('.') return model.Sequence(AST(sequence=[neg, any]))
def negative(self, ast): neg = model.LookaheadNot(ast) any = model.Pattern('.') return model.Sequence([neg, any])
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)