This repository has been archived by the owner on Mar 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_leo.t
107 lines (86 loc) · 3 KB
/
debug_leo.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/perl
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::XS. Marpa::XS is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::XS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser
# General Public License along with Marpa::XS. If not, see
# http://www.gnu.org/licenses/.
use 5.010;
use strict;
use warnings;
use Test::More tests => 3;
use English qw( -no_match_vars );
use Fatal qw( open close );
use lib 'tool/lib';
use Marpa::XS::Test;
BEGIN {
Test::More::use_ok('Marpa::XS');
}
my $progress_report = q{};
my $grammar = Marpa::XS::Grammar->new(
{ start => 'S',
strip => 0,
lhs_terminals => 0,
rules => [
{ lhs => 'S', rhs => [qw/Top_sequence/] },
{ lhs => 'Top_sequence', rhs => [qw/Top Top_sequence/] },
{ lhs => 'Top_sequence', rhs => [qw/Top/] },
{ lhs => 'Top', rhs => [qw/Upper_Middle/] },
{ lhs => 'Upper_Middle', rhs => [qw/Lower_Middle/] },
{ lhs => 'Lower_Middle', rhs => [qw/Bottom/] },
{ lhs => 'Bottom', rhs => [qw/T/] },
],
}
);
# Marpa::XS::Display::End
$grammar->precompute();
my $recce = Marpa::XS::Recognizer->new( { grammar => $grammar } );
my $current_earleme;
for ( 1 .. 20 ) { $recce->read('T'); }
# The call to current earleme is useless,
# but provides an example for the docs
# Marpa::XS::Display
# name: current_earleme Example
$current_earleme = $recce->current_earleme();
# Marpa::XS::Display::End
$progress_report = $recce->show_progress();
my $value_ref = $recce->value;
Test::More::ok( $value_ref, 'Parse ok?' );
# Marpa::XS::Display
# name: Debug Leo Example Progress Report
# start-after-line: END_PROGRESS_REPORT
# end-before-line: '^END_PROGRESS_REPORT$'
Marpa::XS::Test::is( $progress_report,
<<'END_PROGRESS_REPORT', 'sorted progress report' );
F0 @0-20 S -> Top_sequence .
P1 @20-20 Top_sequence -> . Top Top_sequence
R1:1 @19-20 Top_sequence -> Top . Top_sequence
F1 x20 @0...19-20 Top_sequence -> Top Top_sequence .
P2 @20-20 Top_sequence -> . Top
F2 @19-20 Top_sequence -> Top .
P3 @20-20 Top -> . Upper_Middle
F3 @19-20 Top -> Upper_Middle .
P4 @20-20 Upper_Middle -> . Lower_Middle
F4 @19-20 Upper_Middle -> Lower_Middle .
P5 @20-20 Lower_Middle -> . Bottom
F5 @19-20 Lower_Middle -> Bottom .
P6 @20-20 Bottom -> . T
F6 @19-20 Bottom -> T .
F7 @0-20 S['] -> S .
END_PROGRESS_REPORT
# Marpa::XS::Display::End
1; # In case used as "do" file
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: