mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +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>
This commit is contained in:
committed by
Dion Moult
parent
0b7e25a3ef
commit
5c11946470
@@ -40,7 +40,7 @@ import ifcopenshell.util.system
|
||||
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
|
||||
@@ -108,8 +108,10 @@ filter_elements_grammar = lark.Lark("""start: filter_group
|
||||
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
|
||||
""")
|
||||
|
||||
get_element_grammar = lark.Lark("""start: keys
|
||||
|
||||
Reference in New Issue
Block a user