diff --git a/lib/ISO_10303_21/Grammar.pm b/lib/ISO_10303_21/Grammar.pm index 143518e..a3a4630 100644 --- a/lib/ISO_10303_21/Grammar.pm +++ b/lib/ISO_10303_21/Grammar.pm @@ -19,4 +19,16 @@ grammar ISO_10303_21::Grammar token keyword { | } token sign { '+' | '-' } + token integer { ? * } + token real { ? + '.' * [ 'E' ? + ]? } + + token non_q_char { | | | | } + # next one needs control directive too. + token string { "'" [ | [ ** 2] | [ ** 2] ]* "'" } + + token entity_instance_name { '#' + } + token enumeration { '.' [ | ]* '.' } + + token hex { <[0..9]> | <[A..F]> } + token binary { '"' <[0..3]> * '"' } } \ No newline at end of file diff --git a/t/02-tokens.t b/t/02-tokens.t index 10be757..4984ae5 100644 --- a/t/02-tokens.t +++ b/t/02-tokens.t @@ -38,6 +38,36 @@ for ("+", "-") -> $keyword { ok $match, " matches $keyword - 2"; } +for <1 -1 +1 342 -3 0 -0> -> $keyword { + my $match = ISO_10303_21::Grammar.parse($keyword, :rule); + isa_ok $match, Match, " matches $keyword - 1"; + ok $match, " matches $keyword - 2"; +} + +for <1. -1.0 +1. 342.E2 -3.0E-2 0. -0.> -> $keyword { + my $match = ISO_10303_21::Grammar.parse($keyword, :rule); + isa_ok $match, Match, " matches $keyword - 1"; + ok $match, " matches $keyword - 2"; +} + +for ("''", "'This is a test'", "''''", "'\\\\a different test'") -> $keyword { + my $match = ISO_10303_21::Grammar.parse($keyword, :rule); + isa_ok $match, Match, " matches $keyword - 1"; + ok $match, " matches $keyword - 2"; +} + +for ("#1", "#23", "#141123") -> $keyword { + my $match = ISO_10303_21::Grammar.parse($keyword, :rule); + isa_ok $match, Match, " matches $keyword - 1"; + ok $match, " matches $keyword - 2"; +} + +for (".A.", ".AD2.", ".GD.") -> $keyword { + my $match = ISO_10303_21::Grammar.parse($keyword, :rule); + isa_ok $match, Match, " matches $keyword - 1"; + ok $match, " matches $keyword - 2"; +} + done; \ No newline at end of file