Debian Codegraph @

t/debug_seq.t

raw
1 #!/usr/bin/perl
2 # Copyright 2022 Jeffrey Kegler
3 # This file is part of Marpa::R2. Marpa::R2 is free software: you can
4 # redistribute it and/or modify it under the terms of the GNU Lesser
5 # General Public License as published by the Free Software Foundation,
6 # either version 3 of the License, or (at your option) any later version.
7 #
8 # Marpa::R2 is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser
14 # General Public License along with Marpa::R2. If not, see
15 # http://www.gnu.org/licenses/.
16
17 # Debug Sequence Example
18
19 use 5.010001;
20 use strict;
21 use warnings;
22
23 use Test::More tests => 3;
24
25 use English qw( -no_match_vars );
26 use Fatal qw( open close );
27 use lib 'inc';
28 use Marpa::R2::Test;
29 use Marpa::R2;
30
31 my $progress_report = q{};
32
33 my $grammar = Marpa::R2::Grammar->new(
34 { start => 'Document',
35 rules => [ { lhs => 'Document', rhs => [qw/Stuff/], min => 1 }, ],
36 }
37 );
38
39 $grammar->precompute();
40
41 my $recce = Marpa::R2::Recognizer->new( { grammar => $grammar } );
42
43 # Marpa::R2::Display
44 # name: Recognizer check_terminal Synopsis
45
46 my $is_symbol_a_terminal = $recce->check_terminal('Document');
47
48 # Marpa::R2::Display::End
49
50 Test::More::ok( !$is_symbol_a_terminal, 'LHS terminal?' );
51
52 my $token_ix = 0;
53
54 $recce->read('Stuff');
55 $recce->read('Stuff');
56 $recce->read('Stuff');
57
58 $progress_report = $recce->show_progress(0);
59
60 my $value_ref = $recce->value;
61 Test::More::ok( $value_ref, 'Parse ok?' );
62
63 Marpa::R2::Test::is( $progress_report,
64 << 'END_PROGRESS_REPORT', 'progress report' );
65 P0 @0-0 Document -> . Stuff+
66 END_PROGRESS_REPORT
67
68 1; # In case used as "do" file
69
70 # Local Variables:
71 # mode: cperl
72 # cperl-indent-level: 4
73 # fill-column: 100
74 # End:
75 # vim: expandtab shiftwidth=4: