| 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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | our @EXPORT_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 23 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 23 | ▶ | BEGIN { @EXPORT_OK = qw(html); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | package Marpa::R2::HTML::Internal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Data::Dumper is used in tracing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 23 | ▶ | use Marpa::R2::HTML::Internal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 23 | ▶ | use Marpa::R2::HTML::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 23 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | ▶ | use HTML::Parser 3.69; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 23 | ▶ | use HTML::Entities qw(decode_entities); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # versions below must be coordinated with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # those required in Build.PL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 23 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 23 | ▶ | use Marpa::R2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 23 | my $submodule_version = $Marpa::R2::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 23 | ▶ | die 'Marpa::R2::VERSION not defined' if not defined $submodule_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 23 | ▶ | die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | "Marpa::R2::VERSION ($submodule_version) does not match Marpa::R2::HTML::VERSION ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $Marpa::R2::HTML::VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | if $submodule_version != $Marpa::R2::HTML::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 23 | ▶ | use Marpa::R2::Thin::Trace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 23 | ▶ | use constant PHYSICAL_TOKEN => 42; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | ▶ | use constant RUBY_SLIPPERS_TOKEN => 43; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 23 | our @LIBMARPA_ERROR_NAMES = Marpa::R2::Thin::error_names(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 23 | our $UNEXPECTED_TOKEN_ID; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 23 | our $NO_MARPA_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 23 | ERROR: for my $error_number ( 0 .. $#LIBMARPA_ERROR_NAMES ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2300 | my $error_name = $LIBMARPA_ERROR_NAMES[$error_number]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2300 | ▶ | if ( $error_name eq 'MARPA_ERR_UNEXPECTED_TOKEN_ID' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 23 | $UNEXPECTED_TOKEN_ID = $error_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 23 | next ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2277 | ▶ | if ( $error_name eq 'MARPA_ERR_NONE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 23 | $NO_MARPA_ERROR = $error_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 23 | next ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } ## end ERROR: for my $error_number ( 0 .. $#LIBMARPA_ERROR_NAMES ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | ▶ | use Marpa::R2::HTML::Callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 23 | my $submodule_version = $Marpa::R2::HTML::Callback::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 23 | ▶ | die 'Marpa::R2::HTML::Callback::VERSION not defined' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | if not defined $submodule_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 23 | ▶ | die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | "Marpa::R2::HTML::Callback::VERSION ($submodule_version) does not match Marpa::R2::HTML::VERSION ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | $Marpa::R2::HTML::VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | if $submodule_version != $Marpa::R2::HTML::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub earleme_to_linecol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my ( $self, $earleme ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
earleme_to_linecol: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $html_parser_tokens = $self->{tokens}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $html_token_ix = $self->{earleme_to_html_token_ix}->[$earleme] + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | die if not defined $html_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return @{ $html_parser_tokens->[$html_token_ix] }[ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Marpa::R2::HTML::Internal::Token::LINE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Marpa::R2::HTML::Internal::Token::COLUMN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } ## end sub earleme_to_linecol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub earleme_to_offset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my ( $self, $earleme ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
earleme_to_offset: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $html_parser_tokens = $self->{tokens}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $html_token_ix = $self->{earleme_to_html_token_ix}->[$earleme] + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | die if not defined $html_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $html_parser_tokens->[$html_token_ix] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ->[Marpa::R2::HTML::Internal::Token::END_OFFSET]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } ## end sub earleme_to_offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub add_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 501 | ▶ | my ( $self, $handler_description ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_handler: called CC=8 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 501 | ▶ | my $ref_type = ref $handler_description || 'not a reference'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $handler_description || 'not a reference'
MC/DC0%0/1
ref $handler_description || 'not a reference'
ref $handler_description
Truth table50%1/2
A
A= ref $handler_description
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 501 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | "Long form handler description should be ref to hash, but it is $ref_type" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ) if $ref_type ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 501 | my $element = delete $handler_description->{element}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 501 | my $class = delete $handler_description->{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 501 | my $pseudoclass = delete $handler_description->{pseudoclass}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 501 | my $action = delete $handler_description->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'Unknown option(s) in Long form handler description: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ( join q{ }, keys %{$handler_description} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 501 | ▶ | ) if scalar keys %{$handler_description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 501 | ▶ | Marpa::R2::exception('Handler action must be CODE ref') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | if ref $action ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 501 | ▶ | if ( defined $pseudoclass ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 362 | $self->{handler_by_species}->{$pseudoclass} = $action; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 362 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 139 | ▶ | $element = q{*} if not $element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 139 | $element = lc $element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 139 | ▶ | $class //= q{*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$class //= "*"
MC/DC100%1/1
$class //= "*"
$class
Truth table100%2/2
A
A= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 139 | $self->{handler_by_element_and_class}->{ join q{;}, $element, $class } = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | $action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 139 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } ## end sub add_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub add_handlers_from_hashes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my ( $self, $handler_specs ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_handlers_from_hashes: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my $ref_type = ref $handler_specs || 'not a reference'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $handler_specs || 'not a reference'
MC/DC0%0/1
ref $handler_specs || 'not a reference'
ref $handler_specs
Truth table0%0/2
A
A= ref $handler_specs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | "handlers arg must must be ref to ARRAY, it is $ref_type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | if $ref_type ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | for my $handler_spec ( keys %{$handler_specs} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | add_handler( $self, $handler_spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } ## end sub add_handlers_from_hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | sub add_handlers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 106 | ▶ | my ( $self, $handler_specs ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_handlers: called CC=8 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 106 | HANDLER_SPEC: for my $specifier ( keys %{$handler_specs} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 501 | my ( $element, $class, $pseudoclass ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 501 | my $action = $handler_specs->{$specifier}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 501 | ▶ | ( $element, $class ) = ( $specifier =~ /\A ([^.]*) [.] (.*) \z/oxms ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
() = $specifier =~ /\A ([^.]*) [.] (.*) \z/mosx or ($element, $pseudoclass) = $specifier =~ /\A ([^:]*) [:] (.*) \z/mosx
MC/DC100%2/2
() = $specifier =~ /\A ([^.]*) [.] (.*) \z/mosx or ($element, $pseudoclass) = $specifier =~ /\A ([^:]*) [:] (.*) \z/mosx
() = $specifier =~ /\A ([^.]*) [.] (.*) \z/mosx
($element, $pseudoclass) = $specifier =~ /\A ([^:]*) [:] (.*) \z/mosx
Truth table100%3/3
A or B
A= () = $specifier =~ /\A ([^.]*) [.] (.*) \z/mosxB= ($element, $pseudoclass) = $specifier =~ /\A ([^:]*) [:] (.*) \z/mosx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | or ( $element, $pseudoclass ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ( $specifier =~ /\A ([^:]*) [:] (.*) \z/oxms ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | or $element = $specifier; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | state $allowed_pseudoclasses = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 501 | { map { ( $_, 1 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | qw(TOP PI DECL COMMENT PROLOG TRAILER WHITESPACE CDATA PCDATA CRUFT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 501 | ▶ | if ( $pseudoclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pseudoclass and not exists $allowed_pseudoclasses->{$pseudoclass}
MC/DC0%0/2
$pseudoclass and not exists $allowed_pseudoclasses->{$pseudoclass}
$pseudoclass
not exists $allowed_pseudoclasses->{$pseudoclass}
Truth table66%2/3
A and not(B)
A= $pseudoclassB= not exists $allowed_pseudoclasses->{$pseudoclass}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | and not exists $allowed_pseudoclasses->{$pseudoclass} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | qq{pseudoclass "$pseudoclass" is not known:\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | "Specifier was $specifier\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } ## end if ( $pseudoclass and not exists $allowed_pseudoclasses...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 501 | ▶ | if ( $pseudoclass and $element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pseudoclass and $element
MC/DC0%0/2
$pseudoclass and $element
$pseudoclass
$element
Truth table66%2/3
A and B
A= $pseudoclassB= $element
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | qq{pseudoclass "$pseudoclass" may not have an element specified:\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | "Specifier was $specifier\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } ## end if ( $pseudoclass and $element ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | add_handler( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 501 | $self, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { element => $element, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | pseudoclass => $pseudoclass, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | action => $action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } ## end HANDLER_SPEC: for my $specifier ( keys %{$handler_specs} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 106 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } ## end sub add_handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # If we factor this package, this will be the constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 109 | ▶ | my $self = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=12 SCAR=25.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 109 | $self->{trace_fh} = \*STDERR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 109 | ARG: for my $arg (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 123 | ▶ | my $ref_type = ref $arg || 'not a reference'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $arg || 'not a reference'
MC/DC0%0/1
ref $arg || 'not a reference'
ref $arg
Truth table50%1/2
A
A= ref $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 123 | ▶ | if ( $ref_type eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 106 | Marpa::R2::HTML::Internal::add_handlers( $self, $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 106 | next ARG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 17 | ▶ | "Argument must be hash or refs to hash: it is $ref_type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | if $ref_type ne 'REF'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 17 | my $option_hash = ${$arg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 17 | ▶ | $ref_type = ref $option_hash || 'not a reference'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $option_hash || 'not a reference'
MC/DC0%0/1
ref $option_hash || 'not a reference'
ref $option_hash
Truth table50%1/2
A
A= ref $option_hash
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 17 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | "Argument must be hash or refs to hash: it is ref to $ref_type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | if $ref_type ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 17 | OPTION: for my $option ( keys %{$option_hash} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 88 | ▶ | if ( $option eq 'handlers' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | add_handlers_from_hashes( $self, $option_hash->{$option} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | state $allowed_options = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 88 | map { ( $_, 1 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | qw(trace_fh trace_values trace_handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | trace_conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | trace_terminals trace_cruft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | dump_AHFA dump_config compile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 88 | ▶ | if ( not exists $allowed_options->{$option} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | Marpa::R2::exception("unknown option: $option"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 88 | $self->{$option} = $option_hash->{$option}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } ## end OPTION: for my $option ( keys %{$option_hash} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } ## end ARG: for my $arg (@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 109 | my $source_ref = $self->{compile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 109 | ▶ | if ( defined $source_ref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 11 | ▶ | ref $source_ref eq 'SCALAR' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | or Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | qq{value of "compile" option must be a SCALAR}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 11 | $self->{config} = Marpa::R2::HTML::Config->new_from_compile($source_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } ## end if ( defined $source_ref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 98 | $self->{config} = Marpa::R2::HTML::Config->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 109 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } ## end sub create | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub handler_find { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1636 | ▶ | my ( $self, $rule_id, $class ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_find: called CC=14 SCAR=34.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1636 | my $trace_handlers = $self->{trace_handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1636 | my $handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1636 | ▶ | $class //= q{*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$class //= "*"
MC/DC0%0/1
$class //= "*"
$class
Truth table50%1/2
A
A= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1636 | my $action = $self->{action_by_rule_id}->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | FIND_HANDLER: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1636 | ▶ | last FIND_HANDLER if not defined $action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 809 | ▶ | if ( index( $action, 'SPE_' ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 222 | my $species = substr $action, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 222 | $handler = $self->{handler_by_species}->{$species}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 222 | ▶ | say {*STDERR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
$trace_handlers && defined $handler && (say({*STDERR;} qq[Rule ${rule_id}: Found handler by species: "$species"]) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_handlers and defined $handler
say {*STDERR;} qq[Rule ${rule_id}: Found handler by species: "$species"] or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/4
$trace_handlers && defined $handler && (say({*STDERR;} qq[Rule ${rule_id}: Found handler by species: "$species"]) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_handlers
defined $handler
say {*STDERR;} qq[Rule ${rule_id}: Found handler by species: "$species"]
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table20%1/5
A and B && C or D
A= $trace_handlersB= defined $handlerC= say {*STDERR;} qq[Rule ${rule_id}: Found handler by species: "$species"]D= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | qq{Rule $rule_id: Found handler by species: "$species"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | if $trace_handlers and defined $handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 222 | last FIND_HANDLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } ## end if ( index( $action, 'SPE_' ) == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ## At this point action always is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ## and starts with 'ELE_' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 587 | my $element = substr $action, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 587 | my @handler_keys = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ( join q{;}, $element, $class ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ( join q{;}, q{*}, $class ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ( join q{;}, $element, q{*} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ( join q{;}, q{*}, q{*} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ($handler) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 2348 | grep {defined} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 587 | @{ $self->{handler_by_element_and_class} }{@handler_keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | say {*STDERR} qq{Rule $rule_id: Found handler by action and class: "}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 587 | ▶ | ( grep { defined $self->{handler_by_element_and_class}->{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
$trace_handlers && defined $handler && (say({*STDERR;} qq[Rule ${rule_id}: Found handler by action and class: "], (grep {defined $self->{'handler_by_element_and_class'}{$_};} @handler_keys)[0], '"') || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_handlers and defined $handler
say {*STDERR;} qq[Rule ${rule_id}: Found handler by action and class: "], (grep {defined $self->{"handler_by_element_and_class"}{$_};} @handler_keys)[0], "\"" or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/4
$trace_handlers && defined $handler && (say({*STDERR;} qq[Rule ${rule_id}: Found handler by action and class: "], (grep {defined $self->{'handler_by_element_and_class'}{$_};} @handler_keys)[0], '"') || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_handlers
defined $handler
say {*STDERR;} qq[Rule ${rule_id}: Found handler by action and class: "], (grep {defined $self->{"handler_by_element_and_class"}{$_};} @handler_keys)[0], "\""
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table20%1/5
A and B && C or D
A= $trace_handlersB= defined $handlerC= say {*STDERR;} qq[Rule ${rule_id}: Found handler by action and class: "], (grep {defined $self->{"handler_by_element_and_class"}{$_};} @handler_keys)[0], "\""D= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | @handler_keys )[0], q{"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | if $trace_handlers and defined $handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } ## end FIND_HANDLER: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1636 | ▶ | return $handler if defined $handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1035 | ▶ | say {*STDERR} qq{Rule $rule_id: Using default handler for action "}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition12%1/8
$trace_handlers && (say({*STDERR;} qq[Rule ${rule_id}: Using default handler for action "], $action // '*', qq[" and class: "$class"]) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
say {*STDERR;} qq[Rule ${rule_id}: Using default handler for action "], $action // "*", qq[" and class: "$class"] or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
$action // "*"
MC/DC0%0/3
$trace_handlers && (say({*STDERR;} qq[Rule ${rule_id}: Using default handler for action "], $action // '*', qq[" and class: "$class"]) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_handlers
say {*STDERR;} qq[Rule ${rule_id}: Using default handler for action "], $action // "*", qq[" and class: "$class"]
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/1
$action // "*"
$action
Truth table0%0/4
A && B or C
A= $trace_handlersB= say {*STDERR;} qq[Rule ${rule_id}: Using default handler for action "], $action // "*", qq[" and class: "$class"]C= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table0%0/2
A
A= $action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ( $action // q{*} ), qq{" and class: "$class"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | if $trace_handlers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1035 | return 'default_handler'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } ## end sub handler_find | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # "Original" value of a token range -- that is, the corresponding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # text of the original document, unchanged. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # Returned as a reference, because it may be very long | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | sub token_range_to_original { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1329 | ▶ | my ( $self, $first_token_ix, $last_token_ix ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
token_range_to_original: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1329 | ▶ | return \q{} if not defined $first_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1317 | my $document = $self->{document}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1317 | my $tokens = $self->{tokens}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1317 | my $start_offset = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $tokens->[$first_token_ix] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ->[Marpa::R2::HTML::Internal::Token::START_OFFSET]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1317 | my $end_offset = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | $tokens->[$last_token_ix] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ->[Marpa::R2::HTML::Internal::Token::END_OFFSET]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1317 | my $original = substr ${$document}, $start_offset, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ( $end_offset - $start_offset ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1317 | return \$original; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } ## end sub token_range_to_original | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # "Original" value of token -- that is, the corresponding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # text of the original document, unchanged. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # The empty string if there is no such text. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # Returned as a reference, because it may be very long | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | sub tdesc_item_to_original { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my ( $self, $tdesc_item ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tdesc_item_to_original: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $document = $self->{document}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $tokens = $self->{tokens}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $tdesc_item_type = $tdesc_item->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | return q{} if not defined $tdesc_item_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( $tdesc_item_type eq 'PHYSICAL_TOKEN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return token_range_to_original( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::START_TOKEN], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::END_TOKEN], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } ## end if ( $tdesc_item_type eq 'PHYSICAL_TOKEN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if ( $tdesc_item_type eq 'VALUED_SPAN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | return token_range_to_original( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::START_TOKEN], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::END_TOKEN], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } ## end if ( $tdesc_item_type eq 'VALUED_SPAN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } ## end sub tdesc_item_to_original | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Given a token range and a tdesc list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # return a reference to the literal value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | sub range_and_values_to_literal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 218 | ▶ | my ( $self, $next_token_ix, $final_token_ix, $tdesc_list ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_and_values_to_literal: called CC=14 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 218 | my @flat_tdesc_list = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 218 | TDESC_ITEM: for my $tdesc_item ( @{$tdesc_list} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 705 | my $type = $tdesc_item->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 705 | ▶ | next TDESC_ITEM if not defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 705 | ▶ | next TDESC_ITEM if $type eq 'ZERO_SPAN'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 705 | ▶ | next TDESC_ITEM if $type eq 'RUBY_SLIPPERS_TOKEN'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 705 | ▶ | if ( $type eq 'VALUES' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | push @flat_tdesc_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | @{ $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::VALUE] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | next TDESC_ITEM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 701 | push @flat_tdesc_list, $tdesc_item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } ## end TDESC_ITEM: for my $tdesc_item ( @{$tdesc_list} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 218 | my @literal_pieces = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 218 | TDESC_ITEM: for my $tdesc_item (@flat_tdesc_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | my ( $tdesc_item_type, $next_explicit_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $furthest_explicit_token_ix ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 711 | = @{$tdesc_item}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 711 | ▶ | if ( not defined $next_explicit_token_ix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ## An element can contain no HTML tokens -- it may contain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ## only Ruby Slippers tokens. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ## Treat this as a special case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 10 | ▶ | if ( $tdesc_item_type eq 'VALUED_SPAN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | ▶ | my $value = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$tdesc_item->[3] // ""
MC/DC100%1/1
$tdesc_item->[3] // ""
$tdesc_item->[3]
Truth table100%2/2
A
A= $tdesc_item->[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::VALUE] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | // q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 10 | push @literal_pieces, \( q{} . $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } ## end if ( $tdesc_item_type eq 'VALUED_SPAN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 10 | next TDESC_ITEM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } ## end if ( not defined $next_explicit_token_ix ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 701 | ▶ | push @literal_pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | token_range_to_original( $self, $next_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $next_explicit_token_ix - 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | if $next_token_ix < $next_explicit_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 701 | ▶ | if ( $tdesc_item_type eq 'VALUED_SPAN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 588 | my $value = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $tdesc_item->[Marpa::R2::HTML::Internal::TDesc::VALUE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 588 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 98 | push @literal_pieces, \( q{} . $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 98 | $next_token_ix = $furthest_explicit_token_ix + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 98 | next TDESC_ITEM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | ## FALL THROUGH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } ## end if ( $tdesc_item_type eq 'VALUED_SPAN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 603 | ▶ | push @literal_pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | token_range_to_original( $self, $next_explicit_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | $furthest_explicit_token_ix ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | if $next_explicit_token_ix <= $furthest_explicit_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 603 | $next_token_ix = $furthest_explicit_token_ix + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } ## end TDESC_ITEM: for my $tdesc_item (@flat_tdesc_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 218 | return \( join q{}, map { ${$_} } @literal_pieces ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } ## end sub range_and_values_to_literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | sub symbol_names_by_rule_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | my ( $self, $rule_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symbol_names_by_rule_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $tracer = $self->{tracer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $grammar = $tracer->grammar(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $rule_length = $grammar->rule_length($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | return if not defined $rule_length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my @symbol_ids = ( $grammar->rule_lhs($rule_id) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | push @symbol_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | map { $grammar->rule_rhs( $rule_id, $_ ) } ( 0 .. $rule_length - 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return map { $tracer->symbol_name($_) } @symbol_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } ## end sub symbol_names_by_rule_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 109 | ▶ | my ( $self, $document_ref ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=133 SCAR=59.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 109 | my %tags = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | "parse() already run on this object\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 'For a new parse, create a new object' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 109 | ▶ | ) if $self->{document}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 109 | my $trace_cruft = $self->{trace_cruft}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 109 | ▶ | my $trace_terminals = $self->{trace_terminals} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"trace_terminals"} // 0
MC/DC100%1/1
$self->{"trace_terminals"} // 0
$self->{"trace_terminals"}
Truth table100%2/2
A
A= $self->{"trace_terminals"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 109 | my $trace_conflicts = $self->{trace_conflicts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 109 | my $trace_handlers = $self->{trace_handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 109 | my $trace_values = $self->{trace_values}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 109 | my $trace_fh = $self->{trace_fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 109 | my $ref_type = ref $document_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | Marpa::R2::exception('Arg to parse() must be ref to string') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | if not $ref_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | or $ref_type ne 'SCALAR' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 109 | ▶ | or not defined ${$document_ref}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $ref_type or $ref_type ne "SCALAR" or not defined ${$document_ref;}
not $ref_type or $ref_type ne "SCALAR"
MC/DC0%0/3
not $ref_type or $ref_type ne "SCALAR" or not defined ${$document_ref;}
not $ref_type
$ref_type ne "SCALAR"
not defined ${$document_ref;}
Truth table25%1/4
not(A) or B or not(C)
A= not $ref_typeB= $ref_type ne "SCALAR"C= not defined ${$document_ref;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 109 | my $document = $self->{document} = $document_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | my ($core_rules, $runtime_tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $rank_by_name, $is_empty_element, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | $primary_group_by_tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 109 | ) = $self->{config}->contents(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 109 | $self->{is_empty_element} = $is_empty_element; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 109 | ▶ | if ($self->{dump_config}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | return $self->{config}->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 107 | my @action_by_rule_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 107 | $self->{action_by_rule_id} = \@action_by_rule_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 107 | my $thin_grammar = Marpa::R2::Thin::G->new( { if => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 107 | my $tracer = Marpa::R2::Thin::Trace->new($thin_grammar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 107 | $self->{tracer} = $tracer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 107 | RULE: for my $rule ( @{$core_rules} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 14873 | my $lhs = $rule->{lhs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 14873 | my $rhs = $rule->{rhs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 14873 | my $min = $rule->{min}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 14873 | my $action = $rule->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 14873 | my @symbol_ids = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 14873 | for my $symbol_name ( $lhs, @{$rhs} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 36808 | ▶ | push @symbol_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$tracer->symbol_by_name($symbol_name) // $tracer->symbol_new($symbol_name)
MC/DC100%2/2
$tracer->symbol_by_name($symbol_name) // $tracer->symbol_new($symbol_name)
$tracer->symbol_by_name($symbol_name)
$tracer->symbol_new($symbol_name)
Truth table100%3/3
A // B
A= $tracer->symbol_by_name($symbol_name)B= $tracer->symbol_new($symbol_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | $tracer->symbol_by_name($symbol_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | // $tracer->symbol_new($symbol_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 14873 | my ($lhs_id, @rhs_ids) = @symbol_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 14873 | my $rule_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 14873 | ▶ | if ( defined $min ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 2461 | $rule_id = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | $thin_grammar->sequence_new( $lhs_id, $rhs_ids[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | { min => $min } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 12412 | $rule_id = $thin_grammar->rule_new( $lhs_id, \@rhs_ids ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 14873 | $action_by_rule_id[$rule_id] = $action; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } ## end RULE: for my $rule ( @{$core_rules} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # Some constants that we will use a lot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 107 | my $SYMID_CRUFT = $tracer->symbol_by_name('CRUFT'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 107 | my $SYMID_CDATA = $tracer->symbol_by_name('CDATA'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 107 | my $SYMID_PCDATA = $tracer->symbol_by_name('PCDATA'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 107 | my $SYMID_WHITESPACE = $tracer->symbol_by_name('WHITESPACE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 107 | my $SYMID_PI = $tracer->symbol_by_name('PI'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 107 | my $SYMID_C = $tracer->symbol_by_name('C'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 107 | my $SYMID_D = $tracer->symbol_by_name('D'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 107 | my $SYMID_EOF = $tracer->symbol_by_name('EOF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 107 | my @raw_tokens = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 107 | my $p = HTML::Parser->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | api_version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | start_h => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | \@raw_tokens, q{tagname,'S',line,column,offset,offset_end,is_cdata,attr} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | end_h => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | [ \@raw_tokens, q{tagname,'E',line,column,offset,offset_end,is_cdata} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | text_h => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | \@raw_tokens, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | qq{'$SYMID_WHITESPACE','T',line,column,offset,offset_end,is_cdata} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | comment_h => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | [ \@raw_tokens, qq{'$SYMID_C','C',line,column,offset,offset_end,is_cdata} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | declaration_h => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | [ \@raw_tokens, qq{'$SYMID_D','D',line,column,offset,offset_end,is_cdata} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | process_h => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | [ \@raw_tokens, qq{'$SYMID_PI','PI',line,column,offset,offset_end,is_cdata} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | unbroken_text => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 107 | $p->parse( ${$document} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 107 | $p->eof; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 107 | my @html_parser_tokens = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | HTML_PARSER_TOKEN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 107 | for my $raw_token (@raw_tokens) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | my ( undef, $token_type, $line, $column, $offset, $offset_end, $is_cdata, $attr ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 1547 | @{$raw_token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | PROCESS_TOKEN_TYPE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1547 | ▶ | if ($is_cdata) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $raw_token->[Marpa::R2::HTML::Internal::Token::TOKEN_ID] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $SYMID_CDATA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | last PROCESS_TOKEN_TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1547 | ▶ | if ( $token_type eq 'T' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # White space as defined in HTML 4.01 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # space (x20); ASCII tab (x09); ASCII form feed (x0C;); Zero-width space (x200B) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # and the two characters which appear in line breaks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # carriage return (x0D) and line feed (x0A) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # I avoid the Perl character codes because I do NOT want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # localization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | $raw_token->[Marpa::R2::HTML::Internal::Token::TOKEN_ID] = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | $SYMID_PCDATA if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | substr( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 719 | ▶ | ${$document}, $offset, ( $offset_end - $offset ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ) =~ / [^\x09\x0A\x0C\x0D\x20\x{200B}] /oxms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 719 | last PROCESS_TOKEN_TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } ## end if ( $token_type eq 'T' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 828 | ▶ | if ( $token_type eq 'E' or $token_type eq 'S' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token_type eq "E" or $token_type eq "S"
MC/DC100%2/2
$token_type eq "E" or $token_type eq "S"
$token_type eq "E"
$token_type eq "S"
Truth table100%3/3
A or B
A= $token_type eq "E"B= $token_type eq "S"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # If it's a virtual token from HTML::Parser, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # pretend it never existed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # HTML::Parser supplies missing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # end tags for title elements, but for no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # others. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # This is not helpful and we need to special-case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # these zero-length tags and throw them away. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 818 | ▶ | next HTML_PARSER_TOKEN if $offset_end <= $offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 814 | my $tag_name = $raw_token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ->[Marpa::R2::HTML::Internal::Token::TAG_NAME]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 814 | my $terminal = $token_type . q{_} . $tag_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 814 | my $terminal_id = $tracer->symbol_by_name($terminal); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 814 | ▶ | if ( not defined $terminal_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 45 | ▶ | my $group_symbol = $primary_group_by_tag->{$tag_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$primary_group_by_tag->{$tag_name} // "GRP_anywhere"
MC/DC0%0/1
$primary_group_by_tag->{$tag_name} // "GRP_anywhere"
$primary_group_by_tag->{$tag_name}
Truth table50%1/2
A
A= $primary_group_by_tag->{$tag_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | // 'GRP_anywhere'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 45 | ▶ | my $contents = $runtime_tag->{$tag_name} // 'FLO_mixed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$runtime_tag->{$tag_name} // "FLO_mixed"
MC/DC0%0/1
$runtime_tag->{$tag_name} // "FLO_mixed"
$runtime_tag->{$tag_name}
Truth table50%1/2
A
A= $runtime_tag->{$tag_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 45 | my @symbol_names = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | $group_symbol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 'ELE_' . $tag_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 'S_' . $tag_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | $contents, 'E_' . $tag_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 45 | my @symbol_ids = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 45 | SYMBOL: for my $symbol_name (@symbol_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 225 | my $symbol_id = $tracer->symbol_by_name($symbol_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 225 | ▶ | if ( not defined $symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 135 | $symbol_id = $tracer->symbol_new($symbol_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 225 | push @symbol_ids, $symbol_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } ## end SYMBOL: for my $symbol_name (@symbol_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 45 | my ( $top_id, $lhs_id, @rhs_ids ) = @symbol_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 45 | $thin_grammar->rule_new( $top_id, [$lhs_id] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 45 | my $element_rule_id = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | $thin_grammar->rule_new( $lhs_id, \@rhs_ids ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 45 | $action_by_rule_id[$element_rule_id] = 'ELE_' . $tag_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 45 | $terminal_id = $tracer->symbol_by_name($terminal); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } ## end if ( not defined $terminal_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 814 | $raw_token->[Marpa::R2::HTML::Internal::Token::TOKEN_ID] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | $terminal_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 814 | last PROCESS_TOKEN_TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } ## end if ( $token_type eq 'E' or $token_type eq 'S' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } ## end PROCESS_TOKEN_TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 1543 | push @html_parser_tokens, $raw_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } ## end HTML_PARSER_TOKEN: for my $raw_token (@raw_tokens) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # Points AFTER the last HTML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | # Parser token. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # The other logic needs to be ready for this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 107 | my $document_length = length ${$document}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 107 | my $last_token = $html_parser_tokens[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | push @html_parser_tokens, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | $SYMID_EOF, 'EOF', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 107 | @{$last_token}[ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | Marpa::R2::HTML::Internal::Token::LINE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | Marpa::R2::HTML::Internal::Token::COLUMN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | $document_length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | $document_length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # conserve memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 107 | $p = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 107 | @raw_tokens = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 107 | $thin_grammar->start_symbol_set( $tracer->symbol_by_name('document') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 107 | $thin_grammar->precompute(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 107 | ▶ | if ($self->{dump_AHFA}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | return \$tracer->show_AHFA(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # Memoize these -- we use highest symbol a lot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 107 | my $highest_symbol_id = $thin_grammar->highest_symbol_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 107 | my $highest_rule_id = $thin_grammar->highest_rule_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # For the Ruby Slippers engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # We need to know quickly if a symbol is a start tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 107 | my @is_start_tag = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # Find Ruby slippers ranks, by symbol ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 107 | my @ruby_rank_by_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 107 | my @non_final_end_tag_ids = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | SYMBOL: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 107 | for my $symbol_id ( 0 .. $highest_symbol_id ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 16934 | my $symbol_name = $tracer->symbol_name($symbol_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 16934 | ▶ | next SYMBOL if not 0 == index $symbol_name, 'E_'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | next SYMBOL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 3255 | ▶ | if $symbol_name eq 'E_body' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$symbol_name eq "E_body" or $symbol_name eq "E_html"
MC/DC100%2/2
$symbol_name eq "E_body" or $symbol_name eq "E_html"
$symbol_name eq "E_body"
$symbol_name eq "E_html"
Truth table100%3/3
A or B
A= $symbol_name eq "E_body"B= $symbol_name eq "E_html"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | or $symbol_name eq 'E_html'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 3041 | push @non_final_end_tag_ids, $symbol_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } ## end SYMBOL: for my $symbol_id ( 0 .. $highest_symbol_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 107 | my %ruby_vectors = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 107 | for my $rejected_symbol_name ( keys %{$rank_by_name} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 3209 | my @ruby_vector_by_id = ( (0) x ( $highest_symbol_id + 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | my $rank_by_candidate_name = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 3209 | $rank_by_name->{$rejected_symbol_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | CANDIDATE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 3209 | for my $candidate_name ( keys %{$rank_by_candidate_name} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 16366 | my $rank = $rank_by_candidate_name->{$candidate_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 16366 | ▶ | if ( $candidate_name eq '</*>' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 3209 | $ruby_vector_by_id[$_] = $rank for @non_final_end_tag_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 3209 | next CANDIDATE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 13157 | my $candidate_id = $tracer->symbol_by_name($candidate_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 13157 | ▶ | die "Unknown ruby slippers candidate name: $candidate_name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | if not defined $candidate_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | $ruby_vector_by_id[$candidate_id] = $rank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 13157 | for @non_final_end_tag_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } ## end CANDIDATE: for my $candidate_name ( keys %{...}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 3209 | $ruby_vectors{$rejected_symbol_name} = \@ruby_vector_by_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } ## end for my $rejected_symbol_name ( keys %{$rank_by_name} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 107 | my @no_ruby_slippers_vector = ( (0) x ( $highest_symbol_id + 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 107 | SYMBOL: for my $rejected_symbol_id ( 0 .. $highest_symbol_id ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 16934 | ▶ | if ( not $thin_grammar->symbol_is_terminal($rejected_symbol_id) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 9568 | $ruby_rank_by_id[$rejected_symbol_id] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | \@no_ruby_slippers_vector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 9568 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } ## end if ( not $thin_grammar->symbol_is_terminal(...)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 7366 | my $rejected_symbol_name = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | $tracer->symbol_name($rejected_symbol_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 7366 | my $placement; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | FIND_PLACEMENT: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 7366 | my $prefix = substr $rejected_symbol_name, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 7366 | ▶ | if ( $prefix eq 'S_' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 3255 | $placement = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3255 | $is_start_tag[$rejected_symbol_id] = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 3255 | last FIND_PLACEMENT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 4111 | ▶ | if ( $prefix eq 'E_' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 3255 | $placement = '/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } ## end FIND_PLACEMENT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 7366 | my $ruby_vector = $ruby_vectors{$rejected_symbol_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 7366 | ▶ | if ( defined $ruby_vector ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2674 | $ruby_rank_by_id[$rejected_symbol_id] = $ruby_vector; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 2674 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 4692 | ▶ | if ( not defined $placement ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 535 | ▶ | if ( $rejected_symbol_name eq 'CRUFT' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 107 | $ruby_rank_by_id[$rejected_symbol_id] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | \@no_ruby_slippers_vector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 107 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | $ruby_rank_by_id[$rejected_symbol_id] = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 428 | ▶ | $ruby_vectors{'!non_element'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ruby_vectors{"!non_element"} // \@no_ruby_slippers_vector
MC/DC0%0/1
$ruby_vectors{"!non_element"} // \@no_ruby_slippers_vector
$ruby_vectors{"!non_element"}
Truth table50%1/2
A
A= $ruby_vectors{"!non_element"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | // \@no_ruby_slippers_vector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 428 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } ## end if ( not defined $placement ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 4157 | my $tag = substr $rejected_symbol_name, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 4157 | my $primary_group = $primary_group_by_tag->{$tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 4157 | ▶ | my $element_type = defined $primary_group ? (substr $primary_group, 4) : 'anywhere'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | $ruby_vector = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 4157 | $ruby_vectors{ q{<} . $placement . q{%} . $element_type . q{>} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 4157 | ▶ | if ( defined $ruby_vector ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 352 | $ruby_rank_by_id[$rejected_symbol_id] = $ruby_vector; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 352 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 3805 | $ruby_vector = $ruby_vectors{ q{<} . $placement . q{*>} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 3805 | ▶ | if ( defined $ruby_vector ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 3805 | $ruby_rank_by_id[$rejected_symbol_id] = $ruby_vector; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 3805 | next SYMBOL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $ruby_rank_by_id[$rejected_symbol_id] = \@no_ruby_slippers_vector; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } ## end SYMBOL: for my $rejected_symbol_id ( 0 .. $highest_symbol_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 107 | my @empty_element_end_tag = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 107 | TAG: for my $tag (keys %{$is_empty_element}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1286 | my $start_tag_id = $tracer->symbol_by_name('S_' . $tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 1286 | ▶ | next TAG if not defined $start_tag_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 332 | my $end_tag_id = $tracer->symbol_by_name('E_' . $tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 332 | $empty_element_end_tag[$start_tag_id] = $end_tag_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 107 | my $recce = Marpa::R2::Thin::R->new($thin_grammar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 107 | $recce->start_input(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 107 | $self->{recce} = $recce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 107 | $self->{tokens} = \@html_parser_tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 107 | $self->{earleme_to_html_token_ix} = [-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | # These variables track virtual start tokens as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # a protection against infinite loops. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 107 | my %start_virtuals_used = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 107 | my $earleme_of_last_start_virtual = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # first token is a dummy, so that ix is never 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # this is done because 0 has a special meaning as a Libmarpa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # token value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 107 | my $latest_html_token = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 107 | my $token_number = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 107 | my $token_count = scalar @html_parser_tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # this array track the last token number (location) at which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # the symbol with this number was last read. It's used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # to prevent the same Ruby Slippers token being added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # at the same location more than once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # If allowed, this could cause an infinite loop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # Note that only start tags are tracked -- the rest of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # array stays at -1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 107 | my @terminal_last_seen = ( (-1) x ( $highest_symbol_id + 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 107 | $thin_grammar->throw_set(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 107 | my $empty_element_end_tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 107 | ▶ | RECCE_RESPONSE: while ( $token_number < $token_count ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 2592 | ▶ | if ( defined $empty_element_end_tag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 11 | my $read_result = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | $recce->alternative( $empty_element_end_tag, RUBY_SLIPPERS_TOKEN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 11 | ▶ | if ( $read_result != $NO_MARPA_ERROR ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 11 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | say {$trace_fh} 'Virtual end tag accepted: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | $tracer->symbol_name($empty_element_end_tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 11 | ▶ | if ( $recce->earleme_complete() < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 11 | my $current_earleme = $recce->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 11 | ▶ | die $thin_grammar->error() if not defined $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 11 | $self->{earleme_to_html_token_ix}->[$current_earleme] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $latest_html_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 11 | $empty_element_end_tag = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 11 | next RECCE_RESPONSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } ## end if ( defined $empty_element_end_tag ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 2581 | my $token = $html_parser_tokens[$token_number]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 2581 | my $attempted_symbol_id = $token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | ->[Marpa::R2::HTML::Internal::Token::TOKEN_ID]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 2581 | my $read_result = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | $recce->alternative( $attempted_symbol_id, PHYSICAL_TOKEN, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 2581 | ▶ | if ( $read_result != $UNEXPECTED_TOKEN_ID ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 1650 | ▶ | if ( $read_result != $NO_MARPA_ERROR ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 1650 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | say {$trace_fh} 'Token accepted: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | $tracer->symbol_name($attempted_symbol_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1650 | ▶ | if ( $recce->earleme_complete() < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1650 | my $last_html_token_of_marpa_token = $token_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1650 | $token_number++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1650 | ▶ | if ( defined $last_html_token_of_marpa_token ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1650 | $latest_html_token = $last_html_token_of_marpa_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 1650 | my $current_earleme = $recce->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 1650 | ▶ | die $thin_grammar->error() if not defined $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 1650 | $self->{earleme_to_html_token_ix}->[$current_earleme] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | $latest_html_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1650 | $empty_element_end_tag = $empty_element_end_tag[$attempted_symbol_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1650 | next RECCE_RESPONSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } ## end if ( $read_result != $UNEXPECTED_TOKEN_ID ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 931 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | say {$trace_fh} 'Literal Token not accepted: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | $tracer->symbol_name($attempted_symbol_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 931 | my $highest_candidate_rank = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 931 | my $virtual_terminal_to_add; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 931 | my $ruby_vector = $ruby_rank_by_id[$attempted_symbol_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 931 | my @terminals_expected = $recce->terminals_expected(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 931 | ▶ | die $thin_grammar->error() if not defined $terminals_expected[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 931 | CANDIDATE: for my $candidate_id (@terminals_expected) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 8527 | my $this_candidate_rank = $ruby_vector->[$candidate_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 8527 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | say {$trace_fh} 'Considering candidate: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | $tracer->symbol_name($candidate_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | "; rank is $this_candidate_rank; highest rank so far is $highest_candidate_rank" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } ## end if ($trace_terminals) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 8527 | ▶ | if ( $this_candidate_rank > $highest_candidate_rank ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 962 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | say {$trace_fh} 'Considering candidate: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | $tracer->symbol_name($candidate_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | '; last seen at ', $terminal_last_seen[$candidate_id], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | "; current token number is $token_number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } ## end if ($trace_terminals) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | next CANDIDATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 962 | ▶ | if $terminal_last_seen[$candidate_id] == $token_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 962 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | say {$trace_fh} 'Current best candidate: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | $tracer->symbol_name($candidate_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 962 | $highest_candidate_rank = $this_candidate_rank; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 962 | $virtual_terminal_to_add = $candidate_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } ## end if ( $this_candidate_rank > $highest_candidate_rank ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } ## end CANDIDATE: for my $candidate_id (@terminals_expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 931 | ▶ | if ( defined $virtual_terminal_to_add ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 914 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | say {$trace_fh} 'Adding Ruby Slippers token: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | $tracer->symbol_name($virtual_terminal_to_add), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 914 | my $ruby_slippers_result = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | $recce->alternative( $virtual_terminal_to_add, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | RUBY_SLIPPERS_TOKEN, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 914 | ▶ | if ( $ruby_slippers_result != $NO_MARPA_ERROR ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 914 | ▶ | if ( $recce->earleme_complete() < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | die $thin_grammar->error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | # Only keep track of start tags. We need to be able to add end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | # tags repeatedly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | # Adding end tags cannot cause an infinite loop, because each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | # one ends an element and only a finite number of elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # can have been started. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 914 | ▶ | $terminal_last_seen[$virtual_terminal_to_add] = $token_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | if $is_start_tag[$virtual_terminal_to_add]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 914 | my $current_earleme = $recce->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 914 | ▶ | die $thin_grammar->error() if not defined $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 914 | $self->{earleme_to_html_token_ix}->[$current_earleme] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | $latest_html_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 914 | $empty_element_end_tag = $empty_element_end_tag[$virtual_terminal_to_add]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 914 | next RECCE_RESPONSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } ## end if ( defined $virtual_terminal_to_add ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # If we didn't find a token to add, add the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # current physical token as CRUFT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 17 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | say {$trace_fh} 'Adding rejected token as cruft: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | $tracer->symbol_name($attempted_symbol_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 17 | ▶ | my $fatal_cruft_error = $token->[Marpa::R2::HTML::Internal::Token::TOKEN_ID] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | == $SYMID_CRUFT ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 17 | ▶ | if ( $trace_cruft or $fatal_cruft_error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trace_cruft or $fatal_cruft_error
MC/DC0%0/2
$trace_cruft or $fatal_cruft_error
$trace_cruft
$fatal_cruft_error
Truth table33%1/3
A or B
A= $trace_cruftB= $fatal_cruft_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $current_earleme = $recce->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | die $thin_grammar->error() if not defined $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my ( $line, $col ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | earleme_to_linecol( $self, $current_earleme ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # HTML::Parser uses one-based line numbers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # but zero-based column numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # The convention (in vi and cut) is that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # columns are also one-based. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $col++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | say {$trace_fh} qq{Cruft at line $line, column $col: "}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | token_range_to_original( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | $self, $token_number, $token_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | q{"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | die 'Internal error: cruft token was rejected' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | if $fatal_cruft_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } ## end if ( $trace_cruft or $fatal_cruft_error ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | # Cruft tokens are not virtual. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | # They are the real things, hacked up. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 17 | $token->[Marpa::R2::HTML::Internal::Token::TOKEN_ID] = $SYMID_CRUFT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } ## end RECCE_RESPONSE: while ( $token_number < $token_count ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 107 | $thin_grammar->throw_set(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 107 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | say {$trace_fh} 'at end of tokens' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 107 | $Marpa::R2::HTML::INSTANCE = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 107 | local $Marpa::R2::HTML::Internal::PARSE_INSTANCE = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 107 | my $latest_earley_set_ID = $recce->latest_earley_set(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 107 | my $bocage = Marpa::R2::Thin::B->new( $recce, $latest_earley_set_ID ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 107 | my $order = Marpa::R2::Thin::O->new($bocage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 107 | my $tree = Marpa::R2::Thin::T->new($order); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 107 | $tree->next(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 107 | my @stack = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 107 | local $Marpa::R2::HTML::Internal::STACK = \@stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 107 | my %memoized_handlers = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 107 | my $valuator = Marpa::R2::Thin::V->new($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 107 | local $Marpa::R2::HTML::Internal::RECCE = $recce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 107 | local $Marpa::R2::HTML::Internal::VALUATOR = $valuator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 107 | for my $rule_id ( grep { $thin_grammar->rule_length($_); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 .. $thin_grammar->highest_rule_id() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 14856 | $valuator->rule_is_valued_set( $rule_id, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 107 | STEP: while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 8040 | my ( $type, @step_data ) = $valuator->step(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 8040 | ▶ | last STEP if not defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 7933 | ▶ | if ( $type eq 'MARPA_STEP_TOKEN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 2575 | ▶ | say {*STDERR} join q{ }, $type, @step_data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$trace_values && (say({*STDERR;} join(' ', $type, @step_data, $tracer->symbol_name($step_data[0]))) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
say {*STDERR;} join(" ", $type, @step_data, $tracer->symbol_name($step_data[0])) or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/3
$trace_values && (say({*STDERR;} join(' ', $type, @step_data, $tracer->symbol_name($step_data[0]))) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_values
say {*STDERR;} join(" ", $type, @step_data, $tracer->symbol_name($step_data[0]))
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table0%0/4
A && B or C
A= $trace_valuesB= say {*STDERR;} join(" ", $type, @step_data, $tracer->symbol_name($step_data[0]))C= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | $tracer->symbol_name( $step_data[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | if $trace_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 2575 | my ( undef, $token_value, $arg_n ) = @step_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 2575 | ▶ | if ( $token_value eq RUBY_SLIPPERS_TOKEN ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 925 | $stack[$arg_n] = ['RUBY_SLIPPERS_TOKEN']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 925 | ▶ | say {*STDERR} "Stack:\n", Data::Dumper::Dumper( \@stack ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$trace_values && (say({*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack) or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/3
$trace_values && (say({*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_values
say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table0%0/4
A && B or C
A= $trace_valuesB= say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)C= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | if $trace_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 925 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } ## end if ( $token_value eq RUBY_SLIPPERS_TOKEN ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 1650 | my ( $start_earley_set_id, $end_earley_set_id ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | $valuator->location(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 1650 | my $start_earleme = $recce->earleme($start_earley_set_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | my $start_html_token_ix = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 1650 | $self->{earleme_to_html_token_ix}->[$start_earleme]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 1650 | my $end_earleme = $recce->earleme($end_earley_set_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | my $end_html_token_ix = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 1650 | $self->{earleme_to_html_token_ix}->[$end_earleme]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 1650 | $stack[$arg_n] = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 'PHYSICAL_TOKEN' => $start_html_token_ix + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | $end_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 1650 | ▶ | say {*STDERR} "Stack:\n", Data::Dumper::Dumper( \@stack ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$trace_values && (say({*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack) or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/3
$trace_values && (say({*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_values
say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table0%0/4
A && B or C
A= $trace_valuesB= say {*STDERR;} "Stack:\n", Data::Dumper::Dumper(\@stack)C= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | if $trace_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 1650 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } ## end if ( $type eq 'MARPA_STEP_TOKEN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 5358 | ▶ | if ( $type eq 'MARPA_STEP_RULE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 4721 | ▶ | say {*STDERR} join q{ }, ( $type, @step_data ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$trace_values && (say({*STDERR;} join(' ', ($type, @step_data))) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
say {*STDERR;} join(" ", ($type, @step_data)) or Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
MC/DC0%0/3
$trace_values && (say({*STDERR;} join(' ', ($type, @step_data))) || Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO"))
$trace_values
say {*STDERR;} join(" ", ($type, @step_data))
Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
Truth table0%0/4
A && B or C
A= $trace_valuesB= say {*STDERR;} join(" ", ($type, @step_data))C= Carp::croak("Cannot print: $Marpa::R2::HTML::Internal::ERRNO")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | or Carp::croak("Cannot print: $ERRNO") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | if $trace_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 4721 | my ( $rule_id, $arg_0, $arg_n ) = @step_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 4721 | my $attributes = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 4721 | my $class = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 4721 | my $action = $action_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 4721 | local $Marpa::R2::HTML::Internal::START_TAG_IX = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 4721 | local $Marpa::R2::HTML::Internal::END_TAG_IX_REF = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 4721 | local $Marpa::R2::HTML::Internal::ELEMENT = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 4721 | local $Marpa::R2::HTML::Internal::SPECIES = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 4721 | ▶ | if ( defined $action and ( index $action, 'ELE_' ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $action and index($action, "ELE_") == 0
MC/DC100%2/2
defined $action and index($action, "ELE_") == 0
defined $action
index($action, "ELE_") == 0
Truth table100%3/3
A and B
A= defined $actionB= index($action, "ELE_") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 862 | $Marpa::R2::HTML::Internal::SPECIES = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | $Marpa::R2::HTML::Internal::ELEMENT = substr $action, 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 862 | my $start_tag_marpa_token = $stack[$arg_0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 862 | my $start_tag_type = $start_tag_marpa_token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | ->[Marpa::R2::HTML::Internal::TDesc::TYPE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 862 | ▶ | if ( defined $start_tag_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $start_tag_type and $start_tag_type eq "PHYSICAL_TOKEN"
MC/DC50%1/2
defined $start_tag_type and $start_tag_type eq "PHYSICAL_TOKEN"
defined $start_tag_type
$start_tag_type eq "PHYSICAL_TOKEN"
Truth table66%2/3
A and B
A= defined $start_tag_typeB= $start_tag_type eq "PHYSICAL_TOKEN"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | and $start_tag_type eq 'PHYSICAL_TOKEN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 453 | my $start_tag_ix = $start_tag_marpa_token->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 453 | my $start_tag_token = $html_parser_tokens[$start_tag_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 453 | ▶ | if ( $start_tag_token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | ->[Marpa::R2::HTML::Internal::Token::TYPE] eq 'S' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 453 | $Marpa::R2::HTML::Internal::START_TAG_IX = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | $start_tag_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 453 | $attributes = $start_tag_token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ->[Marpa::R2::HTML::Internal::Token::ATTR]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } ## end if ( $start_tag_token->[...]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } ## end if ( defined $start_tag_type and $start_tag_type eq ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } ## end if ( defined $action and ( index $action, 'ELE_' ) ==...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 4721 | ▶ | if ( defined $action and ( index $action, 'SPE_' ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $action and index($action, "SPE_") == 0
MC/DC100%2/2
defined $action and index($action, "SPE_") == 0
defined $action
index($action, "SPE_") == 0
Truth table100%3/3
A and B
A= defined $actionB= index($action, "SPE_") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 858 | $Marpa::R2::HTML::Internal::SPECIES = q{:} . substr $action, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 4721 | local $Marpa::R2::HTML::Internal::ATTRIBUTES = $attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 4721 | ▶ | $class = $attributes->{class} // q{*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$attributes->{"class"} // "*"
MC/DC100%1/1
$attributes->{"class"} // "*"
$attributes->{"class"}
Truth table100%2/2
A
A= $attributes->{"class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 4721 | local $Marpa::R2::HTML::Internal::CLASS = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 4721 | local $Marpa::R2::HTML::Internal::ARG_0 = $arg_0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 4721 | local $Marpa::R2::HTML::Internal::ARG_N = $arg_n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 4721 | my ( $start_earley_set_id, $end_earley_set_id ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | $valuator->location(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 4721 | my $start_earleme = $recce->earleme($start_earley_set_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | my $start_html_token_ix = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 4721 | $self->{earleme_to_html_token_ix}->[$start_earleme] + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 4721 | my $end_earleme = $recce->earleme($end_earley_set_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | my $end_html_token_ix = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 4721 | $self->{earleme_to_html_token_ix}->[$end_earleme]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 4721 | ▶ | if ( $start_html_token_ix > $end_html_token_ix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 130 | $start_html_token_ix = $end_html_token_ix = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 4721 | local $Marpa::R2::HTML::Internal::START_HTML_TOKEN_IX = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | $start_html_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 4721 | local $Marpa::R2::HTML::Internal::END_HTML_TOKEN_IX = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | $end_html_token_ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 4721 | my $handler_key = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | $rule_id . q{;} . $Marpa::R2::HTML::Internal::CLASS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 4721 | my $handler = $memoized_handlers{$handler_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | $trace_handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | and $handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 4721 | ▶ | and say {*STDERR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$trace_handlers and $handler
$class // "*"
MC/DC0%0/2
$trace_handlers and $handler
$trace_handlers
$handler
MC/DC0%0/1
$class // "*"
$class
Truth table33%1/3
A and B
A= $trace_handlersB= $handler
Truth table0%0/2
A
A= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | qq{Found memoized handler for rule $rule_id, class "}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ( $class // q{*} ), q{"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 4721 | ▶ | if ( not defined $handler ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 1636 | $handler = $memoized_handlers{$handler_key} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | handler_find( $self, $rule_id, $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | COMPUTE_VALUE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 4721 | ▶ | if ( ref $handler ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 730 | $stack[$arg_0] = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | VALUED_SPAN => $start_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | $end_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | ( scalar $handler->() ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | $rule_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 730 | last COMPUTE_VALUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } ## end if ( ref $handler ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 3991 | my @flat_tdesc_list = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | STACK_IX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 3991 | for my $stack_ix ( $Marpa::R2::HTML::Internal::ARG_0 .. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | $Marpa::R2::HTML::Internal::ARG_N ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 5884 | my $tdesc_item = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | $Marpa::R2::HTML::Internal::STACK->[$stack_ix]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 5884 | my $tdesc_type = $tdesc_item->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 5884 | ▶ | next STACK_IX if not defined $tdesc_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 5884 | ▶ | if ( $tdesc_type eq 'VALUES' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | push @flat_tdesc_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 473 | @{ $tdesc_item | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | ->[Marpa::R2::HTML::Internal::TDesc::VALUE] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 473 | next STACK_IX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } ## end if ( $tdesc_type eq 'VALUES' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 5411 | ▶ | next STACK_IX if $tdesc_type ne 'VALUED_SPAN'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 3653 | push @flat_tdesc_list, $tdesc_item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } ## end STACK_IX: for my $stack_ix ( $Marpa::R2::HTML::Internal::ARG_0...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 3991 | ▶ | if ( scalar @flat_tdesc_list <= 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 3336 | $stack[$arg_0] = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | VALUED_SPAN => $start_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | $end_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | $flat_tdesc_list[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | ->[Marpa::R2::HTML::Internal::TDesc::VALUE], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | $rule_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 3336 | last COMPUTE_VALUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } ## end if ( scalar @flat_tdesc_list <= 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 655 | $stack[$arg_0] = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | VALUES => $start_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | $end_html_token_ix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | \@flat_tdesc_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | $rule_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } ## end COMPUTE_VALUE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 4721 | ▶ | if ($trace_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | ▶ | say {*STDERR} "rule $rule_id: ", join q{ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | symbol_names_by_rule_id( $self, $rule_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | say {*STDERR} "Stack:\n", Data::Dumper::Dumper( \@stack ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } ## end if ($trace_values) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 4721 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } ## end if ( $type eq 'MARPA_STEP_RULE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 637 | ▶ | if ( $type eq 'MARPA_STEP_NULLING_SYMBOL' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 637 | my ( $symbol_id, $arg_n ) = @step_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 637 | $stack[$arg_n] = ['ZERO_SPAN']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 637 | ▶ | if ($trace_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | ▶ | say {*STDERR} join q{ }, $type, @step_data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | $tracer->symbol_name($symbol_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | ▶ | say {*STDERR} "Stack:\n", Data::Dumper::Dumper( \@stack ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | or Carp::croak("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } ## end if ($trace_values) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 637 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } ## end if ( $type eq 'MARPA_STEP_NULLING_SYMBOL' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | die "Unexpected step type: $type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } ## end STEP: while (1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 107 | my $result = $stack[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 107 | ▶ | Marpa::R2::exception('No parse: evaler returned undef') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | if not defined $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 107 | ▶ | if ( ref $self->{handler_by_species}->{TOP} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | ## This is a user-defined handler. We assume it returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | ## a VALUED_SPAN. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 19 | $result = $result->[Marpa::R2::HTML::Internal::TDesc::VALUE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | ## The TOP handler was the default handler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | ## We now want to "literalize" its result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | FIND_LITERALIZEABLE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 88 | my $type = $result->[Marpa::R2::HTML::Internal::TDesc::TYPE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 88 | ▶ | if ( $type eq 'VALUES' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 11 | $result = $result->[Marpa::R2::HTML::Internal::TDesc::VALUE]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 11 | last FIND_LITERALIZEABLE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 77 | ▶ | if ( $type eq 'VALUED_SPAN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 77 | $result = [$result]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 77 | last FIND_LITERALIZEABLE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | die 'Internal: TOP result is not literalize-able'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } ## end FIND_LITERALIZEABLE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 88 | $result = range_and_values_to_literal( $self, 0, $#html_parser_tokens, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | $result ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | } ## end else [ if ( ref $self->{handler_by_species}->{TOP} ) ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 107 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } ## end sub parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | sub Marpa::R2::HTML::html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 109 | ▶ | my ( $document_ref, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 109 | my $html = Marpa::R2::HTML::Internal::create(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 109 | return Marpa::R2::HTML::Internal::parse( $html, $document_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | # vim: set expandtab shiftwidth=4: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||