Internal code reorganization.

- Separate library loading code into a new module. parser.__init__() no longer loads the library; it accepts (but does not depend on) a library as a parameter.
- Add an optional library argument to parse(). It's no longer mandatory to create a new parser for switching to a different builtins or seftable file.
- Move warning() and types from lslparse to lslcommon.
- Add .copy() to uses of base_keywords, to not rely on it being a frozen set.
- Adjust the test suite.
This commit is contained in:
Sei Lisa 2017-10-20 16:26:05 +02:00
parent 1a1531cb40
commit 3f6f8ed8ad
7 changed files with 294 additions and 238 deletions

View file

@ -24,6 +24,7 @@ from lslopt.lsloutput import outscript
from lslopt.lsloptimizer import optimizer
import sys, os, getopt, re
import lslopt.lslcommon
import lslopt.lslloadlib
VERSION = '0.2.1beta'
@ -651,7 +652,8 @@ def main(argv):
if not preshow:
p = parser(builtins, seftable)
lib = lslopt.lslloadlib.LoadLibrary(builtins, seftable)
p = parser(lib)
try:
ts = p.parse(script, options,
fname if fname != '-' else '<stdin>')