| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MasonX::Lexer::MSP; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Written by John Williams. Most code is plagurized from Lexer.pm, which is: |
|
4
|
|
|
|
|
|
|
# Copyright (c) 1998-2004 by Jonathan Swartz. All rights reserved. |
|
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
|
6
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
|
7
|
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
3089094
|
use strict; |
|
|
7
|
|
|
|
|
56
|
|
|
|
7
|
|
|
|
|
432
|
|
|
9
|
7
|
|
|
7
|
|
61
|
use warnings; |
|
|
7
|
|
|
|
|
27
|
|
|
|
7
|
|
|
|
|
622
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
|
11
|
7
|
|
|
7
|
|
103
|
use base qw(HTML::Mason::Lexer); |
|
|
7
|
|
|
|
|
22
|
|
|
|
7
|
|
|
|
|
1408
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
7
|
|
|
7
|
|
124
|
use HTML::Mason::Exceptions( abbr => [qw(param_error syntax_error error)] ); |
|
|
7
|
|
|
|
|
25
|
|
|
|
7
|
|
|
|
|
302
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
1006
|
use Params::Validate qw(:all); |
|
|
7
|
|
|
|
|
27
|
|
|
|
7
|
|
|
|
|
14147
|
|
|
16
|
|
|
|
|
|
|
Params::Validate::validation_options( on_fail => sub { param_error join '', @_ } ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->valid_params ( |
|
20
|
|
|
|
|
|
|
perl_lines => { parse => 'boolean', type => BOOLEAN, default => 0, |
|
21
|
|
|
|
|
|
|
descr => "Allow perl-lines to be used", }, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub start |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
156
|
|
|
156
|
0
|
615485
|
my $self = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
156
|
|
|
|
|
269
|
my $end; |
|
30
|
156
|
50
|
|
|
|
718
|
while ( defined $self->{current}{pos} ? |
|
31
|
|
|
|
|
|
|
$self->{current}{pos} < length $self->{current}{comp_source} : |
|
32
|
|
|
|
|
|
|
1 ) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
956
|
100
|
|
|
|
64583
|
last if $end = $self->match_end; |
|
35
|
|
|
|
|
|
|
|
|
36
|
804
|
100
|
|
|
|
9036
|
$self->match_block && next; |
|
37
|
|
|
|
|
|
|
|
|
38
|
718
|
100
|
|
|
|
8255
|
$self->match_named_block && next; |
|
39
|
|
|
|
|
|
|
|
|
40
|
668
|
100
|
|
|
|
4435
|
$self->match_substitute && next; |
|
41
|
|
|
|
|
|
|
|
|
42
|
553
|
100
|
|
|
|
1162
|
$self->match_code_tag && next; |
|
43
|
|
|
|
|
|
|
|
|
44
|
491
|
100
|
|
|
|
1024
|
$self->match_comment_tag && next; |
|
45
|
|
|
|
|
|
|
|
|
46
|
488
|
100
|
|
|
|
1312
|
$self->match_comp_call && next; |
|
47
|
|
|
|
|
|
|
|
|
48
|
445
|
100
|
|
|
|
3171
|
$self->match_perl_line && next; |
|
49
|
|
|
|
|
|
|
|
|
50
|
444
|
100
|
|
|
|
1133
|
$self->match_comp_content_call && next; |
|
51
|
|
|
|
|
|
|
|
|
52
|
425
|
100
|
|
|
|
2789
|
$self->match_comp_content_call_end && next; |
|
53
|
|
|
|
|
|
|
|
|
54
|
406
|
50
|
|
|
|
2638
|
$self->match_text && next; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
0
|
|
|
0
|
if ( ( $self->{current}{in_def} || $self->{current}{in_method} ) && |
|
|
|
|
0
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->{current}{comp_source} =~ /\G\z/ ) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
0
|
|
|
|
0
|
my $type = $self->{current}{in_def} ? 'def' : 'method'; |
|
60
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("Missing closing %$type> tag"); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# We should never get here - if we do, we're in an infinite loop. |
|
64
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("Infinite parsing loop encountered - Lexer bug?"); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
152
|
100
|
100
|
|
|
2742
|
if ( $self->{current}{in_def} || $self->{current}{in_method} ) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
48
|
100
|
|
|
|
118
|
my $type = $self->{current}{in_def} ? 'def' : 'method'; |
|
70
|
48
|
50
|
|
|
|
405
|
unless ( $end =~ m,%\Q$type\E>\n?,i ) |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
|
|
|
|
0
|
my $block_name = $self->{current}{"in_$type"}; |
|
73
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("No %$type> tag for <%$type $block_name> block"); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub match_substitute |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
668
|
|
|
668
|
0
|
762
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
668
|
100
|
|
|
|
2706
|
if ( $self->{current}{comp_source} =~ /\G<%=/gcs ) |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
115
|
50
|
|
|
|
929
|
if ( $self->{current}{comp_source} =~ /\G(.+?)(\s*\|\s*([\w\s,]+)?\s*)?%>/igcs ) |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
115
|
|
|
|
|
311
|
my ($sub, $escape) = ($1, $3); |
|
88
|
115
|
|
|
|
|
506
|
$self->{current}{compiler}->substitution( substitution => $sub, |
|
89
|
|
|
|
|
|
|
escape => $escape ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Add it in just to count lines |
|
92
|
115
|
100
|
|
|
|
7405
|
$sub .= $2 if $2; |
|
93
|
115
|
|
|
|
|
272
|
$self->{current}{lines} += $sub =~ tr/\n/\n/; |
|
94
|
|
|
|
|
|
|
|
|
95
|
115
|
|
|
|
|
540
|
return 1; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("'<%=' without matching '%>'"); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# match <% code %> |
|
105
|
|
|
|
|
|
|
# '<%' should not be immediately followed by '=', '|', '&', or '-' |
|
106
|
|
|
|
|
|
|
# '=' is substitution, '-' is comments, |
|
107
|
|
|
|
|
|
|
# '|' and '&' might be used for components calls in the future |
|
108
|
|
|
|
|
|
|
# Actually a space is preferred: i.e. '<% ' |
|
109
|
|
|
|
|
|
|
sub match_code_tag |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
553
|
|
|
553
|
0
|
597
|
my $self = shift; |
|
112
|
|
|
|
|
|
|
|
|
113
|
553
|
100
|
|
|
|
2152
|
if ( $self->{current}{comp_source} =~ /\G<%(?![=|&-])/gcs ) |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
62
|
50
|
|
|
|
318
|
if ( $self->{current}{comp_source} =~ /\G(.+?)%>/gcs ) |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
62
|
|
|
|
|
127
|
my $code = $1; |
|
118
|
62
|
|
|
|
|
265
|
$self->{current}{compiler}->raw_block( block_type => 'perl', |
|
119
|
|
|
|
|
|
|
block => $code ); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# count lines |
|
122
|
62
|
|
|
|
|
3481
|
$self->{current}{lines} += $code =~ tr/\n/\n/; |
|
123
|
|
|
|
|
|
|
|
|
124
|
62
|
|
|
|
|
303
|
return 1; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
else |
|
127
|
|
|
|
|
|
|
{ |
|
128
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("'<%' without matching '%>'"); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub match_comment_tag |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
491
|
|
|
491
|
0
|
527
|
my $self = shift; |
|
136
|
|
|
|
|
|
|
|
|
137
|
491
|
100
|
|
|
|
1859
|
if ( $self->{current}{comp_source} =~ /\G<%--/gcs ) |
|
138
|
|
|
|
|
|
|
{ |
|
139
|
3
|
50
|
|
|
|
16
|
if ( $self->{current}{comp_source} =~ /\G(.*?)--%>/gcs ) |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
3
|
|
|
|
|
141
|
my $comment = $1; |
|
142
|
3
|
|
|
|
|
19
|
$self->{current}{compiler}->doc_block( block_type => 'doc', |
|
143
|
|
|
|
|
|
|
block => $comment ); |
|
144
|
|
|
|
|
|
|
|
|
145
|
3
|
|
|
|
|
10
|
$self->{current}{lines} += $comment =~ tr/\n/\n/; |
|
146
|
|
|
|
|
|
|
|
|
147
|
3
|
|
|
|
|
16
|
return 1; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
else |
|
150
|
|
|
|
|
|
|
{ |
|
151
|
0
|
|
|
|
|
0
|
$self->throw_syntax_error("'<%--' without matching '--%>'"); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub match_perl_line |
|
158
|
|
|
|
|
|
|
{ |
|
159
|
445
|
|
|
445
|
0
|
498
|
my $self = shift; |
|
160
|
|
|
|
|
|
|
|
|
161
|
445
|
100
|
|
|
|
1434
|
return 0 unless $self->{perl_lines}; |
|
162
|
|
|
|
|
|
|
|
|
163
|
5
|
|
|
|
|
25
|
return $self->SUPER::match_perl_line(@_); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__END__ |