File Coverage

blib/lib/MarpaX/Demo/SampleScripts.pm
Criterion Covered Total %
statement 48 50 96.0
branch n/a
condition n/a
subroutine 16 17 94.1
pod 1 1 100.0
total 65 68 95.5


line stmt bran cond sub pod time code
1             package MarpaX::Demo::SampleScripts;
2              
3 1     1   430 use 5.010;
  1         2  
  1         28  
4 1     1   566 use diagnostics;
  1         140141  
  1         10  
5 1     1   422 use strict;
  1         8  
  1         38  
6 1     1   759 use utf8;
  1         8  
  1         5  
7 1     1   34 use warnings;
  1         1  
  1         36  
8 1     1   3 use warnings qw(FATAL utf8); # Fatalize encoding glitches.
  1         1  
  1         31  
9 1     1   401 use open qw(:std :utf8); # Undeclared streams in UTF-8.
  1         831  
  1         4  
10 1     1   548 use charnames qw(:full :short); # Unneeded in v5.16.
  1         24872  
  1         5  
11              
12 1     1   735 use Data::Dumper;
  1         6250  
  1         59  
13 1     1   435 use Data::Section;
  1         20841  
  1         7  
14              
15 1     1   629 use Marpa::R2;
  1         100838  
  1         53  
16 1     1   693 use Marpa::R2::HTML;
  1         19098  
  1         86  
17              
18 1     1   878 use Moo;
  1         16371  
  1         8  
19              
20 1     1   2004 use POSIX;
  1         4692  
  1         6  
21              
22 1     1   2661 use Try::Tiny;
  1         901  
  1         47  
23              
24 1     1   517 use Types::Standard qw/Any ArrayRef HashRef Int Str/;
  1         51666  
  1         13  
25              
26             our $VERSION = '1.02';
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 match.parentheses.02.pl
137              
138             This sophisticated example checks files for matching brackets: (){}[].
139              
140             Or, it can be run (self-tested) with the '--test' option'.
141              
142             The new rejection events are used, along with the Ruby Slippers, meaning it requires L
143             V 2.098000.
144              
145             This program uses the method of adding known tokens (my $suffix = '(){}[]';) to the end of the input
146             string so Marpa can be told to search just that part of the string when the logic dictates that a
147             Ruby Slippers token (bracket) is to be passed to Marpa to satisfy the grammar. It's put at the end
148             so that it does not interfere with line and column counts in the original input string.
149              
150             =item o parmaterized.grammar.01.pl
151              
152             Handle parts of the grammar as strings, and interpolate various things into those strings, before
153             using them to build the final grammar.
154              
155             =item o quoted.strings.01.pl
156              
157             =over 4
158              
159             =item o Handle events
160              
161             =item o Handle utf8 input
162              
163             =item o Handle doublequoted strings
164              
165             =item o Handle single-quoted strings
166              
167             =back
168              
169             =item o quoted.strings.02.pl
170              
171             Handle nested, double-quoted, strings.
172              
173             =item o quoted.strings.03.pl
174              
175             Handle strings quoted with various characters, and with escaped characters in there too.
176              
177             =item o quoted.strings.04.pl
178              
179             Uses a grammar with pauses to handle various types of quoted strings, with manual scanning.
180              
181             See quoted.strings.05.pl for getting Marpa to handling the scanning of HTML.
182              
183             =item o quoted.strings.05.pl
184              
185             Handles HTML.
186              
187             =over 4
188              
189             =item o Handle strings containing escaped characters
190              
191             =item o Handle events
192              
193             =item o Handle unquoted strings
194              
195             =item o Handle doublequoted strings
196              
197             =item o Handle single-quoted strings
198              
199             =back
200              
201             =item o use.utf8.01.pl
202              
203             =over 4
204              
205             =item o Handle events
206              
207             =item o Handle utf8 input
208              
209             =item o Handle unquoted strings
210              
211             =item o Handle doublequoted strings
212              
213             =item o Handle single-quoted strings
214              
215             =back
216              
217             =back
218              
219             =head2 Un-runnable Scripts
220              
221             All these scripts are in the examples/ directory.
222              
223             =over 4
224              
225             =item o ambiguous.grammar.01.pl
226              
227             Contains both ambiguous and un-ambiguous grammars.
228              
229             Uses MarpaX::ASF::PFG, which is not on MetaCPAN.
230              
231             =item o html.01.pl
232              
233             Processes HTML.
234              
235             Uses L, which won't install without patches, and which the author apparently
236             refuses to fix.
237              
238             =item o match.keywords.pl
239              
240              
241             =back
242              
243             =head1 FAQ
244              
245             =head2 Do any scripts handle HTML?
246              
247             Yes. See scripts/quoted.strings.05.pl.
248              
249             =head1 Machine-Readable Change Log
250              
251             The file Changes was converted into Changelog.ini by L.
252              
253             =head1 Version Numbers
254              
255             Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
256              
257             =head1 Support
258              
259             Email the author, or log a bug on RT:
260              
261             L.
262              
263             =head1 Author
264              
265             L was written by Ron Savage Iron@savage.net.auE> in 2014.
266              
267             Marpa's homepage: .
268              
269             My homepage: L.
270              
271             =head1 Copyright
272              
273             Australian copyright (c) 2014, Ron Savage.
274              
275             All Programs of mine are 'OSI Certified Open Source Software';
276             you can redistribute them and/or modify them under the terms of
277             The Artistic License 2.0, a copy of which is available at:
278             http://www.opensource.org/licenses/index.html
279              
280             =cut