Ejemplo n.º 1
0
 def vertical_interval_bound(self, bound):
     if does_match(Constant(value=int, kind=None), bound):
         return sir.Interval.Start, bound.value
     elif does_match(
             UnaryOp(op=USub, operand=Constant(value=int, kind=None)),
             bound):
         return sir.Interval.End, -bound.operand.value
     else:
         raise DuskSyntaxError(
             f"Unrecognized vertical intervals bound '{bound}'!", bound)
Ejemplo n.º 2
0
 def is_stencil(node) -> bool:
     return does_match(
         FunctionDef(
             name=_,
             args=_,
             body=_,
             decorator_list=FixedList(name(stencil_decorator.__name__)),
             returns=_,
             type_comment=_,
         ),
         node,
     )
Ejemplo n.º 3
0
def dispatch(rules: t.Dict[t.Any, t.Callable], node):
    for recognizer, rule in rules.items():
        if does_match(recognizer, node):
            return rule(node)
    raise DuskSyntaxError(f"Unrecognized node: '{node}'!", node)