Skip to content

Commit

Permalink
Rules and tests for recognizing entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Sep 4, 2012
1 parent f64f79a commit f56b998
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ISO_10303_21/Grammar.pm
Expand Up @@ -48,4 +48,11 @@ grammar ISO_10303_21::Grammar
<header_entity_list>?
"ENDSEC;"
}

rule simple_record { <keyword> '(' <parameter_list>? ')' }
rule subsuper_record { '(' <simple_record>+ ')' }
rule simple_entity_instance { <entity_instance_name> '=' <simple_record> ';' }
rule complex_entity_instance { <entity_instance_name> '=' <subsuper_record> ';' }
rule entity_instance { <simple_entity_instance> | <complex_entity_instance> }

}
33 changes: 33 additions & 0 deletions t/03-exchange-structure.t
Expand Up @@ -52,4 +52,37 @@ ENDSEC;];
ok $match, "<header_section> matches a header - 2";
}

{
my $record = q[DIMENSIONAL_EXPONENTS(0.0,0.0,0.0,0.0,0.0,0.0,0.0)];
my $match = ISO_10303_21::Grammar.parse($record, :rule<simple_record>);
isa_ok $match, Match, "<simple_record> matches $record - 1";
ok $match, "<simple_record> matches $record - 2";
}

{
my $record = q[#2=DIMENSIONAL_EXPONENTS(0.0,0.0,0.0,0.0,0.0,0.0,0.0);];
my $match = ISO_10303_21::Grammar.parse($record, :rule<simple_entity_instance>);
isa_ok $match, Match, "<simple_entity_instance> matches $record - 1";
ok $match, "<simple_entity_instance> matches $record - 2";
}

my @entities = (
q[#2=DIMENSIONAL_EXPONENTS(0.0,0.0,0.0,0.0,0.0,0.0,0.0);],
q[#17=PRODUCT_DEFINITION('CAx-AS1','Design Definition',#16,#13);],
q[#49=PRODUCT('nut','nut','Generic Nut for AS1 Assembly',(#12));],
q[#69=CARTESIAN_POINT('#69',(0.0,40.,55.));],
q[#140=(BOUNDED_CURVE()B_SPLINE_CURVE(3,(#136,#137,#138,#139),
.UNSPECIFIED.,.F.,.F.)B_SPLINE_CURVE_WITH_KNOTS((4,4),(0.0,0.5),
.UNSPECIFIED.)CURVE()GEOMETRIC_REPRESENTATION_ITEM()
RATIONAL_B_SPLINE_CURVE((1.0,0.33333333333,0.33333333333,1.0))
REPRESENTATION_ITEM('#140'));],
);

for @entities -> $entity {
my $match = ISO_10303_21::Grammar.parse($entity, :rule<entity_instance>);
isa_ok $match, Match, "<entity_instance> matches $entity - 1";
ok $match, "<entity_instance> matches $entity - 2";
}


done;

0 comments on commit f56b998

Please sign in to comment.