-
Notifications
You must be signed in to change notification settings - Fork 257
/
TmplTokenType.pm
145 lines (104 loc) · 3.28 KB
/
TmplTokenType.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package C4::TmplTokenType;
# Copyright 2011 Tamil
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
require Exporter;
###############################################################################
=head1 NAME
C4::TmplTokenType.pm - Types of TmplToken objects
=head1 DESCRIPTION
This is a Java-style "safe enum" singleton class for types of TmplToken objects.
The predefined constants are
=cut
###############################################################################
###############################################################################
use vars qw( $_text $_text_parametrized $_cdata
$_tag $_decl $_pi $_directive $_comment $_null $_unknown );
our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
TEXT
TEXT_PARAMETRIZED
CDATA
TAG
DECL
PI
DIRECTIVE
COMMENT
UNKNOWN
);
my $new = sub {
my $this = 'C4::TmplTokenType';#shift;
my $class = ref($this) || $this;
my $self = {};
bless $self, $class;
($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
return $self;
};
$_text = &$new(0, 'TEXT');
$_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
$_cdata = &$new(1, 'CDATA');
$_tag = &$new(2, 'TAG');
$_decl = &$new(3, 'DECL');
$_pi = &$new(4, 'PI');
$_directive = &$new(5, 'DIRECTIVE');
$_comment = &$new(6, 'COMMENT');
$_unknown = &$new(7, 'UNKNOWN');
}
sub to_string {
my $this = shift;
return $this->{'name'}
}
sub TEXT { $_text }
sub TEXT_PARAMETRIZED { $_text_parametrized }
sub CDATA { $_cdata }
sub TAG { $_tag }
sub DECL { $_decl }
sub PI { $_pi }
sub DIRECTIVE { $_directive }
sub COMMENT { $_comment }
sub UNKNOWN { $_unknown }
###############################################################################
=over
=item TEXT
normal text (#text in the DTD)
=item TEXT_PARAMETRIZED
parametrized normal text
(result of simple recognition of text interspersed with <TMPL_VAR> directives;
this has to be explicitly enabled in the scanner)
=item CDATA
normal text (CDATA in the DTD)
=item TAG
something that has the form of an HTML tag
=item DECL
something that has the form of an SGML declaration
=item PI
something that has the form of an SGML processing instruction
=item DIRECTIVE
a Template Toolkit directive
=item COMMENT
something that has the form of an HTML comment
(and is not recognized as an HTML::Template directive)
=item UNKNOWN
something that is not recognized at all by the scanner
=back
Note that end of file is currently represented by undef,
instead of a constant predefined by this module.
=cut
1;