Fix for Bug 4024, Search history template problems, and other fixes.
[koha.git] / misc / translator / TmplTokenType.pm
blob75d4f5256a3b24f40e574ef7d7ac75f2ed3831eb
1 package TmplTokenType;
3 use strict;
4 require Exporter;
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8 ###############################################################################
10 =head1 NAME
12 TmplTokenType.pm - Types of TmplToken objects
14 =head1 DESCRIPTION
16 This is a Java-style "safe enum" singleton class for types of TmplToken objects.
17 The predefined constants are
19 =cut
21 ###############################################################################
23 $VERSION = 0.01;
25 @ISA = qw(Exporter);
26 @EXPORT_OK = qw(
27 &TEXT
28 &TEXT_PARAMETRIZED
29 &CDATA
30 &TAG
31 &DECL
32 &PI
33 &DIRECTIVE
34 &COMMENT
35 &UNKNOWN
38 ###############################################################################
40 use vars qw( $_text $_text_parametrized $_cdata
41 $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
43 BEGIN {
44 my $new = sub {
45 my $this = 'TmplTokenType';#shift;
46 my $class = ref($this) || $this;
47 my $self = {};
48 bless $self, $class;
49 ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
50 return $self;
52 $_text = &$new(0, 'TEXT');
53 $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
54 $_cdata = &$new(1, 'CDATA');
55 $_tag = &$new(2, 'TAG');
56 $_decl = &$new(3, 'DECL');
57 $_pi = &$new(4, 'PI');
58 $_directive = &$new(5, 'DIRECTIVE');
59 $_comment = &$new(6, 'COMMENT');
60 $_unknown = &$new(7, 'UNKNOWN');
63 sub to_string {
64 my $this = shift;
65 return $this->{'name'}
68 sub TEXT () { $_text }
69 sub TEXT_PARAMETRIZED () { $_text_parametrized }
70 sub CDATA () { $_cdata }
71 sub TAG () { $_tag }
72 sub DECL () { $_decl }
73 sub PI () { $_pi }
74 sub DIRECTIVE () { $_directive }
75 sub COMMENT () { $_comment }
76 sub UNKNOWN () { $_unknown }
78 ###############################################################################
80 =over
82 =item TEXT
84 normal text (#text in the DTD)
86 =item TEXT_PARAMETRIZED
88 parametrized normal text
89 (result of simple recognition of text interspersed with <TMPL_VAR> directives;
90 this has to be explicitly enabled in the scanner)
92 =item CDATA
94 normal text (CDATA in the DTD)
96 =item TAG
98 something that has the form of an HTML tag
100 =item DECL
102 something that has the form of an SGML declaration
104 =item PI
106 something that has the form of an SGML processing instruction
108 =item DIRECTIVE
110 a HTML::Template directive (whether or not embedded in an SGML comment)
112 =item COMMENT
114 something that has the form of an HTML comment
115 (and is not recognized as an HTML::Template directive)
117 =item UNKNOWN
119 something that is not recognized at all by the scanner
121 =back
123 Note that end of file is currently represented by undef,
124 instead of a constant predefined by this module.
126 =cut