def p_expression_funcall0(t):
'expression : FUNCALL'
var = t[1]
- t[0] = ('variable', var)
+ t[0] = ('funptr', var[:-1])
refcount[var] = refcount.get(var, 0) + 1
def p_expression_name(t):
elif t[0] in ('intnum', 'doublenum'):
return t[1]
elif type(t) == type(()) and t[0] == 'range':
- if t[2] == ('intnum', '1'):
+ if t[2] == ('intnum', '0'):
return print_C_expr(('variable', t[1]))
else:
- return print_C_expr(('+',('variable', t[1]),('-',t[2],('intnum', '1'))))
+ return print_C_expr(('+',('variable', t[1]), t[2]))
else:
return '***'+`t`
rep = "\n" + returntypes.get(currentfunc, normalmode) + " " + currentfunc[:-1] + "("
defaulted = []
if len(statement) > 2:
- for (dummy, var) in statement[2]:
- declarator = ("*" * arraydepths.get(var, 0)) + var
- if var in typedict:
- rep += typedict[var] + " " + declarator + ", "
- del typedict[var]
- else:
- rep += normalmode + " " + declarator + ", "
- defaulted.append(var)
+ for (vtype, var) in statement[2]:
+ if vtype == 'funptr':
+ # we lose if a passed-in function has a type other than the
+ # normal mode -- there's no way to deduce this.
+ rep += "%s (*%s)()" % (normalmode, var)
+ elif vtype == 'variable':
+ declarator = ("*" * arraydepths.get(var, 0)) + var
+ if var in typedict:
+ rep += typedict[var] + " " + declarator + ", "
+ del typedict[var]
+ else:
+ rep += normalmode + " " + declarator + ", "
+ defaulted.append(var)
if rep.endswith(", "):
rep = rep[:-2]
rep = rep + ") {"