force_match('(')
args = []
while not match(')'):
- arg = parse_arg()
+ arg = Arg.parse()
args += [arg]
if arg.idx is not None:
if match(')'):
self.times = times
self.condition = condition
-def parse_arg():
- """Parses and returns a function argument."""
- type_ = Type.parse()
- if type_ is None:
- type_ = types['number']
+ def parse():
+ """Parses and returns a function argument."""
+ type_ = Type.parse()
+ if type_ is None:
+ type_ = types['number']
- if toktype != 'id':
- sys.stderr.write("argument name expected at `%s'\n" % token)
- sys.exit(1)
- name = token
+ if toktype != 'id':
+ sys.stderr.write("argument name expected at `%s'\n" % token)
+ sys.exit(1)
+ name = token
- lookahead()
- global line
+ lookahead()
+ global line
- idx = None
- times = 1
+ idx = None
+ times = 1
- if line[0] in "[,)":
- get_token()
- if match('['):
- if type_.name not in ('number', 'string'):
- sys.stderr.write('only double and string arrays supported\n')
- sys.exit(1)
- idx = force('id')
- if match('*'):
- times = force('int')
- if times != 2:
- sys.stderr.write('multiplication factor must be two\n')
+ if line[0] in "[,)":
+ get_token()
+ if match('['):
+ if type_.name not in ('number', 'string'):
+ sys.stderr.write('only double and string arrays supported\n')
sys.exit(1)
- force_match(']')
- condition = None
- else:
- condition = name + ' ' + accumulate_balanced(',)', swallow_end=False)
- get_token()
+ idx = force('id')
+ if match('*'):
+ times = force('int')
+ if times != 2:
+ sys.stderr.write('multiplication factor must be two\n')
+ sys.exit(1)
+ force_match(']')
+ condition = None
+ else:
+ condition = name + ' ' + accumulate_balanced(',)', swallow_end=False)
+ get_token()
- return Arg(name, type_, idx, times, condition)
+ return Arg(name, type_, idx, times, condition)
def print_header():
"""Prints the output file header."""