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

Parser not able to handle Hollerith constants with whitespaces #48

Open
dmikushin opened this issue Nov 21, 2023 · 4 comments
Open

Parser not able to handle Hollerith constants with whitespaces #48

dmikushin opened this issue Nov 21, 2023 · 4 comments

Comments

@dmikushin
Copy link

This code is actually valid:

Error:./ktshld.f:121,30:
   Invalid initializer
      DATA    BLANK , NAME  / 4H    , 4HTRSH, 4HL     /
                              ^

because Hollerith constants may have whitespaces, and they are unquoted. This is one spectacular piece of Fortran, which exists to confuse the whitespace-based tokenizers.

@ben-brewer-codethink
Copy link
Member

The code for this is here:

ofc_string_t* ofc_parse_hollerith(

The call ofc_sparse_parent_pointer gets a pointer to the source without the spaces removed, so the code should handle holleriths with spaces in.

This tool does not tokenize or use whitespace in that way at all, it removes all whitespace before parsing as tokenizing legacy fortran is not possible, however it keeps a reference to the original source for situations like this, and for reporting error locations.

@ben-brewer-codethink
Copy link
Member

I should further note that this is failing during semantic analysis which should mean that the hollerith was parsed without issue.

The specific error message is here:

ofc_sparse_ref_error(init_elem->src,

@ben-brewer-codethink
Copy link
Member

Would it be possible to get a minimal test which triggers this issue?

@dmikushin
Copy link
Author

Hi @ben-brewer-codethink , I apologize that I won't be able to really minimize the test cases. But as you said the problem should be straight-forward. I'm attaching the original source file mentioned above, FYI it's a part of NASTRAN-95 distribution:

ktshld.f.gz

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

No branches or pull requests

2 participants