1.1 --- a/lplc Fri Mar 10 23:07:37 2017 +0100
1.2 +++ b/lplc Sat Mar 11 01:04:19 2017 +0100
1.3 @@ -65,17 +65,24 @@
1.4 stdout, stderr = cmd.communicate()
1.5 return cmd.wait()
1.6
1.7 -def start_arg_list(l, arg, prefix, needed):
1.8 +def start_arg_list(l, arg, needed):
1.9
1.10 """
1.11 - Add to 'l' any value given as part of 'arg' having the given option
1.12 - 'prefix'. The 'needed' number of values is provided in case no value is
1.13 - found.
1.14 + Add to 'l' any value given as part of 'arg'. The 'needed' number of values
1.15 + is provided in case no value is found.
1.16
1.17 Return 'l' and 'needed' decremented by 1 together in a tuple.
1.18 """
1.19
1.20 - s = arg[len(prefix):].strip()
1.21 + if arg.startswith("--"):
1.22 + try:
1.23 + prefix_length = arg.index("=") + 1
1.24 + except ValueError:
1.25 + prefix_length = len(arg)
1.26 + else:
1.27 + prefix_length = 2
1.28 +
1.29 + s = arg[prefix_length:].strip()
1.30 if s:
1.31 l.append(s)
1.32 return l, needed - 1
1.33 @@ -160,6 +167,10 @@
1.34 --param-codes Parameter codes identifying named parameters
1.35 --param-locations Parameter locations in signatures
1.36
1.37 +A filename can immediately follow such an option, separated from the option by
1.38 +an equals sign, or it can appear as the next argument after the option
1.39 +(separated by a space).
1.40 +
1.41 The following informational options can be specified to produce output instead
1.42 of compiling a program:
1.43
1.44 @@ -212,23 +223,23 @@
1.45 needed = None
1.46
1.47 for arg in args:
1.48 - if arg == "--attr-codes": l = attrnames; needed = 1
1.49 - elif arg == "--attr-locations": l = attrlocations; needed = 1
1.50 + if arg.startswith("--attr-codes"): l, needed = start_arg_list(attrnames, arg, 1)
1.51 + elif arg.startswith("--attr-locations"): l, needed = start_arg_list(attrlocations, arg, 1)
1.52 elif arg in ("-c", "--compile"): make = False
1.53 elif arg in ("-E", "--no-env"): ignore_env = True
1.54 elif arg in ("-g", "--debug"): debug = True
1.55 elif arg in ("-G", "--gc-sections"): gc_sections = True
1.56 # "P" handled below.
1.57 - elif arg == "--param-codes": l = paramnames; needed = 1
1.58 - elif arg == "--param-locations": l = paramlocations; needed = 1
1.59 + elif arg.startswith("--param-codes"): l, needed = start_arg_list(paramnames, arg, 1)
1.60 + elif arg.startswith("--param-locations"): l, needed = start_arg_list(paramlocations, arg, 1)
1.61 elif arg in ("-q", "--quiet"): make_verbose = False
1.62 elif arg in ("-r", "--reset"): reset = True
1.63 elif arg in ("-R", "--reset-all"): reset_all = True
1.64 elif arg in ("-t", "--no-timing"): timings = False
1.65 elif arg in ("-tb", "--traceback"): traceback = True
1.66 - elif arg.startswith("-o"): l, needed = start_arg_list(outputs, arg, "-o", 1)
1.67 + elif arg.startswith("-o"): l, needed = start_arg_list(outputs, arg, 1)
1.68 elif arg in ("-v", "--verbose"): verbose = True
1.69 - elif arg.startswith("-W"): l, needed = start_arg_list(warnings, arg, "-W", 1)
1.70 + elif arg.startswith("-W"): l, needed = start_arg_list(warnings, arg, 1)
1.71 elif arg.startswith("-"): unrecognised.append(arg)
1.72 else:
1.73 l.append(arg)