sub ALLOW_CFORMAT_P () {'allow-cformat-p'}
sub new {
- my $this = shift;
- my($input) = @_;
- my $class = ref($this) || $this;
- my $self = {};
- bless $self, $class;
-
- my $handle = sprintf('TMPLTOKENIZER%d', $serial);
- $serial += 1;
-
- no strict;
- open($handle, "<$input") || die "$input: $!\n";
- use strict;
- $self->{+FILENAME} = $input;
- $self->{+HANDLE} = $handle;
- $self->{+READAHEAD} = [];
- return $self;
+ shift;
+ my ($filename) = @_;
+ open my $handle,$filename or die "can't open $filename";
+ bless {
+ filename => $filename
+ , handle => $handle
+ , readahead => []
+ } , __PACKAGE__;
}
###############################################################################
sub filename {
my $this = shift;
- return $this->{+FILENAME};
+ return $this->{filename};
}
sub _handle {
my $this = shift;
- return $this->{+HANDLE};
+ return $this->{handle};
}
sub fatal_p {
sub has_readahead_p {
my $this = shift;
- return @{$this->{+READAHEAD}};
+ return @{$this->{readahead}};
}
sub _peek_readahead {
my $this = shift;
- return $this->{+READAHEAD}->[$#{$this->{+READAHEAD}}];
+ return $this->{readahead}->[$#{$this->{readahead}}];
}
sub line_number_start {
sub _push_readahead {
my $this = shift;
- push @{$this->{+READAHEAD}}, $_[0];
+ push @{$this->{readahead}}, $_[0];
return $this;
}
sub _pop_readahead {
my $this = shift;
- return pop @{$this->{+READAHEAD}};
+ return pop @{$this->{readahead}};
}
sub _append_readahead {
my $this = shift;
- $this->{+READAHEAD}->[$#{$this->{+READAHEAD}}] .= $_[0];
+ $this->{readahead}->[$#{$this->{readahead}}] .= $_[0];
return $this;
}
sub _set_readahead {
my $this = shift;
- $this->{+READAHEAD}->[$#{$this->{+READAHEAD}}] = $_[0];
+ $this->{readahead}->[$#{$this->{readahead}}] = $_[0];
return $this;
}