gen_grammar.py.in 424 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/usr/bin/env python3

import subprocess, sys, shlex

cfile = sys.argv[1]
hfile = sys.argv[2]
yfile = sys.argv[3]

args = ['-d', '-v', '-ppriv_gst_parse_yy', yfile, '-o', cfile]
bison = [r'@BISON@'] + shlex.split(r'@BISON_ARGS@')
subprocess.check_call(bison + args)

prefix = '''
#ifdef HAVE_CONFIG_H
#include<config.h>
#endif
'''

contents = open(cfile).read()
content = prefix + contents
open(cfile, 'w').write(contents)