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

Unify parsing lines starting with slash #4462

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michal-toth
Copy link

When the file is parsed, anything after '/' is treated as a comment with one exception. When parser expects a keyword but the line contains something else, the function handleRandomText (which body was addressed in this commit) is called. If the line contains only a single '/', the response depends on the PARSE_RANDOM_SLASH variable (throw, warn, or ignore).

This is the only place where the text after '/' makes a difference and this commit removes the irregularity.

@michal-toth
Copy link
Author

jenkins build this please

@michal-toth
Copy link
Author

By the way, since anything after '/' is considered to be a comment (except the line addressed in this commit), double slash '//' is equivalent to '/'.

@blattms
Copy link
Member

blattms commented Feb 6, 2025

jenkins build this please

@michal-toth michal-toth changed the title Unifiy parsing lines starting with slash Unify parsing lines starting with slash Feb 6, 2025
@michal-toth
Copy link
Author

I extended the test that checks the parsing of the random slash. The test passes with the change proposed in this PR, and fails without it. The change categorizes a slash followed by any symbols (usually comments) as PARSE_RANDOM_SLASH, while it was PARSE_RANDOM_TEXT before.

@michal-toth
Copy link
Author

jenkins build this please

@blattms
Copy link
Member

blattms commented Feb 6, 2025

With this PR we will ignore any unexpected line where the first non-whitespace character is a slash. We are quite forgiving here, but one can change that behaviour using the ParseContext.

Let's say there should be only one table, then with master

PVDG
-- PRES BG VISC
--
14.7  197.8092  0.0129
50.0  65.9364  0.0130
                      /  Table 0 (Parser exits PVDG keyword parsing as it is only expecting one table)

and also this

PVDG
-- PRES BG VISC
--
14.7  197.8092  0.0129
50.0  65.9364  0.0130
                      /  Table 0 (Parser exits PVDG keyword parsing as it is only expecting one table)
                      /

would work. The last line of the second example is ignored as it is just a slash. Either changing the last line of the second example to a double slash or a slash with a comment would raise an exception with master.

With this PR this will not be the case any more and we will still ignore the last line in the second example regardless of any following character.

Just to be clear: Even if we expect only one table this will be parsed by Flow with the PR

PVDG
-- PRES BG VISC
--
14.7  197.8092  0.0129
50.0  65.9364  0.0130
                      /  Table 0 (Parser exits PVDG keyword parsing if only 1 table is expected)
                      /
                      / If we change the model such that 3 tables are needed then the last two are defaulted. Otherwise these lines are ignored
                     // If we change the model such that 4 tables are needed then the last one is defaulted. Otherwise these lines are ignored

If we expect more than one table then the last tables will be copies of the first one in the last example with this PR.

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