def pattern(self, ast, *args): pattern = ast try: re.compile(pattern, RE_FLAGS) except (TypeError, re.error) as e: raise FailedSemantics('regexp error: ' + str(e)) return grammars.Pattern(pattern)
def any(self, ast): return model.Pattern('\w+|\S+')
def newrange(self, ast): return model.Pattern('[%s]' % re.escape(ast))
def range(self, ast): return model.Pattern('[%s-%s]' % (ast.first, ast.last))
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 pattern(self, ast, *args): return grammars.Pattern(ast)
def newranges(self, ast): pattern = ''.join(ast) re.compile(pattern) return model.Pattern(pattern)
def regexp(self, ast): pattern = ''.join(ast) re.compile(pattern) return model.Pattern(pattern)