def p_boollist_continue(t):
'boollist : boollist COMMA NAME'
t[0] = t[1] + [t[3]]
- typedict[currentfunc][t[1]] = 'bool'
+ typedict[currentfunc][t[3]] = 'bool'
## CONTINUE
def p_statement_continue(t):
dimensions = {}
static = {}
format = {}
+hasmain = False
# Map MAD intrinsics to C library functions
madfunc_map = {'elog':'log'}
break
if deck[i][3][0] != 'external_function':
deck.insert(i, (deck[i][0], i, None, ('entry', 'main.',())))
-
+ hasmain = True
else:
for i in range(len(deck)):
(file, line, label, statement) = deck[i]
if statement[0] == 'end_function' and i < len(deck)-1 and deck[i+1][2][0] != 'extern':
deck.insert(i, (file, line, None, ('entry', 'main.', ())))
+ hasmain = True
# Mine the code for compile-time directives
for (file, line, label, statement) in deck:
if statement[0] == 'boolean':
sys.stderr.write("mad: -o is required with multiple sourcefiles.\n")
sys.exit(1)
else:
- if not target:
- target = arguments[0][:-4]
for file in arguments:
stem = file[:-4]
out = open(stem + ".c", "w")
srclist = " ".join(map(lambda x: x[:-4] + ".c", arguments))
if binary:
# Must be gcc, else compilation of internal functions will fail
- compile = "gcc %s -lm -o %s" % (srclist, target)
+ if hasmain:
+ if not target:
+ target = arguments[0][:-4]
+ compile = "gcc %s -lm -o %s" % (srclist, target)
+ else:
+ if not target:
+ target = arguments[0][:-4] + ".o"
+ compile = "gcc -c %s -o %s" % (srclist, target)
if os.system(compile) == 0:
os.system("rm -f " + srclist)