| 1 | use 5.010scip-perl cpan Regexp-Grammars 1.058 `5.010`/; |
| 2 | use warningsscip-perl cpan Regexp-Grammars 1.058 warnings/; |
| 3 | |
| 4 | use Test::Morescip-perl cpan Regexp-Grammars 1.058 Test/More/ 'no_plan'; |
| 5 | |
| 6 | use Regexp::Grammarsscip-perl cpan Regexp-Grammars 1.058 Regexp/Grammars/; |
| 7 | |
| 8 | my $list_nonempty = qr{ |
| 9 | <List> |
| 10 | |
| 11 | <rule: List> |
| 12 | \( <[Value]>{0,1}%% <sep=(,)> \) |
| 13 | |
| 14 | <token: Value> |
| 15 | \d+ |
| 16 | }xms; |
| 17 | |
| 18 | no Regexp::Grammars; |
| 19 | |
| 20 | while (my $input = <DATA>) { |
| 21 | chompscip-perl cpan Regexp-Grammars 1.058 main/chomp(). $input; |
| 22 | my $input_copy = $input; |
| 23 | my ($list, $data_structure) = splitscip-perl cpan Regexp-Grammars 1.058 main/split(). /\s*:\s*/, $input; |
| 24 | |
| 25 | if ($list !~ m{ \( \s* \) }xms) { |
| 26 | ok +($input =~ $list_nonempty xor $data_structure =~ /FAIL/) => 'Correct for:' . $list; |
| 27 | if ($data_structure !~ /FAIL/) { |
| 28 | is_deeply $/scip-perl cpan Regexp-Grammars 1.058 main/`$/`.{List}{Value}, eval($data_structure) |
| 29 | => 'Build correct structure'; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | |
| 35 | __DATA__ |
| 36 | () : undef |
| 37 | (1) : [1] |
| 38 | (1,2) : FAIL |
| 39 | (1,2,3) : FAIL |
| 40 | (1,2,3,4) : FAIL |
| 41 | (1,2,3,4,5) : FAIL |
| 42 | ( ) : undef |
| 43 | ( 1 ) : [1] |
| 44 | (1, 2 ) : FAIL |
| 45 | (1, 2,3 ) : FAIL |
| 46 | (1, 2, 3, 4) : FAIL |
| 47 | (1, 2, 3, 4,5) : FAIL |
| 48 | (,) : undef |
| 49 | (1,) : [1] |
| 50 | (1,2,) : FAIL |
| 51 | (1,2,3,) : FAIL |
| 52 | (1,2,3,4,) : FAIL |
| 53 | (1,2,3,4,5,) : FAIL |
| 54 | ( ,) : undef |
| 55 | ( 1 ,) : [1] |
| 56 | (1, 2 ,) : FAIL |
| 57 | (1, 2,3 ,) : FAIL |
| 58 | (1, 2, 3, 4,) : FAIL |
| 59 | (1, 2, 3, 4,5,) : FAIL |