mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Expose the internal preprocessing functionality
This commit is contained in:
parent
822c9e00d1
commit
1331dfbe4a
1 changed files with 19 additions and 1 deletions
20
main.py
20
main.py
|
@ -258,6 +258,8 @@ Use: {progname} -O help for help on the optimizer control options.
|
||||||
Comments are always removed in the output, even when using --prettify.
|
Comments are always removed in the output, even when using --prettify.
|
||||||
|
|
||||||
Preprocessor modes:
|
Preprocessor modes:
|
||||||
|
int Preprocess source using the internal preprocessor
|
||||||
|
(ignores --precmd; accepts --preargs -D, -U and -I)
|
||||||
ext Invoke a preprocessor with no default parameters
|
ext Invoke a preprocessor with no default parameters
|
||||||
mcpp Invoke mcpp as preprocessor, setting default parameters pertinent
|
mcpp Invoke mcpp as preprocessor, setting default parameters pertinent
|
||||||
to it. Implies --precmd=mcpp
|
to it. Implies --precmd=mcpp
|
||||||
|
@ -495,7 +497,7 @@ def main(argv):
|
||||||
|
|
||||||
elif opt in ('-p', '--preproc'):
|
elif opt in ('-p', '--preproc'):
|
||||||
preproc = arg.lower()
|
preproc = arg.lower()
|
||||||
supported = ('ext', 'mcpp', 'gcpp', 'none')
|
supported = ('int', 'ext', 'mcpp', 'gcpp', 'none')
|
||||||
if preproc not in supported:
|
if preproc not in supported:
|
||||||
Usage(argv[0])
|
Usage(argv[0])
|
||||||
werr(u"\nUnknown --preproc option: '%s'."
|
werr(u"\nUnknown --preproc option: '%s'."
|
||||||
|
@ -689,6 +691,22 @@ def main(argv):
|
||||||
pperrors = False
|
pperrors = False
|
||||||
if preproc_show_cmdline:
|
if preproc_show_cmdline:
|
||||||
script = ' '.join(preproc_cmdline)
|
script = ' '.join(preproc_cmdline)
|
||||||
|
|
||||||
|
elif preproc == 'int':
|
||||||
|
# Use internal preprocessor.
|
||||||
|
|
||||||
|
from cpreproc import Preproc
|
||||||
|
pperrors, script, macros = Preproc(script,
|
||||||
|
preproc_cmdline[1:]).get()
|
||||||
|
if pperrors:
|
||||||
|
preshow = True # Force preshow to display errors
|
||||||
|
|
||||||
|
if 'USE_LAZY_LISTS' in macros:
|
||||||
|
options.add('lazylists')
|
||||||
|
if 'USE_SWITCHES' in macros:
|
||||||
|
options.add('enableswitch')
|
||||||
|
del macros
|
||||||
|
|
||||||
elif preproc != 'none':
|
elif preproc != 'none':
|
||||||
# PreparePreproc uses and returns Unicode string encoding.
|
# PreparePreproc uses and returns Unicode string encoding.
|
||||||
script = u2b(PreparePreproc(any2u(script, 'utf8')), 'utf8')
|
script = u2b(PreparePreproc(any2u(script, 'utf8')), 'utf8')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue