line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2022 Jeffrey Kegler |
2
|
|
|
|
|
|
|
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
3
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU Lesser |
4
|
|
|
|
|
|
|
# General Public License as published by the Free Software Foundation, |
5
|
|
|
|
|
|
|
# either version 3 of the License, or (at your option) any later version. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Marpa::R2 is distributed in the hope that it will be useful, |
8
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
10
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser |
13
|
|
|
|
|
|
|
# General Public License along with Marpa::R2. If not, see |
14
|
|
|
|
|
|
|
# http://www.gnu.org/licenses/. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Marpa::R2::HTML::Config; |
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
8
|
|
144
|
use 5.010001; |
|
8
|
|
|
|
|
27
|
|
19
|
8
|
|
|
8
|
|
37
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
197
|
|
20
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
248
|
|
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
43
|
use vars qw($VERSION $STRING_VERSION); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
723
|
|
23
|
|
|
|
|
|
|
$VERSION = '13.002_000'; |
24
|
|
|
|
|
|
|
$STRING_VERSION = $VERSION; |
25
|
|
|
|
|
|
|
## no critic(BuiltinFunctions::ProhibitStringyEval) |
26
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
27
|
|
|
|
|
|
|
## use critic |
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
8
|
|
55
|
use English qw( -no_match_vars ); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
61
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Generate the default configuration |
32
|
|
|
|
|
|
|
sub new { |
33
|
93
|
|
|
93
|
0
|
203
|
my ($class) = @_; |
34
|
93
|
|
|
|
|
16021
|
require Marpa::R2::HTML::Config::Default; |
35
|
93
|
|
|
|
|
448
|
my $self = { |
36
|
|
|
|
|
|
|
rules => $Marpa::R2::HTML::Internal::Config::Default::CORE_RULES, |
37
|
|
|
|
|
|
|
runtime_tag => |
38
|
|
|
|
|
|
|
$Marpa::R2::HTML::Internal::Config::Default::RUNTIME_TAG, |
39
|
|
|
|
|
|
|
ruby_slippers_rank_by_name => |
40
|
|
|
|
|
|
|
$Marpa::R2::HTML::Internal::Config::Default::RUBY_SLIPPERS_RANK_BY_NAME, |
41
|
|
|
|
|
|
|
is_empty_element => |
42
|
|
|
|
|
|
|
$Marpa::R2::HTML::Internal::Config::Default::IS_EMPTY_ELEMENT, |
43
|
|
|
|
|
|
|
primary_group_by_tag => |
44
|
|
|
|
|
|
|
$Marpa::R2::HTML::Internal::Config::Default::PRIMARY_GROUP_BY_TAG |
45
|
|
|
|
|
|
|
}; |
46
|
93
|
|
|
|
|
382
|
return bless $self, $class; |
47
|
|
|
|
|
|
|
} ## end sub new |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new_from_compile { |
50
|
1
|
|
|
1
|
0
|
4
|
my ( $class, $source_ref ) = @_; |
51
|
1
|
|
|
|
|
630
|
require Marpa::R2::HTML::Config::Compile; |
52
|
1
|
|
|
|
|
5
|
return bless Marpa::R2::HTML::Config::Compile::compile($source_ref), $class; |
53
|
|
|
|
|
|
|
} ## end sub new_from_compile |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub contents { |
56
|
96
|
|
|
96
|
0
|
211
|
my ($self) = @_; |
57
|
96
|
|
|
|
|
415
|
return @{$self}{ |
58
|
96
|
|
|
|
|
169
|
qw( rules runtime_tag |
59
|
|
|
|
|
|
|
ruby_slippers_rank_by_name is_empty_element |
60
|
|
|
|
|
|
|
primary_group_by_tag |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
} ## end sub contents |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $legal_preamble = <<'END_OF_TEXT'; |
66
|
|
|
|
|
|
|
# Copyright 2022 Jeffrey Kegler |
67
|
|
|
|
|
|
|
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
68
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU Lesser |
69
|
|
|
|
|
|
|
# General Public License as published by the Free Software Foundation, |
70
|
|
|
|
|
|
|
# either version 3 of the License, or (at your option) any later version. |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# Marpa::R2 is distributed in the hope that it will be useful, |
73
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
74
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
75
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser |
78
|
|
|
|
|
|
|
# General Public License along with Marpa::R2. If not, see |
79
|
|
|
|
|
|
|
# http://www.gnu.org/licenses/. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
END_OF_TEXT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub sort_bnf { |
84
|
902
|
|
|
902
|
0
|
1128
|
my $cmp = $a->{lhs} cmp $b->{lhs}; |
85
|
902
|
100
|
|
|
|
1213
|
return $cmp if $cmp; |
86
|
129
|
|
|
|
|
153
|
my $a_rhs_length = scalar @{ $a->{rhs} }; |
|
129
|
|
|
|
|
153
|
|
87
|
129
|
|
|
|
|
126
|
my $b_rhs_length = scalar @{ $b->{rhs} }; |
|
129
|
|
|
|
|
143
|
|
88
|
129
|
|
|
|
|
145
|
$cmp = $a_rhs_length <=> $b_rhs_length; |
89
|
129
|
50
|
|
|
|
172
|
return $cmp if $cmp; |
90
|
129
|
|
|
|
|
159
|
for my $ix ( 0 .. $a_rhs_length ) { |
91
|
129
|
|
|
|
|
193
|
$cmp = $a->{rhs}->[$ix] cmp $b->{rhs}->[$ix]; |
92
|
129
|
50
|
|
|
|
231
|
return $cmp if $cmp; |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
0
|
return 0; |
95
|
|
|
|
|
|
|
} ## end sub sort_bnf |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub as_string { |
98
|
2
|
|
|
2
|
0
|
5
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
19
|
require Data::Dumper; |
101
|
2
|
|
|
|
|
10
|
require Marpa::R2::HTML::Config::Default; |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
9
|
local $Data::Dumper::Purity = 1; |
104
|
2
|
|
|
|
|
6
|
local $Data::Dumper::Sortkeys = 1; |
105
|
2
|
|
|
|
|
8
|
my @contents = $self->contents(); |
106
|
2
|
|
|
|
|
9
|
my @rules = sort sort_bnf @{$contents[0]}; |
|
2
|
|
|
|
|
22
|
|
107
|
2
|
|
|
|
|
10
|
$contents[0] = \@rules; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Start with the legal language |
110
|
|
|
|
|
|
|
return \( |
111
|
2
|
|
|
|
|
191
|
$legal_preamble |
112
|
|
|
|
|
|
|
. '# This file was generated automatically by ' |
113
|
|
|
|
|
|
|
. __PACKAGE__ . "\n" |
114
|
|
|
|
|
|
|
. '# The date of generation was ' |
115
|
|
|
|
|
|
|
. ( scalar localtime() ) . "\n" . "\n" |
116
|
|
|
|
|
|
|
. "package Marpa::R2::HTML::Internal::Config::Default;\n" . "\n" |
117
|
|
|
|
|
|
|
. Data::Dumper->Dump( |
118
|
|
|
|
|
|
|
\@contents, |
119
|
|
|
|
|
|
|
[ qw( CORE_RULES RUNTIME_TAG |
120
|
|
|
|
|
|
|
RUBY_SLIPPERS_RANK_BY_NAME IS_EMPTY_ELEMENT |
121
|
|
|
|
|
|
|
PRIMARY_GROUP_BY_TAG |
122
|
|
|
|
|
|
|
) |
123
|
|
|
|
|
|
|
] |
124
|
|
|
|
|
|
|
) |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} ## end sub as_string |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# vim: set expandtab shiftwidth=4: |