| 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 | 23 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 23 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 23 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 23 | ▶ | use vars qw($VERSION $STRING_VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 23 | $VERSION = '13.003_000'; | |||||||||
| 24 | 23 | $STRING_VERSION = $VERSION; | |||||||||
| 25 | ## no critic(BuiltinFunctions::ProhibitStringyEval) | ||||||||||
| 26 | 23 | $VERSION = eval $VERSION; | |||||||||
| 27 | ## use critic | ||||||||||
| 28 | |||||||||||
| 29 | 23 | ▶ | use English qw( -no_match_vars ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | # Generate the default configuration | ||||||||||
| 32 | sub new { | ||||||||||
| 33 | 98 | ▶ | my ($class) = @_; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 98 | require Marpa::R2::HTML::Config::Default; | |||||||||
| 35 | 98 | 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 | 98 | return bless $self, $class; | |||||||||
| 47 | } ## end sub new | ||||||||||
| 48 | |||||||||||
| 49 | sub new_from_compile { | ||||||||||
| 50 | 11 | ▶ | my ( $class, $source_ref ) = @_; | ||||||||
|
Subroutine
new_from_compile: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 51 | 11 | require Marpa::R2::HTML::Config::Compile; | |||||||||
| 52 | 11 | return bless Marpa::R2::HTML::Config::Compile::compile($source_ref), $class; | |||||||||
| 53 | } ## end sub new_from_compile | ||||||||||
| 54 | |||||||||||
| 55 | sub contents { | ||||||||||
| 56 | 111 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
contents: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 57 | 111 | return @{$self}{ | |||||||||
| 58 | 111 | 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 | 23 | 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 | 909 | ▶ | my $cmp = $a->{lhs} cmp $b->{lhs}; | ||||||||
|
Subroutine
sort_bnf: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||
| 85 | 909 | ▶ | return $cmp if $cmp; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | 125 | my $a_rhs_length = scalar @{ $a->{rhs} }; | |||||||||
| 87 | 125 | my $b_rhs_length = scalar @{ $b->{rhs} }; | |||||||||
| 88 | 125 | $cmp = $a_rhs_length <=> $b_rhs_length; | |||||||||
| 89 | 125 | ▶ | return $cmp if $cmp; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 125 | for my $ix ( 0 .. $a_rhs_length ) { | |||||||||
| 91 | 125 | $cmp = $a->{rhs}->[$ix] cmp $b->{rhs}->[$ix]; | |||||||||
| 92 | 125 | ▶ | return $cmp if $cmp; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | } | ||||||||||
| 94 | 0 | return 0; | |||||||||
| 95 | } ## end sub sort_bnf | ||||||||||
| 96 | |||||||||||
| 97 | sub as_string { | ||||||||||
| 98 | 2 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 99 | |||||||||||
| 100 | 2 | require Data::Dumper; | |||||||||
| 101 | 2 | require Marpa::R2::HTML::Config::Default; | |||||||||
| 102 | |||||||||||
| 103 | 2 | local $Data::Dumper::Purity = 1; | |||||||||
| 104 | 2 | local $Data::Dumper::Sortkeys = 1; | |||||||||
| 105 | 2 | my @contents = $self->contents(); | |||||||||
| 106 | 2 | my @rules = sort sort_bnf @{$contents[0]}; | |||||||||
| 107 | 2 | $contents[0] = \@rules; | |||||||||
| 108 | |||||||||||
| 109 | # Start with the legal language | ||||||||||
| 110 | return \( | ||||||||||
| 111 | 2 | $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 | 23 | 1; | |||||||||
| 130 | |||||||||||
| 131 | # vim: set expandtab shiftwidth=4: | ||||||||||