def apply(self, element):
     form = element.parent
     next = element.next
     if is_identifier(next) or is_literal(next):
         new_form_element = form.wrap(element, next, Form)
     elif is_token(next, Tokens.BEGIN_MACRO):
         new_form_element = form.wrap(element, next.end, Form)
     else:
         raise ArrangementError(next.range.first_position, "Expected identifier, literal or begin-macro-token after '%s' identifier in position %s." %(element.value, element.range.first_position.nameless_str))
     new_form = new_form_element.code
     new_form.remove(element)
     new_form.prepend(element)
     return new_form_element.next
 def apply(self, element):
     form = element.parent
     next = element.next
     if is_identifier(next) or is_literal(next):
         new_form_element = form.wrap(element, next, Form)
     elif is_token(next, Tokens.BEGIN_MACRO):
         new_form_element = form.wrap(element, next.end, Form)
     else:
         raise ArrangementError(
             next.range.first_position,
             "Expected identifier, literal or begin-macro-token after '%s' identifier in position %s."
             % (element.value, element.range.first_position.nameless_str))
     new_form = new_form_element.code
     new_form.remove(element)
     new_form.prepend(element)
     return new_form_element.next
예제 #3
0
 def apply(self, element):
     form = element.parent
     next = element.next  # this is 'b'
     prev = element.prev  # this is 'a'
     if is_identifier(next) or is_literal(next) or is_form(next):
         new_form_element = form.wrap(prev, next, Form)
     elif is_token(next, Tokens.BEGIN_MACRO):
         # a . BEGIN_MACRO something END_MACRO dont want => (. a BEGIN_MACRO) something END_MACRO
         # actually want
         # a . BEGIN_MACRO something END_MACRO => (. a BEGIN_MACRO something END_MACRO)
         new_form_element = form.wrap(prev, next.end, Form)
     else:
         raise ArrangementError(
             element.range.position_after,
             "Expected identifier, literal, form or begin-macro-token after '%s' in position %s."
             %
             (element.code.name, element.range.first_position.nameless_str))
     new_form = new_form_element.code
     # at this point new_form = ⦅a X b⦆
     new_form.remove(element)
     # at this point new_form = ⦅a b⦆
     new_form.prepend(element)
     # at this point new_form = ⦅X a b⦆
     return new_form_element.next  # return the next position to be read
 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_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)