var = t[1]
t[0] = ('variable', var)
refcount[var] = refcount.get(var, 0) + 1
- if var not in integers + bools + floats + untyped:
+ if var not in integers + bools + doubles + untyped:
untyped.append(var)
# Error handling
import sys, re
integers = []
-floats = []
+doubles = []
bools = []
dimensions = {}
static = {}
def analyze():
"Gather variable types and determine function boundaries."
- global integers, floats, bools, deck
+ global integers, doubles, bools, deck
# We may need to generate a pseudo-function call
if deck[0][3][0] != 'external_function':
deck = [(deck[0][0], 0, None, ('entry', ('apply', 'main.',())))] + deck
declare(var, integers)
elif statement[0] == 'substitution':
var = statement[1]
- if var not in integers + bools + floats + untyped:
+ if var not in integers + bools + doubles + untyped:
untyped.append(var)
elif statement[0] in ('read', 'print'):
pass
i = 1
while str[i] in '0123456789.':
i += 1
- res += ('%' + str[1:i] + 'f') * count
+ res += ('%' + str[1:i] + 'g') * count
str = str[i:]
elif str[0] == 'H':
if write:
if bools:
out.write('int ' + ', '.join(bools) + ';\t/* boolean */\n')
if untyped:
- out.write('float ' + ', '.join(untyped) + ';\t/* untyped */\n')
- if floats:
- out.write('float ' + ', '.join(floats) + ';\n')
+ out.write('double ' + ', '.join(untyped) + ';\t/* untyped */\n')
+ if doubles:
+ out.write('double ' + ', '.join(doubles) + ';\n')
for (id, value) in static.items():
out.write('static const char *%s\t= "%s";\n' % (id,fmt_convert(value)))
for (file, line, label, statement) in deck:
if statement[0] == 'internal':
# FIXME: someday, deduce when return is of integral type
- out.write('float %s {return %s;}\n' % \
+ out.write('double %s {return %s;}\n' % \
(print_expr(('apply', statement[1], statement[2])), print_expr(statement[3])))
indent = 0