diff --git a/lslopt/lslparse.py b/lslopt/lslparse.py index 823a346..b4c89e4 100644 --- a/lslopt/lslparse.py +++ b/lslopt/lslparse.py @@ -2668,13 +2668,19 @@ list lazy_list_set(list L, integer i, list v) return self.parse(script, options) - def __init__(self, builtins = 'builtins.txt', seftable = 'seftable.txt'): + def __init__(self, builtins = None, seftable = None): """Reads the library.""" self.events = {} self.constants = {} self.funclibrary = {} + if builtins is None: + builtins = lslcommon.DataPath + 'builtins.txt' + + if seftable is None: + seftable = lslcommon.DataPath + 'seftable.txt' + self.parse_directive_re = None # Library read code @@ -2694,7 +2700,7 @@ list lazy_list_set(list L, integer i, list v) parse_num_re = re.compile(r'^\s*(-?(?=[0-9]|\.[0-9])[0-9]*((?:\.[0-9]*)?(?:[Ee][+-]?[0-9]+)?))\s*$') parse_str_re = re.compile(ur'^"((?:[^"\\]|\\.)*)"$') - f = open(lslcommon.DataPath + builtins, 'rb') + f = open(builtins, 'rb') try: linenum = 0 try: @@ -2850,7 +2856,7 @@ list lazy_list_set(list L, integer i, list v) # that includes domain data (min, max) and possibly input # parameter transformations e.g. # llSensor(..., PI, ...) -> llSensor(..., 4, ...). - f = open(lslcommon.DataPath + seftable, 'rb') + f = open(seftable, 'rb') try: while True: line = f.readline() diff --git a/main.py b/main.py index 2884afd..b39e649 100755 --- a/main.py +++ b/main.py @@ -172,6 +172,8 @@ Usage: {progname} [-h|--help] print this help [--version] print this program's version [-o|--output=] output to file rather than stdout + [-b|--builtins=] use a builtins file other than builtins.txt + [-S|--seftable=] use a SEF table file other than seftable.txt [-H|--header] add the script as a comment in Firestorm format [-T|--timestamp] add a timestamp as a comment at the beginning [-y|--python-exceptions] when an exception is raised, show a stack trace @@ -343,11 +345,12 @@ def main(argv): % (b"', '".join(options - validoptions)).decode('utf8')) try: - opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTy', + opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTyb:S:', ('optimizer-options=', 'help', 'version', 'output=', 'header', 'timestamp','python-exceptions', 'preproc=', 'precmd=', 'prearg=', 'prenodef', 'preshow', - 'avid=', 'avname=', 'assetid=', 'shortname=')) + 'avid=', 'avname=', 'assetid=', 'shortname=', 'builtins=' + 'seftable=')) except getopt.GetoptError as e: Usage(argv[0]) sys.stderr.write(u"\nError: " + str(e).decode('utf8') + u"\n") @@ -366,6 +369,8 @@ def main(argv): mcpp_mode = False preshow = False raise_exception = False + builtins = None + seftable = None for opt, arg in opts: if type(opt) is unicode: @@ -409,6 +414,12 @@ def main(argv): elif opt in ('-o', '--output'): outfile = arg + elif opt in ('-b', '--builtins'): + builtins = arg + + elif opt in ('-S', '--seftable'): + seftable = arg + elif opt in ('-y', '--python-exceptions'): raise_exception = True @@ -597,7 +608,7 @@ def main(argv): if not preshow: - p = parser() + p = parser(builtins, seftable) try: ts = p.parse(script, options) except EParse as e: