diff --git a/src/fparser/scripts/fparser2.py b/src/fparser/scripts/fparser2.py index 8109585b..3f9af427 100755 --- a/src/fparser/scripts/fparser2.py +++ b/src/fparser/scripts/fparser2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Modified work Copyright (c) 2017-2018 Science and Technology +# Modified work Copyright (c) 2017-2019 Science and Technology # Facilities Council # Original work Copyright (c) 1999-2008 Pearu Peterson @@ -93,7 +93,6 @@ def runner(_, options, args): try: f2003_parser = ParserFactory().create() program = f2003_parser(reader) - print (program) except FortranSyntaxError as msg: print ("Syntax error: {0}".format(str(msg))) try: @@ -108,6 +107,17 @@ def runner(_, options, args): print ("Internal error in fparser: {0}".format(str(msg))) raise SystemExit(1) + if options.task == 'repr': + print (repr(program)) + elif options.task == 'show': + print (program) + elif options.task == 'none': + pass + else: + print ("Internal error in fparser2.py: task command line " + "option '{0}' is not supported.".format(options.task)) + raise SystemExit(1) + def main(): ''' Check arguments before parsing code ''' diff --git a/src/fparser/scripts/script_options.py b/src/fparser/scripts/script_options.py index 8ccf7840..d38a26d9 100644 --- a/src/fparser/scripts/script_options.py +++ b/src/fparser/scripts/script_options.py @@ -100,7 +100,7 @@ def set_fparser_options(parser): %prog parses Fortran code.''') parser.add_option('--task', default = 'show', - choices = ['show', 'none'], + choices = ['show', 'repr', 'none'], help = 'Specify parsing result task. Default: %default.' ) parser.add_option('--std',