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