Add functionality to validate data section only#17
Add functionality to validate data section only#17aothms merged 5 commits intoIfcOpenShell:masterfrom
Conversation
__init__.py
Outdated
| parser = Lark(grammar, parser="lalr", start="file", **transformer) | ||
|
|
||
| if validate_data_only: | ||
| match = re.search( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Small addition allowing us to split syntax task into
syntax_validation_headerandsyntax_validation_data