Skip to content

Commit

Permalink
issue #171. Making script option to output repr.
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertford committed Mar 24, 2019
1 parent e279d5d commit a0c8c75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/fparser/scripts/fparser2.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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 '''
Expand Down
2 changes: 1 addition & 1 deletion src/fparser/scripts/script_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a0c8c75

Please sign in to comment.