X Tutup
Skip to content

Commit 4f0d21f

Browse files
author
Troy Melhase
committed
Adds flag to skip compile check of generated source.
1 parent 9f9251b commit 4f0d21f

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

bin/j2py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ def main(options):
151151
module.name = path.splitext(filein)[0] if filein != '-' else '<stdin>'
152152
print >> output, source
153153

154-
try:
155-
compile(source, '<string>', 'exec')
156-
except (SyntaxError, ), ex:
157-
warning('Generated source has invalid syntax. %s', ex)
158-
else:
159-
info('Generated source has valid syntax.')
154+
if not options.skipcompile:
155+
try:
156+
compile(source, '<string>', 'exec')
157+
except (SyntaxError, ), ex:
158+
warning('Generated source has invalid syntax. %s', ex)
159+
else:
160+
info('Generated source has valid syntax.')
160161

161162
info('Parse: %.4f seconds', timed['comp_finish'] - timed['comp'])
162163
info('Visit: %.4f seconds', timed['visit_finish'] - timed['visit'])
@@ -183,30 +184,33 @@ def config(argv):
183184
addopt('-d', '--configdir', dest='configdir',
184185
help='Use DIR to match input filename with config filename.',
185186
metavar='DIR', default=None)
186-
addopt('-n', '--nodefaults', dest='includedefaults',
187-
help='Ignore default configuration module.',
188-
default=True, action='store_false')
187+
addopt('-f', '--profile', dest='profile',
188+
help='Profile execution and print results to stderr.',
189+
default=False, action='store_true')
190+
addopt('-j', '--java-ast', dest='javaast',
191+
help='Print java source AST tree to stderr.',
192+
default=False, action='store_true')
193+
addopt('-k', '--skip-compile', dest='skipcompile',
194+
help='Skip compile check on translated source.',
195+
default=False, action='store_true')
189196
addopt('-l', '--loglevel', dest='loglevel',
190197
help='Set log level by name or value.',
191198
default='WARN', type='loglevel')
192-
addopt('-t', '--lexer-tokens', dest='lexertokens',
193-
help='Print lexer tokens to stderr.',
194-
default=False, action='store_true')
199+
addopt('-n', '--nodefaults', dest='includedefaults',
200+
help='Ignore default configuration module.',
201+
default=True, action='store_false')
195202
addopt('-p', '--python-tree', dest='pytree',
196203
help='Print python object tree to stderr.',
197204
default=False, action='store_true')
198-
addopt('-j', '--java-ast', dest='javaast',
199-
help='Print java source AST tree to stderr.',
200-
default=False, action='store_true')
201-
addopt('-f', '--profile', dest='profile',
202-
help='Profile execution and print results to stderr.',
205+
addopt('-r', '--nocolor', dest='nocolor',
206+
help='Disable color output.' +\
207+
(' No effect on Win OS.' if isWindows() else ''),
203208
default=False, action='store_true')
204209
addopt('-s', '--skip-source', dest='skipsource',
205210
help='Skip writing translated source; useful when printing trees',
206211
default=False, action='store_true')
207-
addopt('-r', '--nocolor', dest='nocolor',
208-
help='Disable color output.' +\
209-
(' No effect on Win OS.' if isWindows() else ''),
212+
addopt('-t', '--lexer-tokens', dest='lexertokens',
213+
help='Print lexer tokens to stderr.',
210214
default=False, action='store_true')
211215

212216
options, args = parser.parse_args(argv)

0 commit comments

Comments
 (0)
X Tutup