'range : NAME application DOTRANGE NAME application'
t[0] = ('range', t[1], t[2][0], t[5][0])
if t[1] != t[4]:
- sys.stderr.write("variable names in range don't match!")
+ sys.stderr.write("\"%s\", %d: variable names in range don't match!" % (sourcefile, t.lineno(1)))
sys.exit(1)
## R
# Error handling
def p_error(t):
+ "Gets fed an error token."
sys.stderr.write('"%s", line %d: syntax error at "%s"\n' % (sourcefile, t.lineno, t.value))
import yacc
# Map MAD intrinsics to C library functions
madfunc_map = {'elog':'log'}
-def croak(t, msg):
- (file, line, label, statement) = t
- sys.stderr.write('"%s", line %d: %s\n' % (file, line, msg))
+def croak(msg):
+ sys.stderr.write('"%s", line %d: %s\n' % (sourcefile, sourceline, msg))
# All MAD variables are global, you have to simulate locals using SAVE DATA and
# RETURN DATA. Thus the variable lookup tables about are straight
if statement[0] == 'for':
target = statement[1]
if not target in labels:
- croak((sourcefile,sourceline,label,statement),"no such label as "+`target`)
+ croak("no such label as "+`target`)
sys.exit(1)
# On to actual analysis
try:
funcline = sourceline
elif statement[0] == 'read':
if statement[1] not in format:
- croak(card, "uninitialized format string" +`statement[1]`)
+ croak("uninitialized format string" +`statement[1]`)
else:
(fmt, types) = fmt_convert(format[statement[1]])
for (vtype, var) in zip(types, statement[2:]):
deck[i] = (sourcefile, sourceline, label, ('entry', name, prev[1]))
break
elif prev[0] == 'entry':
- croak(deck[i-j-1],"multiple ENTRY points are not supported")
+ (sourcefile,sourceline,label,statement) = deck[i-j-1]
+ croak("multiple ENTRY points are not supported")
else:
- croak(deck[i], 'no EXTERNAL declaration matches this ENTRY')
+ croak('no EXTERNAL declaration matches this ENTRY')
except:
sys.stderr.write("mad: internal error while analyzing code for line %d\n" % line)
(exc_type, exc_value, exc_traceback) = sys.exc_info()