1.1 --- a/docs/lplc.1 Fri Mar 10 23:07:56 2017 +0100
1.2 +++ b/docs/lplc.1 Sat Mar 11 01:04:34 2017 +0100
1.3 @@ -94,6 +94,10 @@
1.4 .B \-\-param\-locations
1.5 Parameter locations in signatures
1.6 .PP
1.7 +A filename can immediately follow such an option, separated from the option by
1.8 +an equals sign, or it can appear as the next argument after the option
1.9 +(separated by a space).
1.10 +.PP
1.11 The following informational options can be specified to produce output instead
1.12 of compiling a program:
1.13 .PP
1.14 @@ -148,6 +152,17 @@
1.15 in the current directory, assuming that
1.16 .B hello.py
1.17 can be compiled without errors.
1.18 +.PP
1.19 +To configure a program using existing attribute codes in
1.20 +.B attrnames
1.21 +and existing attribute positions in
1.22 +.BR locations :
1.23 +.IP
1.24 +lplc -o hello hello.py --attr-codes=attrnames --attr-locations=locations
1.25 +.PP
1.26 +If attributes cannot be positioned in a way compatible with the given
1.27 +.B locations
1.28 +file, an error will be reported.
1.29 .SH FILES
1.30 .B lplc
1.31 produces an output executable file called
2.1 --- a/lplc Fri Mar 10 23:07:56 2017 +0100
2.2 +++ b/lplc Sat Mar 11 01:04:34 2017 +0100
2.3 @@ -65,17 +65,24 @@
2.4 stdout, stderr = cmd.communicate()
2.5 return cmd.wait()
2.6
2.7 -def start_arg_list(l, arg, prefix, needed):
2.8 +def start_arg_list(l, arg, needed):
2.9
2.10 """
2.11 - Add to 'l' any value given as part of 'arg' having the given option
2.12 - 'prefix'. The 'needed' number of values is provided in case no value is
2.13 - found.
2.14 + Add to 'l' any value given as part of 'arg'. The 'needed' number of values
2.15 + is provided in case no value is found.
2.16
2.17 Return 'l' and 'needed' decremented by 1 together in a tuple.
2.18 """
2.19
2.20 - s = arg[len(prefix):].strip()
2.21 + if arg.startswith("--"):
2.22 + try:
2.23 + prefix_length = arg.index("=") + 1
2.24 + except ValueError:
2.25 + prefix_length = len(arg)
2.26 + else:
2.27 + prefix_length = 2
2.28 +
2.29 + s = arg[prefix_length:].strip()
2.30 if s:
2.31 l.append(s)
2.32 return l, needed - 1
2.33 @@ -160,6 +167,10 @@
2.34 --param-codes Parameter codes identifying named parameters
2.35 --param-locations Parameter locations in signatures
2.36
2.37 +A filename can immediately follow such an option, separated from the option by
2.38 +an equals sign, or it can appear as the next argument after the option
2.39 +(separated by a space).
2.40 +
2.41 The following informational options can be specified to produce output instead
2.42 of compiling a program:
2.43
2.44 @@ -212,23 +223,23 @@
2.45 needed = None
2.46
2.47 for arg in args:
2.48 - if arg == "--attr-codes": l = attrnames; needed = 1
2.49 - elif arg == "--attr-locations": l = attrlocations; needed = 1
2.50 + if arg.startswith("--attr-codes"): l, needed = start_arg_list(attrnames, arg, 1)
2.51 + elif arg.startswith("--attr-locations"): l, needed = start_arg_list(attrlocations, arg, 1)
2.52 elif arg in ("-c", "--compile"): make = False
2.53 elif arg in ("-E", "--no-env"): ignore_env = True
2.54 elif arg in ("-g", "--debug"): debug = True
2.55 elif arg in ("-G", "--gc-sections"): gc_sections = True
2.56 # "P" handled below.
2.57 - elif arg == "--param-codes": l = paramnames; needed = 1
2.58 - elif arg == "--param-locations": l = paramlocations; needed = 1
2.59 + elif arg.startswith("--param-codes"): l, needed = start_arg_list(paramnames, arg, 1)
2.60 + elif arg.startswith("--param-locations"): l, needed = start_arg_list(paramlocations, arg, 1)
2.61 elif arg in ("-q", "--quiet"): make_verbose = False
2.62 elif arg in ("-r", "--reset"): reset = True
2.63 elif arg in ("-R", "--reset-all"): reset_all = True
2.64 elif arg in ("-t", "--no-timing"): timings = False
2.65 elif arg in ("-tb", "--traceback"): traceback = True
2.66 - elif arg.startswith("-o"): l, needed = start_arg_list(outputs, arg, "-o", 1)
2.67 + elif arg.startswith("-o"): l, needed = start_arg_list(outputs, arg, 1)
2.68 elif arg in ("-v", "--verbose"): verbose = True
2.69 - elif arg.startswith("-W"): l, needed = start_arg_list(warnings, arg, "-W", 1)
2.70 + elif arg.startswith("-W"): l, needed = start_arg_list(warnings, arg, 1)
2.71 elif arg.startswith("-"): unrecognised.append(arg)
2.72 else:
2.73 l.append(arg)