1 package TemplateInputReader
;
3 # ************************************************************
4 # Description : Reads the template input and stores the values
5 # Author : Chad Elliott
6 # Create Date : 5/16/2002
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
20 # ************************************************************
22 # ************************************************************
26 # ************************************************************
28 # ************************************************************
31 my($class, $inc) = @_;
32 my $self = Parser
::new
($class, $inc);
34 ## Set up the internal data members
35 $self->{'values'} = {};
36 $self->{'cindex'} = 0;
37 $self->{'current'} = [ $self->{'values'} ];
38 $self->{'realnames'} = {};
45 my($self, $ih, $line) = @_;
48 my $current = $self->{'current'};
52 elsif ($line =~ /^([-\w\s\(\)\.]+)\s*{$/) {
53 ## Entering a new scope, we need to save the real name so that it can
54 ## be accessed at a later time.
57 my $name = lc($rname);
58 $self->{'realnames'}->{$name} = $rname;
60 ## Scopes are reentrant, so we only create a new map when we haven't
62 if (!defined $$current[$self->{'cindex'}]->{$name}) {
63 $$current[$self->{'cindex'}]->{$name} = {};
66 ## Keep track of the current scope
67 push(@
$current, $$current[$self->{'cindex'}]->{$name});
70 elsif ($line =~ /^}$/) {
71 ## Maintain the scope and make sure there aren't any unmatched
73 if ($self->{'cindex'} > 0) {
79 $errorString = 'Unmatched curly brace';
82 elsif ($line =~ /^(\w+)\s*(\+=|=)\s*(.*)?/) {
83 ## Save the name, operation type and value.
88 ## Turn the value into an array
90 $value = $self->create_array($value);
97 if ($op eq '+=' && defined $$current[$self->{'cindex'}]->{$name}) {
98 push(@
{$$current[$self->{'cindex'}]->{$name}}, @
$value);
101 $$current[$self->{'cindex'}]->{$name} = $value;
104 elsif ($line =~ /^conditional_include\s+"([\w\s\-\+\/\\\
.]+)"$/) {
105 ## Search for the include template file. If it does not exist, we
106 ## don't complain. It's likely that these sort of files won't exist.
107 my $file = $self->search_include_path("$1.$mpt");
109 ## Process the file making sure to restore the line number seting
111 my $ol = $self->get_line_number();
112 ($status, $errorString) = $self->read_file($file);
113 $self->set_line_number($ol);
118 $errorString = "Unrecognized line
: $line";
121 return $status, $errorString;
126 ## All template names are case-insensitive.
127 my($self, $tag) = @_;
128 return $self->{'values'}->{lc($tag)};
133 ## Sometimes, we need to get back to the name retaining the case so we
134 ## access the hash map containing them.
135 my($self, $tag) = @_;
136 return $self->{'realnames'}->{lc($tag)};