lutaml / expressir

Ruby parser for the ISO EXPRESS language
3 stars 2 forks source link

Issue compiler warning when statement contains reference to attribute prefixed with "self schema" (and perform automatic fix) #125

Open ronaldtse opened 1 year ago

ronaldtse commented 1 year ago

In the EXPRESS file aic_topologically_bounded_surface, it contains statements like this:

SCHEMA aic_topologically_bounded_surface;

USE FROM geometry_schema ( axis2_placement_2d, axis2_placement_3d, bezier_curve, bezier_surface, b_spline_curve_with_knots, b_spline_surface_with_knots, ...);

ENTITY advanced_face 
 SUBTYPE OF ( face_surface );
 WHERE 
WR1 : 
SIZEOF ([ 'AIC_TOPOLOGICALLY_BOUNDED_SURFACE.ELEMENTARY_SURFACE', 'AIC_TOPOLOGICALLY_BOUNDED_SURFACE.B_SPLINE_SURFACE', 'AIC_TOPOLOGICALLY_BOUNDED_SURFACE.SWEPT_SURFACE' ] * TYPEOF (face_geometry)) = 1;
...

Notice that the statement AIC_TOPOLOGICALLY_BOUNDED_SURFACE.B_SPLINE_SURFACE is technically incorrect:

The definition of b_spline_curve_with_knots from geometry_schema:

ENTITY b_spline_curve_with_knots
  SUBTYPE OF (b_spline_curve);
...
END_ENTITY;

This means that when someone USE FROM geometry_schema (b_spline_curve_with_knots);, the b_spline_curve attribute will also be imported.

The goal here is to:

Once we have the warning, we can also automatically fix the problem with an .EXP file as output.

FYI @trthurman @stuartgalt

ronaldtse commented 1 year ago

For documentation on EXPRESS features, see: