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