summaryrefslogtreecommitdiff
path: root/scripts/clean_c_api_trace.py
blob: efe8baa4355c15046a1629518134138c020f682c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env python

'''
Cleans up output from the C api, makes a runnable C file
'''

import sys

trace = open(sys.argv[1]).read()

start = trace.find('// beginning a Binaryen API trace')
if start >= 0:
  trace = trace[start:]

  while 1:
    start = trace.find('\n(')
    if start < 0:
      break
    end = trace.find('\n)', start + 1)
    assert end > 0
    trace = trace[:start] + trace[end + 2:]

  print trace