Commit 3a6c0e07 authored by Thomas Huetter's avatar Thomas Huetter

fixed bugs in python asts; still not working

parent 4c05cc9d
......@@ -14,7 +14,7 @@ import json
def print_tree(json_tree, index):
print('{' + json_tree[index]['type'], end='')
if 'value' in json_tree[index]:
print('{' + json_tree[index]['value'].replace('\r','').replace('\n','').strip().translate(str.maketrans({"{": r"\{",
print('{' + json_tree[index]['value'].replace('\r','').replace('\n','').replace('\t', '').strip().translate(str.maketrans({"{": r"\{",
"}": r"\}",
"\\": r"\\"}))
+ '}', end='')
......@@ -34,4 +34,4 @@ with open(args.inputfile) as f:
for line in f:
json_tree = json.loads(line)
print_tree(json_tree, 0)
print()
\ No newline at end of file
print()
#!/bin/bash
# | sort by number of nodes (equivalent to number of "{")
cat $1 | awk '{print gsub("{","{"), $0}' | sort -n | cut -d' ' -f2- > "${1%.bracket}_sorted.bracket"
# | sort by number of nodes (equivalent to number of "{"), remove duplicates
cat $1 | perl -F{ -lane 'print "$#F $_"' | sort -n | cut -d' ' -f2- > "${1%.bracket}_sorted.bracket"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment