Continuing on my tests mission
[koha.git] / misc / translator / TmplTokenType.pm
1 package TmplTokenType;
2
3 use strict;
4 require Exporter;
5
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
7
8 ###############################################################################
9
10 =head1 NAME
11
12 TmplTokenType.pm - Types of TmplToken objects
13
14 =head1 DESCRIPTION
15
16 This is a Java-style "safe enum" singleton class for types of TmplToken objects.
17 The predefined constants are
18
19 =cut
20
21 ###############################################################################
22
23 $VERSION = 0.01;
24
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
36 );
37
38 ###############################################################################
39
40 use vars qw( $_text $_text_parametrized $_cdata
41     $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
42
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;
51     };
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');
61 }
62
63 sub to_string {
64     my $this = shift;
65     return $this->{'name'}
66 }
67
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 }
77
78 ###############################################################################
79
80 =over
81
82 =item TEXT
83
84 normal text (#text in the DTD)
85
86 =item TEXT_PARAMETRIZED
87
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)
91
92 =item CDATA
93
94 normal text (CDATA in the DTD)
95
96 =item TAG
97
98 something that has the form of an HTML tag
99
100 =item DECL
101
102 something that has the form of an SGML declaration
103
104 =item PI
105
106 something that has the form of an SGML processing instruction
107
108 =item DIRECTIVE
109
110 a HTML::Template directive (whether or not embedded in an SGML comment)
111
112 =item COMMENT
113
114 something that has the form of an HTML comment
115 (and is not recognized as an HTML::Template directive)
116
117 =item UNKNOWN
118
119 something that is not recognized at all by the scanner
120
121 =back
122
123 Note that end of file is currently represented by undef,
124 instead of a constant predefined by this module.
125
126 =cut
127
128 1;