Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add some of the higher level things.

  • Loading branch information...
commit f64f79a16535def5dc7c2c93301dbbad64ae3655 1 parent 1c63fd7
colomon authored

Showing 2 changed files with 73 additions and 1 deletion. Show diff stats Hide diff stats

  1. +18 1 lib/ISO_10303_21/Grammar.pm
  2. +55 0 t/03-exchange-structure.t
19 lib/ISO_10303_21/Grammar.pm
@@ -5,7 +5,7 @@ grammar ISO_10303_21::Grammar
5 5 token space { " " }
6 6 token digit { <[0..9]> }
7 7 token lower { <[a..z]> }
8   - token upper { <[A..Z]> }
  8 + token upper { <[A..Z]> | '_' }
9 9 token special { '!' | '"' | '*' | '$' | '%' | '&' | '.' | '#'
10 10 | '+' | ',' | '-' | '(' | ')' | '?' | '/' | ':'
11 11 | ';' | '<' | '=' | '>' | '@' | '[' | ']' | '{'
@@ -31,4 +31,21 @@ grammar ISO_10303_21::Grammar
31 31
32 32 token hex { <[0..9]> | <[A..F]> }
33 33 token binary { '"' <[0..3]> <hex>* '"' }
  34 +
  35 + token parameter { <typed_parameter> | <untyped_parameter> | <omitted_parameter> }
  36 + token omitted_parameter { '*' }
  37 + token untyped_parameter { '$' | <real> | <integer> | <string>
  38 + | <entity_instance_name> | <enumeration> | <binary> | <list_of_parameters> }
  39 + rule typed_parameter { <keyword> '(' <parameter> ')' }
  40 + rule list_of_parameters { '(' [ <parameter> ]* % [ ',' ] ')' }
  41 + rule parameter_list { [ <parameter> ]+ % [ ',' ] }
  42 +
  43 + rule header_entity { <keyword> '(' <parameter_list> ')' ';' }
  44 + rule header_entity_list { <header_entity>+ }
  45 + rule header_section {
  46 + "HEADER;"
  47 + <header_entity> <header_entity> <header_entity>
  48 + <header_entity_list>?
  49 + "ENDSEC;"
  50 + }
34 51 }
55 t/03-exchange-structure.t
... ... @@ -0,0 +1,55 @@
  1 +use v6;
  2 +use Test;
  3 +use ISO_10303_21::Grammar;
  4 +
  5 +my @parameters = (
  6 + "*",
  7 + '$',
  8 + "#2",
  9 + ".ENUMERATION.",
  10 + "(#24)",
  11 + '(#24, $)',
  12 + '($, (#1), *)',
  13 + );
  14 +
  15 +for @parameters -> $trial-parameter {
  16 + my $match = ISO_10303_21::Grammar.parse($trial-parameter, :rule<parameter>);
  17 + isa_ok $match, Match, "<parameter> matches $trial-parameter - 1";
  18 + ok $match, "<parameter> matches $trial-parameter - 2";
  19 +}
  20 +
  21 +{
  22 + my $header = q[('CAx 3rd Joint Test Round - Test Model AS1', 'Validation Properties Test Model '),'1';];
  23 + my $match = ISO_10303_21::Grammar.parse($header, :rule<parameter_list>);
  24 + isa_ok $match, Match, "<parameter_list> matches a parameter_list - 1";
  25 + ok $match, "<parameter_list> matches a parameter_list - 2";
  26 +}
  27 +
  28 +{
  29 + my $header = q[FILE_DESCRIPTION(('CAx 3rd Joint Test Round - Test Model AS1', 'Validation Properties Test Model '),'1');];
  30 + my $match = ISO_10303_21::Grammar.parse($header, :rule<header_entity>);
  31 + isa_ok $match, Match, "<header_entity> matches a header - 1";
  32 + ok $match, "<header_entity> matches a header - 2";
  33 +}
  34 +
  35 +{
  36 + my $header =
  37 +q[HEADER;
  38 +FILE_DESCRIPTION(('CAx 3rd Joint Test Round - Test Model AS1',
  39 +'Validation Properties Test Model '),'1');
  40 +FILE_NAME('as1-tc-214.stp',
  41 +'2000-02-04 T10:13:49',
  42 +('SD Yates '),
  43 +('Theorem Solutions Ltd'),
  44 +'THEOREM SOLUTIONS CADDS -> AP214 DIS PREPROCESSOR 4.0.002',
  45 +'CADDS4X/5 - CAMU',
  46 +'AP Ranger ');
  47 +FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 2 10303 214 0 1 1 1 } '));
  48 +ENDSEC;];
  49 +
  50 + my $match = ISO_10303_21::Grammar.parse($header, :rule<header_section>);
  51 + isa_ok $match, Match, "<header_section> matches a header - 1";
  52 + ok $match, "<header_section> matches a header - 2";
  53 +}
  54 +
  55 +done;

0 comments on commit f64f79a

Please sign in to comment.
Something went wrong with that request. Please try again.