Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 def any(self, ast):
     return model.Pattern('\w+|\S+')
Ejemplo n.º 3
0
 def newrange(self, ast):
     return model.Pattern('[%s]' % re.escape(ast))
Ejemplo n.º 4
0
 def range(self, ast):
     return model.Pattern('[%s-%s]' % (ast.first, ast.last))
Ejemplo n.º 5
0
 def negative(self, ast):
     neg = model.NegativeLookahead(ast)
     any = model.Pattern('.')
     return model.Sequence(AST(sequence=[neg, any]))
Ejemplo n.º 6
0
 def negative(self, ast):
     neg = model.LookaheadNot(ast)
     any = model.Pattern('.')
     return model.Sequence([neg, any])
Ejemplo n.º 7
0
 def pattern(self, ast, *args):
     return grammars.Pattern(ast)
Ejemplo n.º 8
0
 def newranges(self, ast):
     pattern = ''.join(ast)
     re.compile(pattern)
     return model.Pattern(pattern)
Ejemplo n.º 9
0
 def regexp(self, ast):
     pattern = ''.join(ast)
     re.compile(pattern)
     return model.Pattern(pattern)