self.mangle = ''.join([a.type_.mangle for a in args])
self.opname += '_%s' % self.mangle
+ def array_arg(self):
+ """If this operation has an array argument, returns it. Otherwise,
+ returns None.
+ """
+ if self.args and self.args[-1].idx is not None:
+ return self.args[-1]
+ else:
+ return None
+
def parse_input():
"""Parses the entire input.
sys.exit(1)
if min_valid > 0:
- aa = array_arg(op)
+ aa = op.array_arg()
if aa is None:
sys.stderr.write("can't have minimum valid count without array arg\n")
sys.exit(1)
if arg.idx is None:
args += [arg.type_.human_name]
- array = array_arg(op)
+ array = op.array_arg()
if array is not None:
if op.min_valid == 0:
array_args = []
flags = []
if op.absorb_miss:
flags += ['OPF_ABSORB_MISS']
- if array_arg(op):
+ if op.array_arg():
flags += ['OPF_ARRAY_OPERAND']
if op.min_valid > 0:
flags += ['OPF_MIN_VALID']
members += ['%s' % op.min_valid]
- members += ['%s' % (array_arg(op).times if array_arg(op) else 0)]
+ members += ['%s' % (op.array_arg().times if op.array_arg() else 0)]
out_file.write('{%s},\n' % ', '.join(members))
\f
return 'bool force_sysmis = %s' % ' || '.join(sysmis_cond)
return None
-def array_arg(op):
- """If 'op' has an array argument, returns it. Otherwise, returns
- None."""
- args = op.args
- if not args:
- return None
- last_arg = args[-1]
- if last_arg.idx is not None:
- return last_arg
- return None
-
def usage():
print("""\
%(argv0)s, for generating expression parsers and evaluators from definitions