mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Support block comments in selector filter syntax (#5023)
The filter_elements selector grammar had no way to comment out part of a
query, so users had to delete and retype text to temporarily toggle a
facet. Add a /* ... */ block comment terminal that is ignored by the
lexer, and tolerate a trailing "+" so that commenting out the final
operand (e.g. "IfcWall + /* IfcSlab */") parses cleanly. Comments may
span multiple lines; a /* sequence inside a quoted string is not treated
as a comment. Only the filter grammar is affected, not get_element or
format which use "/" for regex and division.
Adds a regression test and documents the syntax.
Generated with the assistance of an AI coding tool.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 5c11946470)
This commit is contained in:
committed by
Dion Moult
parent
d39b1c56f8
commit
007573cea5
@@ -41,7 +41,7 @@ import ifcopenshell.util.unit
|
||||
|
||||
filter_elements_grammar = lark.Lark(
|
||||
"""start: filter_group
|
||||
filter_group: facet_list ("+" facet_list)*
|
||||
filter_group: facet_list ("+" facet_list)* "+"?
|
||||
facet_list: facet ("," facet)*
|
||||
|
||||
facet: instance | entity | attribute | type | material | query | classification | location | property | group | parent
|
||||
@@ -109,8 +109,10 @@ filter_elements_grammar = lark.Lark(
|
||||
CR : /\\r/
|
||||
LF : /\\n/
|
||||
NEWLINE: (CR? LF)+
|
||||
COMMENT: "/*" /.*?/s "*/"
|
||||
|
||||
%ignore WS // Disregard spaces in text
|
||||
%ignore COMMENT // Allow /* ... */ block comments to toggle parts of a query
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user