def applies(self, element:Element):
     return (
         is_identifier(element.code) and
         identifier_in(element.code, self.sym_vals) and
         not is_head(element) and
         not element.is_last()
     )
 def applies(self, element:Element):
     #  p [ + ] n
     return (is_identifier(element.code) and
             identifier_in(element.code, self.sym_vals) and
             not element.is_first() and
             not element.is_last() and
             not is_form(element.parent, self.head_symbol_name))
 def applies(self, element: Element):
     return ((not isinstance(element.parent, Form)
              or not element.is_first()) and is_identifier(element.code)
             and identifier_in(element.code, self.sym_vals)
             and element.next is not None and element.next.code is not None
             and element.code.range.position_after.index
             == element.next.code.range.first_position.index)
 def applies(self, element:Element):
     return (
         not element.is_first() and
         is_token(element, Tokens.CONSTITUENT) and
         identifier_in(element.value, self.sym_vals) and
         is_not_none(element.prev, ".code.range.position_after.index", element, ".range.first_position.index") and
         element.prev.code.range.position_after.index == element.range.first_position.index
     )
 def applies(self, element: Element):
     return (not element.is_first()
             and is_token(element, Tokens.CONSTITUENT)
             and identifier_in(element.value, self.sym_vals) and
             is_not_none(element.prev, ".code.range.position_after.index",
                         element, ".range.first_position.index")
             and element.prev.code.range.position_after.index
             == element.range.first_position.index)
 def applies(self, element:Element):
     return (
         not element.is_first() and
         is_identifier(element.code) and
         identifier_in(element.code, self.sym_vals) and
         element.prev is not None and
         element.prev.code is not None and
         element.prev.code.range.position_after.index == element.code.range.first_position.index
     )
 def applies(self, element:Element):
     return (
         (not isinstance(element.parent, Form) or not element.is_first()) and
         is_identifier(element.code) and
         identifier_in(element.code, self.sym_vals) and
         element.next is not None and
         element.next.code is not None and
         element.code.range.position_after.index == element.next.code.range.first_position.index
     )
    def generate(self, element:Element, GC:GenerationContext):

        self.precheck(element, GC)
        head_name = element.code[0].code.name

        if not is_form(element.prev) or not identifier_in(element.prev.code[0], self.expected_names):
            raise CodeGenerationError(element.code[0].range, "`%s` form must appear after %s." % (head_name, self.expected_names))

        if GC.domain == ExpressionDomain:
            return expr_wrap(ast.NameConstant(None), GC)
        else:
            return []
    def generate(self, element: Element, GC: GenerationContext):

        self.precheck(element, GC)
        head_name = element.code[0].code.name

        if not is_form(element.prev) or not identifier_in(
                element.prev.code[0], self.expected_names):
            raise CodeGenerationError(
                element.code[0].range, "`%s` form must appear after %s." %
                (head_name, self.expected_names))

        if GC.domain == ExpressionDomain:
            return expr_wrap(ast.NameConstant(None), GC)
        else:
            return []
    def applies(self, element:Element):
        def _is_identifier_or_literal_immediately_after(next, element):
            return ((is_identifier(next) or is_literal(next)) and
                is_not_none(next, ".code.range.first_position.index") and
                element.code.range.position_after.index == next.code.range.first_position.index)

        def _is_begin_macro_token_immediately_after(next, element):
            return (is_token(next, Tokens.BEGIN_MACRO) and
                is_not_none(next, ".range.first_position.index") and
                element.code.range.position_after.index == next.range.first_position.index)

        next = element.next
        return (
            next is not None and
            (not (element.is_first() and is_form(element.parent)) or not next.is_last()) and
            is_identifier(element) and
            identifier_in(element.code, self.sym_vals) and
            is_not_none(element, ".code.range.position_after.index") and
            (_is_identifier_or_literal_immediately_after(next, element) or
             _is_begin_macro_token_immediately_after(next, element))
        )
    def applies(self, element: Element):
        def _is_identifier_or_literal_immediately_after(next, element):
            return ((is_identifier(next) or is_literal(next))
                    and is_not_none(next, ".code.range.first_position.index")
                    and element.code.range.position_after.index
                    == next.code.range.first_position.index)

        def _is_begin_macro_token_immediately_after(next, element):
            return (is_token(next, Tokens.BEGIN_MACRO)
                    and is_not_none(next, ".range.first_position.index")
                    and element.code.range.position_after.index
                    == next.range.first_position.index)

        next = element.next
        return (next is not None
                and (not (element.is_first() and is_form(element.parent))
                     or not next.is_last()) and is_identifier(element)
                and identifier_in(element.code, self.sym_vals)
                and is_not_none(element, ".code.range.position_after.index")
                and
                (_is_identifier_or_literal_immediately_after(next, element)
                 or _is_begin_macro_token_immediately_after(next, element)))
 def applies(self, element: Element):
     return (is_identifier(element.code)
             and identifier_in(element.code, self.sym_vals)
             and not element.is_first() and not element.is_last())
 def applies(self, element:Element):
     #  p [ + ] n
     return (is_identifier(element.code) and
             identifier_in(element.code, self.sym_vals) and
             not element.is_first() and
             not element.is_last())
 def applies(self, element: Element):
     return (not element.is_first() and is_identifier(element.code)
             and identifier_in(element.code, self.sym_vals)
             and element.prev is not None and element.prev.code is not None
             and element.prev.code.range.position_after.index
             == element.code.range.first_position.index)
Beispiel #15
0
 def applies(self, element: Element):
     #  p [ + ] n
     return (is_identifier(element.code)
             and identifier_in(element.code, self.sym_vals)
             and not element.is_first() and not element.is_last()
             and not is_form(element.parent, self.head_symbol_name))