def convert_keywords_to_identifiers(tokens): prev_token = Token('\n', 'newline', False) for token in tokens: if prev_token.text == 'type' and token.group != 'class': prev_token.group = 'identifier' prev_token = token
def convert_identifiers_to_labels(self): prev_2_token = Token('\n', 'newline', False) prev_token = Token('\n', 'newline', False) for token in self.tokens: if token.group == 'group' and token.text == ',' and \ prev_token.group == 'identifier' and \ prev_2_token.group == 'newline': prev_token.group = 'label' prev_token.is_operand = False if token.group not in ['whitespace']: prev_2_token = prev_token prev_token = token
def convert_values_to_functions(tokens, values): prev_token = Token('\n', 'newline', False) for token in tokens: if token.group == 'group' and token.text == '(' and \ prev_token.group == 'value' and prev_token.text in values: prev_token.group = 'function' if token.group not in [ 'whitespace', 'comment', 'line description' ]: prev_token = token return tokens