|
|
@ -150,6 +150,14 @@ def collapse_tokens(uncollapsed_tokens: list) -> list:
|
|
|
|
usefull_tokens.sort(key=operator.itemgetter('line_number'))
|
|
|
|
usefull_tokens.sort(key=operator.itemgetter('line_number'))
|
|
|
|
return usefull_tokens
|
|
|
|
return usefull_tokens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_token(removable: dict, tokens: list) -> list:
|
|
|
|
|
|
|
|
for index in range(0,len(tokens)):
|
|
|
|
|
|
|
|
token = tokens[index]
|
|
|
|
|
|
|
|
if token == removable:
|
|
|
|
|
|
|
|
del tokens[index]
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
return tokens
|
|
|
|
|
|
|
|
|
|
|
|
collapsed_tokens = collapse_tokens(tokens)
|
|
|
|
collapsed_tokens = collapse_tokens(tokens)
|
|
|
|
|
|
|
|
|
|
|
|
for index in range(0, len(collapsed_tokens)):
|
|
|
|
for index in range(0, len(collapsed_tokens)):
|
|
|
@ -159,4 +167,20 @@ for index in range(0, len(collapsed_tokens)):
|
|
|
|
collapsed_tokens[index]['function'] = function.pop()
|
|
|
|
collapsed_tokens[index]['function'] = function.pop()
|
|
|
|
params = coaless_tokens(token['params'], token['line_number'],collapsed_tokens.copy(), "variable_declaration")
|
|
|
|
params = coaless_tokens(token['params'], token['line_number'],collapsed_tokens.copy(), "variable_declaration")
|
|
|
|
collapsed_tokens[index]['params'] = params
|
|
|
|
collapsed_tokens[index]['params'] = params
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
minus = 0
|
|
|
|
|
|
|
|
for index in range(0, len(collapsed_tokens)):
|
|
|
|
|
|
|
|
token = collapsed_tokens[index - minus].copy()
|
|
|
|
|
|
|
|
if token['variant'] == 'function_declaration':
|
|
|
|
|
|
|
|
for part in token['body']:
|
|
|
|
|
|
|
|
collapsed_tokens = remove_token(part,collapsed_tokens.copy())
|
|
|
|
|
|
|
|
minus = minus + 1
|
|
|
|
|
|
|
|
if token['variant'] == 'function_call':
|
|
|
|
|
|
|
|
for part in token['function']['body']:
|
|
|
|
|
|
|
|
collapsed_tokens = remove_token(part,collapsed_tokens.copy())
|
|
|
|
|
|
|
|
minus = minus + 1
|
|
|
|
|
|
|
|
collapsed_tokens = remove_token(token['function'],collapsed_tokens.copy())
|
|
|
|
|
|
|
|
minus = minus + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(json.dumps(collapsed_tokens))
|
|
|
|
print(json.dumps(collapsed_tokens))
|
|
|
|