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