Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save pruned ast if path provided #1924

Open
wants to merge 2 commits into
base: f2dace/dev
Choose a base branch
from
Open

Conversation

ThrudPrimrose
Copy link
Collaborator

Generating SDFGs involve saving the pruned ast
I added these lines:
import os
FORTRAN_AST_PATH = os.getenv("FORTRAN_AST_PATH")
if FORTRAN_AST_PATH is not None:
with open(FORTRAN_AST_PATH, 'w') as f:
f.write(ast.tofortran())

(my editor automatically removes empty lines that only have whitespace)

It can streamline the process of parsing SDFGs

@ThrudPrimrose
Copy link
Collaborator Author

If we want to comment out a function, we need to save this and call it again.
So saving this always if a path is provided is a good idea IMHO

@@ -3187,6 +3187,12 @@ def create_sdfg_from_fortran_file_with_options(
else:
ast = correct_for_function_calls(ast)

import os
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I'd rather advice against looking for environment variable in the middle of a library code, and insist on adding yet another Optional[Path] flag to the ParserConfig instead. Or even better, I'd suggest taking the FParser processing part out to the CLI and let it decide if it wants to save the file or not.

However, create_sdfg_from_fortran_file_with_options() is sadly already in quite an "anything goes" state. So, I'm okay with this too if Lex accepts it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants