| 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
|
|
172
|
use 5.010001; |
|
|
8
|
|
|
|
|
24
|
|
|
19
|
8
|
|
|
8
|
|
39
|
use strict; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
170
|
|
|
20
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
|
8
|
|
|
|
|
23
|
|
|
|
8
|
|
|
|
|
275
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
47
|
use vars qw($VERSION $STRING_VERSION); |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
653
|
|
|
23
|
|
|
|
|
|
|
$VERSION = '12.000000'; |
|
24
|
|
|
|
|
|
|
$STRING_VERSION = $VERSION; |
|
25
|
|
|
|
|
|
|
## no critic(BuiltinFunctions::ProhibitStringyEval) |
|
26
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
27
|
|
|
|
|
|
|
## use critic |
|
28
|
|
|
|
|
|
|
|
|
29
|
8
|
|
|
8
|
|
50
|
use English qw( -no_match_vars ); |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
75
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Generate the default configuration |
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
93
|
|
|
93
|
0
|
212
|
my ($class) = @_; |
|
34
|
93
|
|
|
|
|
15958
|
require Marpa::R2::HTML::Config::Default; |
|
35
|
93
|
|
|
|
|
444
|
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
|
|
|
|
|
345
|
return bless $self, $class; |
|
47
|
|
|
|
|
|
|
} ## end sub new |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new_from_compile { |
|
50
|
1
|
|
|
1
|
0
|
3
|
my ( $class, $source_ref ) = @_; |
|
51
|
1
|
|
|
|
|
569
|
require Marpa::R2::HTML::Config::Compile; |
|
52
|
1
|
|
|
|
|
7
|
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
|
182
|
my ($self) = @_; |
|
57
|
96
|
|
|
|
|
414
|
return @{$self}{ |
|
58
|
96
|
|
|
|
|
175
|
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
|
904
|
|
|
904
|
0
|
1128
|
my $cmp = $a->{lhs} cmp $b->{lhs}; |
|
85
|
904
|
100
|
|
|
|
1262
|
return $cmp if $cmp; |
|
86
|
126
|
|
|
|
|
120
|
my $a_rhs_length = scalar @{ $a->{rhs} }; |
|
|
126
|
|
|
|
|
149
|
|
|
87
|
126
|
|
|
|
|
126
|
my $b_rhs_length = scalar @{ $b->{rhs} }; |
|
|
126
|
|
|
|
|
137
|
|
|
88
|
126
|
|
|
|
|
160
|
$cmp = $a_rhs_length <=> $b_rhs_length; |
|
89
|
126
|
50
|
|
|
|
165
|
return $cmp if $cmp; |
|
90
|
126
|
|
|
|
|
163
|
for my $ix ( 0 .. $a_rhs_length ) { |
|
91
|
126
|
|
|
|
|
194
|
$cmp = $a->{rhs}->[$ix] cmp $b->{rhs}->[$ix]; |
|
92
|
126
|
50
|
|
|
|
230
|
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
|
|
|
|
|
22
|
require Data::Dumper; |
|
101
|
2
|
|
|
|
|
10
|
require Marpa::R2::HTML::Config::Default; |
|
102
|
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
5
|
local $Data::Dumper::Purity = 1; |
|
104
|
2
|
|
|
|
|
6
|
local $Data::Dumper::Sortkeys = 1; |
|
105
|
2
|
|
|
|
|
9
|
my @contents = $self->contents(); |
|
106
|
2
|
|
|
|
|
6
|
my @rules = sort sort_bnf @{$contents[0]}; |
|
|
2
|
|
|
|
|
21
|
|
|
107
|
2
|
|
|
|
|
8
|
$contents[0] = \@rules; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Start with the legal language |
|
110
|
|
|
|
|
|
|
return \( |
|
111
|
2
|
|
|
|
|
163
|
$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: |