Skip to content

Commit

Permalink
Parse a full file!
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Sep 4, 2012
1 parent f56b998 commit 8c25fdb
Show file tree
Hide file tree
Showing 41 changed files with 94,099 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/ISO_10303_21/Grammar.pm
Expand Up @@ -54,5 +54,16 @@ grammar ISO_10303_21::Grammar
rule simple_entity_instance { <entity_instance_name> '=' <simple_record> ';' } rule simple_entity_instance { <entity_instance_name> '=' <simple_record> ';' }
rule complex_entity_instance { <entity_instance_name> '=' <subsuper_record> ';' } rule complex_entity_instance { <entity_instance_name> '=' <subsuper_record> ';' }
rule entity_instance { <simple_entity_instance> | <complex_entity_instance> } rule entity_instance { <simple_entity_instance> | <complex_entity_instance> }


rule data_section {
"DATA" [ '(' <parameter_list> ')']? ';'
<entity_instance>*
"ENDSEC" ';'
}

rule exchange_file {
"ISO-10303-21;"
<header_section> <data_section>+
"END-ISO-10303-21;"
}
} }
19 changes: 19 additions & 0 deletions t/03-exchange-structure.t
Expand Up @@ -84,5 +84,24 @@ for @entities -> $entity {
ok $match, "<entity_instance> matches $entity - 2"; ok $match, "<entity_instance> matches $entity - 2";
} }


{
my $data =
q[DATA;
#1=DIMENSIONAL_EXPONENTS(1.0,0.0,0.0,0.0,0.0,0.0,0.0);
#2=DIMENSIONAL_EXPONENTS(0.0,0.0,0.0,0.0,0.0,0.0,0.0);
#3=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
#4=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
#5=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
#6=CARTESIAN_POINT('#6',(0.0,0.0,0.0));
#7=DIRECTION('#7',(1.0,0.0,0.0));
#8=DIRECTION('#8',(0.0,0.0,1.0));
#9=AXIS2_PLACEMENT_3D('#9',#6,#8,#7);
ENDSEC;];

my $match = ISO_10303_21::Grammar.parse($data, :rule<data_section>);
isa_ok $match, Match, "<data_section> matches a data - 1";
ok $match, "<data_section> matches a data - 2";
}



done; done;
14 changes: 14 additions & 0 deletions t/04-read-files.t
@@ -0,0 +1,14 @@
use v6;
use Test;
use ISO_10303_21::Grammar;

my @files = <t/CAx/conrod.stp>;

for @files -> $file {
my $file-data = slurp($file);
my $match = ISO_10303_21::Grammar.parse($file-data, :rule<exchange_file>);
isa_ok $match, Match, "<exchange_file> matches $file - 1";
ok $match, "<exchange_file> matches $file - 2";
}

done;

0 comments on commit 8c25fdb

Please sign in to comment.