diff options
Diffstat (limited to 'ast2json/imachine2json.py')
-rwxr-xr-x | ast2json/imachine2json.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ast2json/imachine2json.py b/ast2json/imachine2json.py new file mode 100755 index 0000000..db1878c --- /dev/null +++ b/ast2json/imachine2json.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import json +import sys + +def imachine2json(ast): + ret = {} + if ast[0]['_type'] != 'Label': + raise TypeError('obj does not start with Label, wrong file?') + for label in ast: + if label['parameters'] is not None or label['hide']: + raise NotImplementedError() + ret[label['name']] = label + return ret + +with open(sys.argv[1], 'r') as f: + output = imachine2json(json.load(f)) + +json.dump(output, open(sys.argv[2], 'w'), separators=(',', ':')) |