global headers
op = t[2][1:-1].lower()
t[0] = (op, t[1], t[3])
- if op == 'pow':
+ if op == 'pow' and "math" not in headers:
headers.append("math")
def p_expression_not(t):
'expression : FUNCALL application'
t[0] = ('apply', t[1], tuple(t[2]))
global headers
- if t[1] in ('elog.', 'sqrt.'):
+ if t[1] in ('elog.', 'sqrt.') and "math" not in headers:
headers.append("math")
def p_expression_application(t):
def generate(out):
out.write("/* generated by the MAD compiler */\n\n")
- if headers:
- out.write('#include <math.h>\n\n')
+ for header in headers:
+ out.write('#include <%s.h>\n\n' % header)
if integers:
out.write('int ' + ', '.join(integers) + ';\t/* INTEGER */\n')
# Perform global analysis
analyze()
- print "Baz!", headers
if (dump_tuples):
for t in deck: