Commit Graph

14 Commits

Author SHA1 Message Date
Petru Conduraru 5d439f2729 Source UNIQUE-clause validation from express_parser (#4499 review)
Per review, do not hard-code the uniqueness rules. express_parser already
captures each entity's UNIQUE clauses (nodes.entity_definition.unique), but
they were dropped at codegen. Emit them, via the same pipeline that already
produces the WHERE rules, into the generated express/rules/<SCHEMA>.py
modules, and have validate read them from there so the data tracks the
EXPRESS schema.

- express/nodes.py: capture the full attribute list per UNIQUE clause
  (label, (attrs...)); previously only the first attribute was kept, which
  silently dropped compound clauses such as IfcApplication.UR2
  (ApplicationFullName, Version).
- express/rule_compiler.py: collect_uniqueness_rules / format_uniqueness_rules
  emit a uniqueness_rules dict into every generated rules module.
- express/rules/{IFC2X3,IFC4,IFC4X1,IFC4X2}.py: carry the generated dict.
- validate.py: get_uniqueness_rules reads it statically (ast, cached, no
  heavy import; graceful {} if absent) and validate_uniqueness_rules applies
  it generically. IfcRoot.UR1 and IfcApplication keep their dedicated paths
  to avoid double-reporting.

Verified: get_uniqueness_rules('IFC4') returns IfcApplication /
IfcPropertyEnumeration / IfcRoot from the rules module; a duplicate
IfcPropertyEnumeration name (IFC4) and IFC2X3 UR clauses are flagged, valid
files clean, no double-reporting. All test/test_validate.py fixtures (40)
pass; black and ruff clean.

Refs #4499. IFC4X3 variants gain the dict automatically on the next full
rules regeneration; validate no-ops gracefully until then.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 18:39:36 +03:00
Thomas Krijnen 77aa080334 Recompile rules 2026-06-28 10:37:33 +02:00
Thomas Krijnen 98aa2c635e Rerun express-related codegen 2026-06-26 16:09:44 +02:00
Thomas Krijnen 84abf5e918 Adapt codegen for new parsing 2026-06-25 14:29:14 +02:00
Thomas Krijnen 1137e7b77b Fix rule compilation regarding indeterminate #7529 2026-01-23 14:36:06 +01:00
Thomas Krijnen 7fdf815d3c Re-run express rule codegen #7501 2025-12-24 15:33:44 +01:00
Thomas Krijnen 9efc9d2044 Fix iteration over indeterminate in rule execution 2024-12-18 11:45:47 +01:00
Thomas Krijnen 6302be6bfd Merge v0.7.0 -- src\ifcopenshell-python\ifcopenshell\express 2023-10-18 09:47:27 +02:00
Thomas Krijnen 42d7c7d32c #2685 Recompile rule 2023-03-11 20:44:11 +01:00
Thomas Krijnen 18670bcbd6 Recompile rules 2023-02-14 10:04:46 +01:00
Thomas Krijnen c4b77c2a07 Recompile rules 2023-02-03 22:22:40 +01:00
Thomas Krijnen a1ac820050 #2685 Recompile rules 2023-01-13 12:12:32 +01:00
Thomas Krijnen d1a40d129f #2685 Recompile rules 2023-01-11 13:38:12 +01:00
Thomas Krijnen 0f9c84c1ce Feature: express rules (#2662)
* temp reasonable state, missing rule_head contents

* better state, with init() and rule_id, but some missing parameters

* performance; embed root in dict; fix lookup

* Add ast_utils

* Fixes related to listnode and typo

* First steps with code gen

* Finalize first steps towards working code generation

* Backwards compat

* Rule execution, error formatting, test cases

* Where rule: support indexing, more expressions, test plane angle measure

* positive length measure test cases

* Venture into entity rules, test actor role

* Fixed for not unary op and address test cases

* Test group qualifier and air terminal type

* typeof() implementation and test annotation curve occ

* Flexible handling of expression, type set intersection, IfcAnnotationSurface test cases

* Functions, derived attrs, fix branch order, allow to terminate branches, apply -1 to index

* Implement express query(), test cases for 2x3 bspline curve

* Function args, if-else, repeat, entity instance construction, cshape test cases

* Multiple function call arguments and other small but influential changes. IfcDotProject() almost working except for variable case

* Make lowercase and fix assignment to qualified lhs

* Entity instance schema without file, aggregate assignment workaround, range fix, lowercase instance locals, extruded area direction test cases

* Enumeration item handling, query() robustness, arbitrary profile test cases

* Empty aggregate_initializer, xor and instance equality, nested expression fix in IfcCrossProduct, axis2-3d test cases

* Numeric stable sort with indices greater then 10, get ast node parent, redeclared derived support, nested expression robustness, define entity functions, case statements, xor, mod, bool literals, nvl, unknown, conversion based unit test cases

* Safeguard for schema name case norm, case norm query variable_id

* free instance comparison, supertype serialization fix, include inherited attributes in locals, proper elif-else in case stmt, loindex, shape rep test cases

* Union operator on set, retain general_aggr_types in parse tree, test cases for property set

* Escape stmt, rule locals and statements

* Return calculated values for redeclared derived attributes

* fix for rules without stmt, add derived and inverse attributes to locals, filter unused locals, wrap exists() arg with lambda to catch indexerror, support repeated aggr init element, typeof() none check, enum namespace uppercase

* Regen 2x3 rules

* Rule test filter only on basename

* Update fixtures for compliance with full body of rules

* Add rule support to ifcopenshell.validate

* Implement usedin() function, test cases for IfcWallSC MLS

* blength

* Run code generation on all schemas

* Try to eliminate runtime pyparsing dep

* Try to eliminate runtime pyparsing dep
2022-12-26 11:29:32 +01:00