File Coverage

blib/lib/Parse/Yapp/Output.pm
Criterion Covered Total %
statement 29 34 85.2
branch 2 6 33.3
condition 1 2 50.0
subroutine 5 6 83.3
pod 0 1 0.0
total 37 49 75.5


line stmt bran cond sub pod time code
1             #
2             # Module Parse::Yapp::Output
3             #
4             # Copyright © 1998, 1999, 2000, 2001, Francois Desarmenien.
5             # Copyright © 2017 William N. Braswell, Jr.
6             # (see the pod text in Parse::Yapp module for use and distribution rights)
7             #
8             package Parse::Yapp::Output;
9             @ISA=qw ( Parse::Yapp::Lalr );
10              
11             require 5.004;
12              
13 3     3   1056 use Parse::Yapp::Lalr;
  3         10  
  3         98  
14 3     3   18 use Parse::Yapp::Driver;
  3         6  
  3         67  
15              
16 3     3   15 use strict;
  3         6  
  3         59  
17              
18 3     3   16 use Carp;
  3         21  
  3         1025  
19              
20             sub _CopyDriver {
21 0     0   0 my($text)='#Included Parse/Yapp/Driver.pm file'.('-' x 40)."\n";
22 0 0       0 open(DRV,$Parse::Yapp::Driver::FILENAME)
23             or die "BUG: could not open $Parse::Yapp::Driver::FILENAME";
24 0         0 $text.="{\n".join('',)."}\n";
25 0         0 close(DRV);
26 0         0 $text.='#End of include'.('-' x 50)."\n";
27             }
28              
29             sub Output {
30 9     9 0 110 my($self)=shift;
31              
32 9         51 $self->Options(@_);
33              
34 9         32 my($package)=$self->Option('classname');
35 9         21 my($head,$states,$rules,$tail,$driver);
36 9         20 my($version)=$Parse::Yapp::Driver::VERSION;
37 9         12 my($datapos);
38 9   50     26 my($text)=$self->Option('template') ||<<'EOT';
39             ####################################################################
40             #
41             # This file was generated using Parse::Yapp version <<$version>>.
42             #
43             # Don't edit this file, use source file instead.
44             #
45             # ANY CHANGE MADE HERE WILL BE LOST !
46             #
47             ####################################################################
48             package <<$package>>;
49             use vars qw ( @ISA );
50             use strict;
51              
52             @ISA= qw ( Parse::Yapp::Driver );
53             <<$driver>>
54              
55             <<$head>>
56              
57             sub new {
58             my($class)=shift;
59             ref($class)
60             and $class=ref($class);
61              
62             my($self)=$class->SUPER::new( yyversion => '<<$version>>',
63             yystates =>
64             <<$states>>,
65             yyrules =>
66             <<$rules>>,
67             @_);
68             bless($self,$class);
69             }
70              
71             <<$tail>>
72             1;
73             EOT
74              
75 9         20 $driver='use Parse::Yapp::Driver;';
76              
77 9 50       21 defined($package)
78             or $package='Parse::Yapp::Default';
79              
80 9         38 $head= $self->Head();
81 9         34 $rules=$self->RulesTable();
82 9         39 $states=$self->DfaTable();
83 9         42 $tail= $self->Tail();
84              
85 9 50       23 $self->Option('standalone')
86             and $driver=_CopyDriver();
87              
88 9         91 $text=~s/<<(\$.+)>>/$1/gee;
  72         2598  
89              
90 9         85 $text;
91             }
92              
93             1;