Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some of the higher level things.

  • Loading branch information...
commit f64f79a16535def5dc7c2c93301dbbad64ae3655 1 parent 1c63fd7
Solomon Foster authored
Showing with 73 additions and 1 deletion.
  1. +18 −1 lib/ISO_10303_21/Grammar.pm
  2. +55 −0 t/03-exchange-structure.t
19 lib/ISO_10303_21/Grammar.pm
View
@@ -5,7 +5,7 @@ grammar ISO_10303_21::Grammar
token space { " " }
token digit { <[0..9]> }
token lower { <[a..z]> }
- token upper { <[A..Z]> }
+ token upper { <[A..Z]> | '_' }
token special { '!' | '"' | '*' | '$' | '%' | '&' | '.' | '#'
| '+' | ',' | '-' | '(' | ')' | '?' | '/' | ':'
| ';' | '<' | '=' | '>' | '@' | '[' | ']' | '{'
@@ -31,4 +31,21 @@ grammar ISO_10303_21::Grammar
token hex { <[0..9]> | <[A..F]> }
token binary { '"' <[0..3]> <hex>* '"' }
+
+ token parameter { <typed_parameter> | <untyped_parameter> | <omitted_parameter> }
+ token omitted_parameter { '*' }
+ token untyped_parameter { '$' | <real> | <integer> | <string>
+ | <entity_instance_name> | <enumeration> | <binary> | <list_of_parameters> }
+ rule typed_parameter { <keyword> '(' <parameter> ')' }
+ rule list_of_parameters { '(' [ <parameter> ]* % [ ',' ] ')' }
+ rule parameter_list { [ <parameter> ]+ % [ ',' ] }
+
+ rule header_entity { <keyword> '(' <parameter_list> ')' ';' }
+ rule header_entity_list { <header_entity>+ }
+ rule header_section {
+ "HEADER;"
+ <header_entity> <header_entity> <header_entity>
+ <header_entity_list>?
+ "ENDSEC;"
+ }
}
55 t/03-exchange-structure.t
View
@@ -0,0 +1,55 @@
+use v6;
+use Test;
+use ISO_10303_21::Grammar;
+
+my @parameters = (
+ "*",
+ '$',
+ "#2",
+ ".ENUMERATION.",
+ "(#24)",
+ '(#24, $)',
+ '($, (#1), *)',
+ );
+
+for @parameters -> $trial-parameter {
+ my $match = ISO_10303_21::Grammar.parse($trial-parameter, :rule<parameter>);
+ isa_ok $match, Match, "<parameter> matches $trial-parameter - 1";
+ ok $match, "<parameter> matches $trial-parameter - 2";
+}
+
+{
+ my $header = q[('CAx 3rd Joint Test Round - Test Model AS1', 'Validation Properties Test Model '),'1';];
+ my $match = ISO_10303_21::Grammar.parse($header, :rule<parameter_list>);
+ isa_ok $match, Match, "<parameter_list> matches a parameter_list - 1";
+ ok $match, "<parameter_list> matches a parameter_list - 2";
+}
+
+{
+ my $header = q[FILE_DESCRIPTION(('CAx 3rd Joint Test Round - Test Model AS1', 'Validation Properties Test Model '),'1');];
+ my $match = ISO_10303_21::Grammar.parse($header, :rule<header_entity>);
+ isa_ok $match, Match, "<header_entity> matches a header - 1";
+ ok $match, "<header_entity> matches a header - 2";
+}
+
+{
+ my $header =
+q[HEADER;
+FILE_DESCRIPTION(('CAx 3rd Joint Test Round - Test Model AS1',
+'Validation Properties Test Model '),'1');
+FILE_NAME('as1-tc-214.stp',
+'2000-02-04 T10:13:49',
+('SD Yates '),
+('Theorem Solutions Ltd'),
+'THEOREM SOLUTIONS CADDS -> AP214 DIS PREPROCESSOR 4.0.002',
+'CADDS4X/5 - CAMU',
+'AP Ranger ');
+FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 2 10303 214 0 1 1 1 } '));
+ENDSEC;];
+
+ my $match = ISO_10303_21::Grammar.parse($header, :rule<header_section>);
+ isa_ok $match, Match, "<header_section> matches a header - 1";
+ ok $match, "<header_section> matches a header - 2";
+}
+
+done;
Please sign in to comment.
Something went wrong with that request. Please try again.