Permalink
Browse files

Add the control directives to strings.

  • Loading branch information...
1 parent 8c25fdb commit ff14d08f5866e826d4e9e25d65bb39110138ff30 @colomon committed Sep 4, 2012
Showing with 18 additions and 7 deletions.
  1. +12 −2 lib/ISO_10303_21/Grammar.pm
  2. +6 −5 t/02-tokens.t
@@ -22,9 +22,19 @@ grammar ISO_10303_21::Grammar
token integer { <sign>? <digit> <digit>* }
token real { <sign>? <digit>+ '.' <digit>* [ 'E' <sign>? <digit>+ ]? }
+ token hex_one { <hex> <hex> }
+ token hex_two { <hex_one> <hex_one> }
+ token hex_four { <hex_two> <hex_two> }
+ token page { <reverse_solidus> 'S' <reverse_solidus> <character> }
+ token alphabet { <reverse_solidus> 'P' <upper> <reverse_solidus> <character> }
+ token end_extended { <reverse_solidus> 'X0' <reverse_solidus> }
+ token extended2 { <reverse_solidus> 'X2' <reverse_solidus> <hex_two>+ <end_extended> }
+ token extended4 { <reverse_solidus> 'X4' <reverse_solidus> <hex_four>+ <end_extended> }
+ token arbitrary { <reverse_solidus> 'X' <reverse_solidus> <hex_one> }
+ token control_directive { <page> | <alphabet> | <extended2> | <extended4> | <arbitrary> }
+
token non_q_char { <special> | <digit> | <space> | <lower> | <upper> }
- # next one needs control directive too.
- token string { "'" [ <non_q_char> | [<apostrophe> ** 2] | [<reverse_solidus> ** 2] ]* "'" }
+ token string { "'" [ <non_q_char> | [<apostrophe> ** 2] | [<reverse_solidus> ** 2] | <control_directive> ]* "'" }
token entity_instance_name { '#' <digit>+ }
token enumeration { '.' <upper> [ <upper> | <digit> ]* '.' }
View
@@ -2,7 +2,7 @@ use v6;
use Test;
use ISO_10303_21::Grammar;
-plan 104;
+plan 108;
for <A A2 AB2 AB2A> -> $keyword {
my $match = ISO_10303_21::Grammar.parse($keyword, :rule<standard_keyword>);
@@ -52,10 +52,11 @@ for <1. -1.0 +1. 342.E2 -3.0E-2 0. -0.> -> $keyword {
ok $match, "<real> matches $keyword - 2";
}
-for ("''", "'This is a test'", "''''", "'\\\\a different test'") -> $keyword {
- my $match = ISO_10303_21::Grammar.parse($keyword, :rule<string>);
- isa_ok $match, Match, "<string> matches $keyword - 1";
- ok $match, "<string> matches $keyword - 2";
+for ("''", "'This is a test'", "''''", "'\\\\a different test'", "'H\\X4\\ACE0FAC3\\X0\\llo!'",
+ "'z\\X2\\6C34\\X0\\\\X4\\00010000\\X0\\\\X4\\0001D11E\\X0\\'") -> $string {
+ my $match = ISO_10303_21::Grammar.parse($string, :rule<string>);
+ isa_ok $match, Match, "<string> matches $string - 1";
+ ok $match, "<string> matches $string - 2";
}
for ("#1", "#23", "#141123") -> $keyword {

0 comments on commit ff14d08

Please sign in to comment.