| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MarpaX::Demo::SampleScripts; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
544
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
549
|
use diagnostics; |
|
|
1
|
|
|
|
|
153416
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
353
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
38
|
|
|
6
|
1
|
|
|
1
|
|
642
|
use utf8; |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
4
|
|
|
7
|
1
|
|
|
1
|
|
31
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings qw(FATAL utf8); # Fatalize encoding glitches. |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
9
|
1
|
|
|
1
|
|
398
|
use open qw(:std :utf8); # Undeclared streams in UTF-8. |
|
|
1
|
|
|
|
|
860
|
|
|
|
1
|
|
|
|
|
5
|
|
|
10
|
1
|
|
|
1
|
|
562
|
use charnames qw(:full :short); # Unneeded in v5.16. |
|
|
1
|
|
|
|
|
24642
|
|
|
|
1
|
|
|
|
|
6
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
766
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
9271
|
|
|
|
1
|
|
|
|
|
71
|
|
|
13
|
1
|
|
|
1
|
|
470
|
use Data::Section; |
|
|
1
|
|
|
|
|
870173
|
|
|
|
1
|
|
|
|
|
7
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
716
|
use Marpa::R2; |
|
|
1
|
|
|
|
|
102175
|
|
|
|
1
|
|
|
|
|
44
|
|
|
16
|
1
|
|
|
1
|
|
666
|
use Marpa::R2::HTML; |
|
|
1
|
|
|
|
|
457705
|
|
|
|
1
|
|
|
|
|
60
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
85214
|
use Moo; |
|
|
1
|
|
|
|
|
81006
|
|
|
|
1
|
|
|
|
|
6
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
1939
|
use POSIX; |
|
|
1
|
|
|
|
|
5403
|
|
|
|
1
|
|
|
|
|
9
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
379799
|
use Try::Tiny; |
|
|
1
|
|
|
|
|
1327
|
|
|
|
1
|
|
|
|
|
76
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
840
|
use Types::Standard qw/Any ArrayRef HashRef Int Str/; |
|
|
1
|
|
|
|
|
64692
|
|
|
|
1
|
|
|
|
|
15
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub run |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Return 0 for success and 1 for failure. |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return 0; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} # End of run. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
C - A collection of scripts using Marpa::R2 |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 Synopsis |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
See scripts/*.pl. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 Description |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
C demonstrates various grammars and various ways to write and test |
|
57
|
|
|
|
|
|
|
scripts. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The whole point of this module is in scripts/*.pl. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 Installation |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Install C as you would for any C module: |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Run: |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
cpanm MarpaX::Demo::SampleScripts |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
or run: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sudo cpan MarpaX::Demo::SampleScripts |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
or unpack the distro, and then either: |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
perl Build.PL |
|
76
|
|
|
|
|
|
|
./Build |
|
77
|
|
|
|
|
|
|
./Build test |
|
78
|
|
|
|
|
|
|
sudo ./Build install |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
or: |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
perl Makefile.PL |
|
83
|
|
|
|
|
|
|
make (or dmake or nmake) |
|
84
|
|
|
|
|
|
|
make test |
|
85
|
|
|
|
|
|
|
make install |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 Constructor and Initialization |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
C is called as C<< my($parser) = MarpaX::Demo::SampleScripts -> new(k1 => v1, k2 => v2, ...) >>. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
It returns a new object of type C. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Key-value pairs accepted in the parameter list: |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
(None). |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 Methods |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 run() |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This method does nothing, and return 0 for success. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 Files Shipped with this Module |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Many of these scripts are gists, i.e. from https://gist.github.com/. You can always go there are |
|
110
|
|
|
|
|
|
|
search for some I text within the script, to see if there are other versions, or commentary |
|
111
|
|
|
|
|
|
|
available. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 Runnable Scripts |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
All these scripts are in the scripts/ directory. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item o ambiguous.grammar.03.pl |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
A grammar for the |
|
122
|
|
|
|
|
|
|
L language. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item o grammar.inspector.01.pl |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Display Marpa's view of the structure of a grammar. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item o html.02.pl |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Process defective HTML. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item o match.parentheses.01.pl |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Match nested parantheses, i.e. the '(' and ')' pair. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item o parmaterized.grammar.01.pl |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Handle parts of the grammar as strings, and interpolate various things into those strings, before |
|
139
|
|
|
|
|
|
|
using them to build the final grammar. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item o quoted.strings.01.pl |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item o Handle events |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item o Handle utf8 input |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item o Handle doublequoted strings |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item o Handle single-quoted strings |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item o quoted.strings.02.pl |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Handle nested, double-quoted, strings. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item o quoted.strings.03.pl |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Handle strings quoted with various characters, and with escaped characters in there too. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item o quoted.strings.04.pl |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 4 |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item o Handle strings containing escaped characters |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item o Handle events |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item o Handle unquoted strings |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item o Handle doublequoted strings |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item o Handle single-quoted strings |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item o use.utf8.01.pl |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over 4 |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item o Handle events |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item o Handle utf8 input |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item o Handle unquoted strings |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item o Handle doublequoted strings |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item o Handle single-quoted strings |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=back |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 Un-runnable Scripts |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
All these scripts are in the examples/ directory. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=over 4 |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item o ambiguous.grammar.01.pl |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Contains both ambiguous and un-ambiguous grammars. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Uses MarpaX::ASF::PFG, which is not on MetaCPAN. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item o html.01.pl |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Processes HTML. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Uses L, which won't install without patches, and which the author apparently |
|
214
|
|
|
|
|
|
|
refuses to fix. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item o match.keywords.pl |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=back |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 FAQ |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 Machine-Readable Change Log |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
The file Changes was converted into Changelog.ini by L. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 Version Numbers |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 Support |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Email the author, or log a bug on RT: |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 Author |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
L was written by Ron Savage Iron@savage.net.auE> in 2014. |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Marpa's homepage: . |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Homepage: L. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 Copyright |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Australian copyright (c) 2014, Ron Savage. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
All Programs of mine are 'OSI Certified Open Source Software'; |
|
250
|
|
|
|
|
|
|
you can redistribute them and/or modify them under the terms of |
|
251
|
|
|
|
|
|
|
The Artistic License 2.0, a copy of which is available at: |
|
252
|
|
|
|
|
|
|
http://www.opensource.org/licenses/index.html |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |