Skip to content

Add functionality to validate data section only #17

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

Merged
merged 5 commits into from
Jun 26, 2025

Conversation

Ghesselink
Copy link
Contributor

@Ghesselink Ghesselink commented Jun 19, 2025

Small addition allowing us to split syntax task into syntax_validation_header and syntax_validation_data

__init__.py Outdated
parser = Lark(grammar, parser="lalr", start="file", **transformer)

if validate_data_only:
match = re.search(
Copy link
Member

Choose a reason for hiding this comment

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

I don't know... as always the risk with these kind of regexes is that they don't follow the grammar, there can be ENDSEC in a string somewhere or comment. Not likely I know, but still can we do this in another way.

Parsing the header is not time consuming and I guess once we have arrived at this point in the VS we have also established that it's valid, can't we do this in another way, like use the grammar to parse the header (again) to find the exact start offset of the data section. And also don't look for the ENDSEC in the file using the grammar, but just see what the parser tells us that the end of the data section is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I'm making it too complicated for myself; the idea was that we can still check the header section of a file with an invalid header. However, as you mention, at the moment we check the data section we already established that the header section is valid.

Wouldn't this imply that we can just run simple_spf as before in this case, i.e. without any data-only section? So:

  • For syntax_validation_header, run ifcopenshell.simple_spf file.ifc --header-only --json
  • For syntax_validation_data, run ifcopenshell.simple_spf file.ifc --json

Since an error in the header will block the syntax_validation_data task, we'll know for sure that the error is in the data_section if an error occurs there.

@aothms aothms merged commit 4a56a2b into IfcOpenShell:master Jun 26, 2025
1 check passed
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