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