| 1 | # /=====================================================================\ # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | LaTeXML::Core::Gullet | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | Analog of TeX's Gullet; deals with expansion and arg parsing | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # |=====================================================================| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | Part of LaTeXML: | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | Public domain software, produced as part of work done by the | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | United States Government & not subject to copyright in the US. | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # |---------------------------------------------------------------------| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # \=========================================================ooo==U==ooo=/ # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package LaTeXML::Core::Gullet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use LaTeXML::Global; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use LaTeXML::Common::Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use LaTeXML::Common::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use LaTeXML::Core::Token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use LaTeXML::Core::Tokens; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use LaTeXML::Core::Mouth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use LaTeXML::Util::Pathname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use LaTeXML::Common::Number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use LaTeXML::Common::Float; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use LaTeXML::Common::Dimension; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use LaTeXML::Common::Glue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use LaTeXML::Core::MuDimension; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use LaTeXML::Core::MuGlue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use base qw(LaTeXML::Common::Object); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | mouth => undef, mouthstack => [], pushback => [], autoclose => 1, pending_comments => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | }, $class; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Start reading tokens from a new Mouth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # This pushes the mouth as the current source that $gullet->readToken (etc) will read from. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Once this Mouth has been exhausted, readToken, etc, will return undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # until you call $gullet->closeMouth to clear the source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Exception: if $toplevel=1, readXToken will step to next source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Note that a Tokens can act as a Mouth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | sub openMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my ($self, $mouth, $noautoclose) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openMouth: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return unless $mouth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | unshift(@{ $$self{mouthstack} }, [$$self{mouth}, $$self{pushback}, $$self{autoclose}]) if $$self{mouth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $$self{mouth} = $mouth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $$self{pushback} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $$self{autoclose} = !$noautoclose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | sub closeMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my ($self, $forced) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
closeMouth: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if (!$forced && (@{ $$self{pushback} } || $$self{mouth}->hasMoreInput)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $forced and @{$self->{"pushback"};} || $self->{"mouth"}->hasMoreInput
@{$self->{"pushback"};} or $self->{"mouth"}->hasMoreInput
MC/DC0%0/3
not $forced and @{$self->{"pushback"};} || $self->{"mouth"}->hasMoreInput
not $forced
@{$self->{"pushback"};}
$self->{"mouth"}->hasMoreInput
Truth table0%0/4
not(A) and B or C
A= not $forcedB= @{$self->{"pushback"};}C= $self->{"mouth"}->hasMoreInput
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $next = Stringify($self->readToken); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | Error('unexpected', $next, $self, "Closing mouth with input remaining '$next'"); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $$self{mouth}->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if (@{ $$self{mouthstack} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ($$self{mouth}, $$self{pushback}, $$self{autoclose}) = @{ shift(@{ $$self{mouthstack} }) }; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $$self{pushback} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## $$self{mouth}=Tokens(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $$self{mouth} = LaTeXML::Core::Mouth->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #### $$self{mouth}=undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $$self{autoclose} = 1; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | sub getMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMouth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $$self{mouth}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub mouthIsOpen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my ($self, $mouth) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mouthIsOpen: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | return ($$self{mouth} eq $mouth) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | || grep { $_ && ($$_[0] eq $mouth) } @{ $$self{mouthstack} }; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{'mouth'} eq $mouth || grep({$_ and $_->[0] eq $mouth;} @{$$self{'mouthstack'};})
MC/DC0%0/2
$self->{'mouth'} eq $mouth || grep({$_ and $_->[0] eq $mouth;} @{$$self{'mouthstack'};})
$self->{'mouth'} eq $mouth
grep({$_ and $_->[0] eq $mouth;} @{$$self{'mouthstack'};})
Truth table0%0/3
A || B
A= $self->{'mouth'} eq $mouthB= grep({$_ and $_->[0] eq $mouth;} @{$$self{'mouthstack'};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # This flushes a mouth so that it will be automatically closed, next time it's read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # Corresponds (I think) to TeX's \endinput | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub flushMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flushMouth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $$self{mouth}->finish; # but not close! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $$self{pushback} = []; # And don't read anytyhing more from it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $$self{autoclose} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # Obscure, but the only way I can think of to End!! (see \bye or \end{document}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Flush all sources (close all pending mouth's) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub flush { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $$self{mouth}->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | while (@{ $$self{mouthstack} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $entry = shift @{ $$self{mouthstack} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $$entry[0]->finish; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $$self{pushback} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ## $$self{mouth}=Tokens(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $$self{mouth} = LaTeXML::Core::Mouth->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | #### $$self{mouth}=undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $$self{autoclose} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $$self{mouthstack} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # Do something, while reading stuff from a specific Mouth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # This reads ONLY from that mouth (or any mouth openned by code in that source), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # and the mouth should end up empty afterwards, and only be closed here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sub readingFromMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my ($self, $mouth, $closure) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readingFromMouth: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->openMouth($mouth, 1); # only allow mouth to be explicitly closed here. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ($result, @result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | @result = &$closure($self); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $result = &$closure($self); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # $mouth must still be open, with (at worst) empty autoclosable mouths in front of it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($$self{mouth} eq $mouth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->closeMouth(1); last; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | elsif (!@{ $$self{mouthstack} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | Error('unexpected', '<closed>', $self, "Mouth is unexpectedly already closed", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | "Reading from " . Stringify($mouth) . ", but it has already been closed."); last; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | elsif (!$$self{autoclose} || @{ $$self{pushback} } || $$self{mouth}->hasMoreInput) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
not $self->{"autoclose"} or @{$self->{"pushback"};} or $self->{"mouth"}->hasMoreInput
not $self->{"autoclose"} or @{$self->{"pushback"};}
MC/DC0%0/3
not $self->{"autoclose"} or @{$self->{"pushback"};} or $self->{"mouth"}->hasMoreInput
not $self->{"autoclose"}
@{$self->{"pushback"};}
$self->{"mouth"}->hasMoreInput
Truth table0%0/4
not(A) or B or C
A= not $self->{"autoclose"}B= @{$self->{"pushback"};}C= $self->{"mouth"}->hasMoreInput
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $next = Stringify($self->readToken); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | Error('unexpected', $next, $self, "Unexpected input remaining: '$next'", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | "Finished reading from " . Stringify($mouth) . ", but it still has input."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $$self{mouth}->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $self->closeMouth(1); } # ?? if we continue? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->closeMouth; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return (wantarray ? @result : $result); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # User feedback for where something (error?) occurred. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub getLocator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLocator: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $mouth = $$self{mouth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | while ((defined $mouth) && (!defined $$mouth{source}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $mouth and not defined $mouth->{"source"} and $i < scalar @{$self->{"mouthstack"};}
defined $mouth and not defined $mouth->{"source"}
MC/DC0%0/3
defined $mouth and not defined $mouth->{"source"} and $i < scalar @{$self->{"mouthstack"};}
defined $mouth
not defined $mouth->{"source"}
$i < scalar @{$self->{"mouthstack"};}
Truth table0%0/4
A and not(B) and C
A= defined $mouthB= not defined $mouth->{"source"}C= $i < scalar @{$self->{"mouthstack"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | && ($i < scalar(@{ $$self{mouthstack} }))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $mouth = $$self{mouthstack}[$i++][0]; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $loc = (defined $mouth ? $mouth->getLocator : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return $loc if defined $loc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | foreach my $frame (@{ $$self{mouthstack} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $ml = $$frame[0]->getLocator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return $ml if defined $ml; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | sub getSource { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSource: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $source = defined $$self{mouth} && $$self{mouth}->getSource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $self->{'mouth'} && $self->{'mouth'}->getSource
MC/DC0%0/2
defined $self->{'mouth'} && $self->{'mouth'}->getSource
defined $self->{'mouth'}
$self->{'mouth'}->getSource
Truth table0%0/3
A && B
A= defined $self->{'mouth'}B= $self->{'mouth'}->getSource
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if (!defined($source)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | foreach my $frame (@{ $$self{mouthstack} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $source = $$frame[0]->getSource; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | last if defined($source); } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return $source; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | sub getSourceMouth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSourceMouth: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $mouth = $$self{mouth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $source = defined $mouth && $mouth->getSource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $mouth && $mouth->getSource
MC/DC0%0/2
defined $mouth && $mouth->getSource
defined $mouth
$mouth->getSource
Truth table0%0/3
A && B
A= defined $mouthB= $mouth->getSource
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (!defined($source)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | foreach my $frame (@{ $$self{mouthstack} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $mouth = $$frame[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $source = $mouth->getSource; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | last if defined($source); } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return $mouth; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Handy message generator when we didn't get something expected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | sub showUnexpected { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
showUnexpected: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $message = "Input is empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if (my $token = $self->readToken) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $message = "Next token is " . Stringify($token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | unshift(@{ $$self{pushback} }, $token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return $message; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | sub show_pushback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my ($pb) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_pushback: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my @pb = @$pb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | @pb = (@pb[0 .. 50], T_OTHER('...')) if scalar(@pb) > 55; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return (@pb ? "\n To be read again " . ToString(Tokens(@pb)) : ''); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Not really 100% sure how this is supposed to work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # See TeX Ch 20, p216 regarding noexpand, \edef with token list registers, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Solution: Duplicate param tokens, stick NOTEXPANDED infront of expandable tokens. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub neutralizeTokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my ($self, @tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neutralizeTokens: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my @result = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | foreach my $token (@tokens) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ($$token[1] == CC_PARAM) { # Inline ->getCatcode! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | push(@result, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif (defined(my $defn = LaTeXML::Core::State::lookupDefinition($STATE, $token))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | push(@result, Token('\noexpand', CC_NOTEXPANDED)); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | push(@result, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return @result; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Low-level readers: read token, read expanded token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # Note that every char (token) comes through here (maybe even twice, through args parsing), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # So, be Fast & Clean! This method only reads from the current input stream (Mouth). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | our @hold_token = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0, 0, 1, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0, 0, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | sub readToken { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readToken: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # my $token = shift(@{$$self{pushback}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my $cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Check in pushback first.... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | while (($token = shift(@{ $$self{pushback} })) && $hold_token[$cc = $$token[1]]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token = shift @{$$self{"pushback"};} and $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
MC/DC0%0/2
$token = shift @{$$self{"pushback"};} and $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
$token = shift @{$$self{"pushback"};}
$LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
Truth table0%0/3
A and B
A= $token = shift @{$$self{"pushback"};}B= $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ($cc == CC_COMMENT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | push(@{ $$self{pending_comments} }, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | elsif ($cc == CC_MARKER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | LaTeXML::Core::Definition::stopProfiling($token, 'expand'); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return $token if defined $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | while (($token = $$self{mouth}->readToken()) && $hold_token[$cc = $$token[1]]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
MC/DC0%0/2
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
$token = $self->{"mouth"}->readToken
$LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
Truth table0%0/3
A and B
A= $token = $self->{"mouth"}->readTokenB= $LaTeXML::Core::Gullet::hold_token[$cc = $token->[1]]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($cc == CC_COMMENT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | push(@{ $$self{pending_comments} }, $token); } # What to do with comments??? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif ($cc == CC_MARKER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | LaTeXML::Core::Definition::stopProfiling($token, 'expand'); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return $token; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Unread tokens are assumed to be not-yet expanded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | sub unread { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my ($self, @tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unread: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | unshift(@{ $$self{pushback} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | map { (!defined $_ ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | : (($r = ref $_) eq 'LaTeXML::Core::Token' ? $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | : ($r eq 'LaTeXML::Core::Tokens' ? @$_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | : Fatal('misdefined', $r, undef, "Expected a Token, got " . Stringify($_))))) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | @tokens); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # Read the next non-expandable token (expanding tokens until there's a non-expandable one). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # Note that most tokens pass through here, so be Fast & Clean! readToken is folded in. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # `Toplevel' processing, (if $toplevel is true), used at the toplevel processing by Stomach, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # will step to the next input stream (Mouth) if one is available, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # If $commentsok is true, will also pass comments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sub readXToken { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my ($self, $toplevel, $commentsok) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readXToken: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | $toplevel = 1 unless defined $toplevel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | return shift(@{ $$self{pending_comments} }) if $commentsok && @{ $$self{pending_comments} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$commentsok and @{$self->{"pending_comments"};}
MC/DC0%0/2
$commentsok and @{$self->{"pending_comments"};}
$commentsok
@{$self->{"pending_comments"};}
Truth table0%0/3
A and B
A= $commentsokB= @{$self->{"pending_comments"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my ($token, $cc, $defn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $token = shift(@{ $$self{pushback} }) || $$self{mouth}->readToken(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift @{$$self{'pushback'};} || $self->{'mouth'}->readToken
MC/DC0%0/2
shift @{$$self{'pushback'};} || $self->{'mouth'}->readToken
shift @{$$self{'pushback'};}
$self->{'mouth'}->readToken
Truth table0%0/3
A || B
A= shift @{$$self{'pushback'};}B= $self->{'mouth'}->readToken
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (!defined $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return unless $$self{autoclose} && $toplevel && @{ $$self{mouthstack} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"autoclose"} and $toplevel and @{$self->{"mouthstack"};}
$self->{"autoclose"} and $toplevel
MC/DC0%0/3
$self->{"autoclose"} and $toplevel and @{$self->{"mouthstack"};}
$self->{"autoclose"}
$toplevel
@{$self->{"mouthstack"};}
Truth table0%0/4
A and B and C
A= $self->{"autoclose"}B= $toplevelC= @{$self->{"mouthstack"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->closeMouth; } # Next input stream. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | elsif (($cc = $$token[1]) == CC_NOTEXPANDED) { # NOTE: Inlined ->getCatcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # Should only occur IMMEDIATELY after expanding \noexpand (by readXToken), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # so this token should never leak out through an EXTERNAL call to readToken. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return $self->readToken; } # Just return the next token. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | elsif ($cc == CC_COMMENT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return $token if $commentsok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | push(@{ $$self{pending_comments} }, $token); } # What to do with comments??? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | elsif ($cc == CC_MARKER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | LaTeXML::Core::Definition::stopProfiling($token, 'expand'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # Note: special-purpose lookup in State, for efficiency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | elsif (defined($defn = LaTeXML::Core::State::lookupExpandable($STATE, $token, $toplevel))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | local $LaTeXML::CURRENT_TOKEN = $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if (my $r = $defn->invoke($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | unshift(@{ $$self{pushback} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | map { (!defined $_ ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | : (($r = ref $_) eq 'LaTeXML::Core::Token' ? $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | : ($r eq 'LaTeXML::Core::Tokens' ? @$_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | : Fatal('misdefined', $r, undef, "Expected a Token, got " . Stringify($_))))) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | @{$r}); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return $token; } # just return it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return; } # never get here. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Read the next raw line (string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # primarily to read from the Mouth, but keep any unread input! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | sub readRawLine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readRawLine: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # If we've got unread tokens, they presumably should come before the Mouth's raw data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # but we'll convert them back to string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my @tokens = @{ $$self{pushback} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my @markers = grep { $_->getCatcode == CC_MARKER } @tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if (@markers) { # Whoops, profiling markers! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | @tokens = grep { $_->getCatcode != CC_MARKER } @tokens; # Remove | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | map { LaTeXML::Core::Definition::stopProfiling($_, 'expand') } @markers; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $$self{pushback} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # If we still have peeked tokens, we ONLY want to combine it with the remainder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # of the current line from the Mouth (NOT reading a new line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (@tokens) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return ToString(Tokens(@tokens)) . $$self{mouth}->readRawLine(1); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Otherwise, read the next line from the Mouth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return $$self{mouth}->readRawLine; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Mid-level readers: checking and matching tokens, strings etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # The following higher-level parsing methods are built upon readToken & unread. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | sub readNonSpace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readNonSpace: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | do { $token = $self->readToken(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $token and $token->[1] == 10
MC/DC0%0/2
defined $token and $token->[1] == 10
defined $token
$token->[1] == 10
Truth table0%0/3
A and B
A= defined $tokenB= $token->[1] == 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } while (defined $token && $$token[1] == CC_SPACE); # Inline ->getCatcode! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return $token; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | sub readXNonSpace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readXNonSpace: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | do { $token = $self->readXToken(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $token and $token->[1] == 10
MC/DC0%0/2
defined $token and $token->[1] == 10
defined $token
$token->[1] == 10
Truth table0%0/3
A and B
A= defined $tokenB= $token->[1] == 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } while (defined $token && $$token[1] == CC_SPACE); # Inline ->getCatcode! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | return $token; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | sub skipSpaces { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipSpaces: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $tok = $self->readNonSpace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | unshift(@{ $$self{pushback} }, $tok) if defined $tok; # Unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | sub skip1Space { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip1Space: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $token = $self->readToken(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token && ($$token[1] != CC_SPACE); # Inline ->getCatcode, unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->[1] != 10
MC/DC0%0/2
$token and $token->[1] != 10
$token
$token->[1] != 10
Truth table0%0/3
A and B
A= $tokenB= $token->[1] != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # <filler> = <optional spaces> | <filler>\relax<optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | sub skipFiller { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipFiller: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $tok = $self->readNonSpace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | return unless defined $tok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Should \foo work too (where \let\foo\relax) ?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($tok->getString ne '\relax') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | unshift(@{ $$self{pushback} }, $tok); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # Read a sequence of tokens balanced in {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # assuming the { has already been read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # Returns a Tokens list of the balanced sequence, omitting the closing } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 4 | our @balanced_interesting_cc = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0, 1, 1, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0, 0, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | sub readBalanced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my ($self, $expanded) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readBalanced: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my @tokens = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ($token, $level) = (undef, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $startloc = $self->getLocator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # Inlined readToken (we'll keep comments in the result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | while ($token = ($expanded ? $self->readXToken(0, 1) : $self->readToken())) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $cc = $$token[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if (!$balanced_interesting_cc[$cc]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | push(@tokens, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | elsif ($cc == CC_END) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $level--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | last unless $level; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | push(@tokens, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | elsif ($cc == CC_BEGIN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $level++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | push(@tokens, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | elsif ($cc == CC_MARKER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | LaTeXML::Core::Definition::stopProfiling($token, 'expand'); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if ($level > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # TODO: The current implementation has a limitation where if the balancing end is in a different mouth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # it will not be recognized. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | Error('expected', "}", $self, "Gullet->readBalanced ran out of input in an unbalanced state.", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | "started at $startloc"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return Tokens(@tokens); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | sub ifNext { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | my ($self, $token) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ifNext: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if (my $tok = $self->readToken()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | unshift(@{ $$self{pushback} }, $tok); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return $tok->equals($token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | else { return 0; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # Match the input against one of the Token or Tokens in @choices; return the matching one or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | sub readMatch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my ($self, @choices) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMatch: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | foreach my $choice (@choices) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my @tomatch = $choice->unlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my @matched = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | while (@tomatch && defined($token = $self->readToken) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
@tomatch and defined($token = $self->readToken) and push @matched, $token and $token->equals($tomatch[0])
@tomatch and defined($token = $self->readToken) and push @matched, $token
@tomatch and defined($token = $self->readToken)
MC/DC0%0/4
@tomatch and defined($token = $self->readToken) and push @matched, $token and $token->equals($tomatch[0])
@tomatch
defined($token = $self->readToken)
push @matched, $token
$token->equals($tomatch[0])
Truth table0%0/5
A and B and C and D
A= @tomatchB= defined($token = $self->readToken)C= push @matched, $tokenD= $token->equals($tomatch[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | && push(@matched, $token) && ($token->equals($tomatch[0]))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | shift(@tomatch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ($$token[1] == CC_SPACE) { # If this was space, SKIP any following!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | while (defined($token = $self->readToken) && ($$token[1] == CC_SPACE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined($token = $self->readToken) and $token->[1] == 10
MC/DC0%0/2
defined($token = $self->readToken) and $token->[1] == 10
defined($token = $self->readToken)
$token->[1] == 10
Truth table0%0/3
A and B
A= defined($token = $self->readToken)B= $token->[1] == 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | push(@matched, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token; } # Unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | return $choice unless @tomatch; # All matched!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | unshift(@{ $$self{pushback} }, @matched); # Put 'em back and try next! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # Match the input against a set of keywords; Similar to readMatch, but the keywords are strings, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # and Case and catcodes are ignored; additionally, leading spaces are skipped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # AND, macros are expanded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | sub readKeyword { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | my ($self, @keywords) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readKeyword: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->skipSpaces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | foreach my $keyword (@keywords) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $keyword = ToString($keyword) if ref $keyword; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my @tomatch = split('', uc($keyword)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my @matched = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my $tok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | while (@tomatch && defined($tok = $self->readXToken(0)) && push(@matched, $tok) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok and uc $tok->getString eq $tomatch[0]
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok
@tomatch and defined($tok = $self->readXToken(0))
MC/DC0%0/4
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok and uc $tok->getString eq $tomatch[0]
@tomatch
defined($tok = $self->readXToken(0))
push @matched, $tok
uc $tok->getString eq $tomatch[0]
Truth table0%0/5
A and B and C and D
A= @tomatchB= defined($tok = $self->readXToken(0))C= push @matched, $tokD= uc $tok->getString eq $tomatch[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | && (uc($tok->getString) eq $tomatch[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | shift(@tomatch); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | return $keyword unless @tomatch; # All matched!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | unshift(@{ $$self{pushback} }, @matched); # Put 'em back and try next! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # Return a (balanced) sequence tokens until a match against one of the Tokens in @delims. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # In list context, also returns the found delimiter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | sub readUntil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | my ($self, @delims) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readUntil: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ($n, $found, @tokens) = (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | while (!defined($found = $self->readMatch(@delims))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $token = $self->readToken(); # Copy next token to args | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return unless defined $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | push(@tokens, $token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($$token[1] == CC_BEGIN) { # And if it's a BEGIN, copy till balanced END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | push(@tokens, $self->readBalanced->unlist, T_END); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Notice that IFF the arg looks like {balanced}, the outer braces are stripped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # so that delimited arguments behave more similarly to simple, undelimited arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if (($n == 1) && ($tokens[0][1] == CC_BEGIN)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n == 1 and $tokens[0][1] == 1
MC/DC0%0/2
$n == 1 and $tokens[0][1] == 1
$n == 1
$tokens[0][1] == 1
Truth table0%0/3
A and B
A= $n == 1B= $tokens[0][1] == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | shift(@tokens); pop(@tokens); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | return (wantarray ? (Tokens(@tokens), $found) : Tokens(@tokens)); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | sub readUntilBrace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readUntilBrace: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my @tokens = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | while (defined($token = $self->readToken())) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if ($$token[1] == CC_BEGIN) { # INLINE Catcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | unshift(@{ $$self{pushback} }, $token); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | last; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | push(@tokens, $token); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | return Tokens(@tokens); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # Skipping over conditional branches is used heavily when processing raw TeX (eg. tikz). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # Make this efficient! Note that since we're skipping tokens, we presumably neither | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # need to note profiling end markers, nor preserve comments in the skipped sections? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | sub readNextConditional { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readNextConditional: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | my $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | while ($token = shift(@{ $$self{pushback} }) || $$self{mouth}->readToken()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
shift @{$$self{'pushback'};} || $self->{'mouth'}->readToken
MC/DC0%0/2
shift @{$$self{'pushback'};} || $self->{'mouth'}->readToken
shift @{$$self{'pushback'};}
$self->{'mouth'}->readToken
Truth table0%0/3
A || B
A= shift @{$$self{'pushback'};}B= $self->{'mouth'}->readToken
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ($type = $STATE->lookupConditional($token)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return ($token, $type); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # Higher-level readers: Read various types of things from the input: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # tokens, non-expandable tokens, args, Numbers, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | sub readArg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readArg: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $token = $self->readNonSpace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if (!defined $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | elsif ($$token[1] == CC_BEGIN) { # Inline ->getCatcode! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | return $self->readBalanced; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | return Tokens($token); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Note that this returns an empty array if [] is present, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # otherwise $default or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub readOptional { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my ($self, $default) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readOptional: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $tok = $self->readNonSpace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if (!defined $tok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | elsif (($tok->equals(T_OTHER('[')))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return $self->readUntil(T_OTHER(']')); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | unshift(@{ $$self{pushback} }, $tok); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | return $default; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # Numbers, Dimensions, Glue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # See TeXBook, Ch.24, pp.269-271. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | sub readValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | my ($self, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readValue: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ($type eq 'Number') { return $self->readNumber; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | elsif ($type eq 'Dimension') { return $self->readDimension; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | elsif ($type eq 'Glue') { return $self->readGlue; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | elsif ($type eq 'MuGlue') { return $self->readMuGlue; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | elsif ($type eq 'Tokens') { return $self->readTokensValue; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | elsif ($type eq 'Token') { return $self->readToken; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | elsif ($type eq 'any') { return $self->readArg; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | Error('unexpected', $type, $self, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | "Gullet->readValue Didn't expect this type: $type"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | sub readRegisterValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | my ($self, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readRegisterValue: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $token = $self->readXToken(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | return unless defined $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $defn = LaTeXML::Core::State::lookupDefinition($STATE, $token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if ((defined $defn) && ($defn->isRegister eq $type)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $defn and $defn->isRegister eq $type
MC/DC0%0/2
defined $defn and $defn->isRegister eq $type
defined $defn
$defn->isRegister eq $type
Truth table0%0/3
A and B
A= defined $defnB= $defn->isRegister eq $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return $defn->valueOf($defn->readArguments($self)); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | unshift(@{ $$self{pushback} }, $token); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # Apparent behaviour of a token value (ie \toks#=<arg>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | sub readTokensValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readTokensValue: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $token = $self->readNonSpace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if (!defined $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | elsif ($$token[1] == CC_BEGIN) { # Inline ->getCatcode! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return $self->readBalanced; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | elsif (my $defn = LaTeXML::Core::State::lookupDefinition($STATE, $token)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if ($defn->isRegister eq 'Tokens') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return $defn->valueOf($defn->readArguments($self)); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | elsif ($defn->isExpandable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | if (my $x = $defn->invoke($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $self->unread(@{$x}); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | return $self->readTokensValue; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return $token; } } # ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | return $token; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # some helpers... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # <optional signs> = <optional spaces> | <optional signs><plus or minus><optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # return +1 or -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | sub readOptionalSigns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readOptionalSigns: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my ($sign, $t) = ("+1", ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | while (defined($t = $self->readXToken(0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined($t = $self->readXToken(0)) and $t->getString eq "+" || $t->getString eq "-" || $t->equals(bless( [" ",10], 'LaTeXML::Core::Token' ))
$t->getString eq "+" or $t->getString eq "-" or $t->equals(bless( [" ",10], 'LaTeXML::Core::Token' ))
$t->getString eq "+" or $t->getString eq "-"
MC/DC0%0/4
defined($t = $self->readXToken(0)) and $t->getString eq "+" || $t->getString eq "-" || $t->equals(bless( [" ",10], 'LaTeXML::Core::Token' ))
defined($t = $self->readXToken(0))
$t->getString eq "+"
$t->getString eq "-"
$t->equals(bless( [" ",10], 'LaTeXML::Core::Token' ))
Truth table0%0/5
A and B or C or D
A= defined($t = $self->readXToken(0))B= $t->getString eq "+"C= $t->getString eq "-"D= $t->equals(bless( [" ",10], 'LaTeXML::Core::Token' ))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | && (($t->getString eq '+') || ($t->getString eq '-') || ($t->equals(T_SPACE)))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | $sign = -$sign if ($t->getString eq '-'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | unshift(@{ $$self{pushback} }, $t) if $t; # Unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return $sign; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | sub readDigits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | my ($self, $range, $skip) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readDigits: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my ($token, $digit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | while (($token = $self->readXToken(0)) && (($digit = $token->getString) =~ /^[$range]$/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token = $self->readXToken(0) and ($digit = $token->getString) =~ /^[$range]$/
MC/DC0%0/2
$token = $self->readXToken(0) and ($digit = $token->getString) =~ /^[$range]$/
$token = $self->readXToken(0)
($digit = $token->getString) =~ /^[$range]$/
Truth table0%0/3
A and B
A= $token = $self->readXToken(0)B= ($digit = $token->getString) =~ /^[$range]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $string .= $digit; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token && !($skip && $$token[1] == CC_SPACE); # Inline ->getCatcode, unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$token and not $skip && $token->[1] == 10
$skip && $token->[1] == 10
MC/DC0%0/3
$token and not $skip && $token->[1] == 10
$token
$skip
$token->[1] == 10
Truth table0%0/4
A and not(B && C)
A= $tokenB= $skipC= $token->[1] == 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return $string; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # <factor> = <normal integer> | <decimal constant> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # <decimal constant> = . | , | <digit><decimal constant> | <decimal constant><digit> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # Return a number (perl number) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | sub readFactor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readFactor: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $string = $self->readDigits('0-9'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $token = $self->readXToken(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if ($token && $token->getString =~ /^[\.\,]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->getString =~ /^[\.\,]$/
MC/DC0%0/2
$token and $token->getString =~ /^[\.\,]$/
$token
$token->getString =~ /^[\.\,]$/
Truth table0%0/3
A and B
A= $tokenB= $token->getString =~ /^[\.\,]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $string .= '.' . $self->readDigits('0-9'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $token = $self->readXToken(0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if (length($string) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token && $$token[1] != CC_SPACE; # Inline ->getCatcode, unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->[1] != 10
MC/DC0%0/2
$token and $token->[1] != 10
$token
$token->[1] != 10
Truth table0%0/3
A and B
A= $tokenB= $token->[1] != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return $string; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | unshift(@{ $$self{pushback} }, $token); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my $n = $self->readNormalInteger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | return (defined $n ? $n->valueOf : undef); } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Integer, Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # <number> = <optional signs><unsigned number> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # <unsigned number> = <normal integer> | <coerced integer> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # <coerced integer> = <internal dimen> | <internal glue> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | sub readNumber { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readNumber: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if (defined(my $n = $self->readNormalInteger)) { return ($s < 0 ? $n->negate : $n); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | elsif (defined($n = $self->readInternalDimension)) { return Number($s * $n->valueOf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | elsif (defined($n = $self->readInternalGlue)) { return Number($s * $n->valueOf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $next = $self->readToken(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | unshift(@{ $$self{pushback} }, $next); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | Warn('expected', '<number>', $self, "Missing number, treated as zero", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | "while processing " . ToString($LaTeXML::CURRENT_TOKEN), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | "next token is " . ToString($next)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return Number(0); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # <normal integer> = <internal integer> | <integer constant> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # | '<octal constant><one optional space> | "<hexadecimal constant><one optional space> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # | `<character token><one optional space> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # Return a Number or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | sub readNormalInteger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readNormalInteger: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my $token = $self->readXToken(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | if (!defined $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | ▶ | elsif (($$token[1] == CC_OTHER) && ($token->getString =~ /^[0-9]$/)) { # Read decimal literal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$token->[1] == 12 and $token->getString =~ /^[0-9]$/
MC/DC0%0/2
$token->[1] == 12 and $token->getString =~ /^[0-9]$/
$token->[1] == 12
$token->getString =~ /^[0-9]$/
Truth table0%0/3
A and B
A= $token->[1] == 12B= $token->getString =~ /^[0-9]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return Number(int($token->getString . $self->readDigits('0-9', 1))); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | elsif ($token->equals(T_OTHER("\'"))) { # Read Octal literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | return Number(oct($self->readDigits('0-7', 1))); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | elsif ($token->equals(T_OTHER("\""))) { # Read Hex literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | return Number(hex($self->readDigits('0-9A-F', 1))); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | elsif ($token->equals(T_OTHER("\`"))) { # Read Charcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $next = $self->readToken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | my $s = ($next && $next->getString) || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$next && $next->getString || ''
$next and $next->getString
MC/DC0%0/2
$next && $next->getString || ''
$next
$next->getString
Truth table0%0/3
A and B
A= $nextB= $next->getString
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $s =~ s/^\\//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | return Number(ord($s)); } # Only a character token!!! NOT expanded!!!! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | unshift(@{ $$self{pushback} }, $token); # Unread | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | return $self->readInternalInteger; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | sub readInternalInteger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readInternalInteger: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | return $self->readRegisterValue('Number'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | # Float, a floating point number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # Similar to factor, but does NOT accept comma! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # This is NOT part of TeX, but is convenient. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | sub readFloat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readFloat: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | my $string = $self->readDigits('0-9'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my $token = $self->readXToken(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | if ($token && $token->getString =~ /^[\.]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->getString =~ /^[\.]$/
MC/DC0%0/2
$token and $token->getString =~ /^[\.]$/
$token
$token->getString =~ /^[\.]$/
Truth table0%0/3
A and B
A= $tokenB= $token->getString =~ /^[\.]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | $string .= '.' . $self->readDigits('0-9'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $token = $self->readXToken(0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | if (length($string) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token && $$token[1] != CC_SPACE; # Inline ->getCatcode, unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->[1] != 10
MC/DC0%0/2
$token and $token->[1] != 10
$token
$token->[1] != 10
Truth table0%0/3
A and B
A= $tokenB= $token->[1] != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $n = $string; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | unshift(@{ $$self{pushback} }, $token) if $token; # Unread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $n = $self->readNormalInteger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | $n = $n->valueOf if defined $n; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | return (defined $n ? Float($s * $n) : undef); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # Dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # <dimen> = <optional signs><unsigned dimen> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # <unsigned dimen> = <normal dimen> | <coerced dimen> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # <coerced dimen> = <internal glue> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | sub readDimension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readDimension: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if (defined(my $d = $self->readInternalDimension)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | return ($s < 0 ? $d->negate : $d); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | elsif (defined($d = $self->readInternalGlue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | return Dimension($s * $d->valueOf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | elsif (defined($d = $self->readFactor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $unit = $self->readUnit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if (!defined $unit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | Warn('expected', '<unit>', $self, "Illegal unit of measure (pt inserted)."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $unit = 65536; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return Dimension($s * $d * $unit); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | Warn('expected', '<number>', $self, "Missing number, treated as zero.", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | "while processing " . ToString($LaTeXML::CURRENT_TOKEN)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | return Dimension(0); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # <unit of measure> = <optional spaces><internal unit> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # | <optional true><physical unit><one optional space> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # <internal unit> = em <one optional space> | ex <one optional space> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # | <internal integer> | <internal dimen> | <internal glue> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # <physical unit> = pt | pc | in | bp | cm | mm | dd | cc | sp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # Read a unit, returning the equivalent number of scaled points, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | sub readUnit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readUnit: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | if (defined(my $u = $self->readKeyword('ex', 'em'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $self->skip1Space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | return $STATE->convertUnit($u); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | elsif (defined($u = $self->readInternalInteger)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return $u->valueOf; } # These are coerced to number=>sp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | elsif (defined($u = $self->readInternalDimension)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | return $u->valueOf; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | elsif (defined($u = $self->readInternalGlue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | return $u->valueOf; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->readKeyword('true'); # But ignore, we're not bothering with mag... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | my $units = $STATE->lookupValue('UNITS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $u = $self->readKeyword(keys %$units); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | if ($u) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $self->skip1Space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return $STATE->convertUnit($u); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | return; } } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | # Return a dimension value or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | sub readInternalDimension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readInternalDimension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | return $self->readRegisterValue('Dimension'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # Mu Dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # <mudimen> = <optional signs><unsigned mudimem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # <unsigned mudimen> = <normal mudimen> | <coerced mudimen> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # <normal mudimen> = <factor><mu unit> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # <mu unit> = <optional spaces><internal muglue> | mu <one optional space> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # <coerced mudimen> = <internal muglue> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | sub readMuDimension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMuDimension: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | if (defined(my $m = $self->readFactor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my $munit = $self->readMuUnit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if (!defined $munit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | Warn('expected', '<unit>', $self, "Illegal unit of measure (mu inserted)."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $munit = $STATE->convertUnit('mu'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | return MuDimension($s * $m * $munit); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | elsif (defined($m = $self->readInternalMuGlue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | return MuDimension($s * $m->valueOf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | Warn('expected', '<mudimen>', $self, "Expecting mudimen; assuming 0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | return MuDimension(0); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | sub readMuUnit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMuUnit: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | if (my $m = $self->readKeyword('mu')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $self->skip1Space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | return $STATE->convertUnit($m); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | elsif ($m = $self->readInternalMuGlue) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | return $m->valueOf; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | return; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | # Glue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # <glue> = <optional signs><internal glue> | <dimen><stretch><shrink> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | # <stretch> = plus <dimen> | plus <fil dimen> | <optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # <shrink> = minus <dimen> | minus <fil dimen> | <optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | sub readGlue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readGlue: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | if (defined($n = $self->readInternalGlue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | return ($s < 0 ? $n->negate : $n); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my $d = $self->readDimension; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if (!$d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | Warn('expected', '<number>', $self, "Missing number, treated as zero.", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | "while processing " . ToString($LaTeXML::CURRENT_TOKEN)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | return Glue(0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | $d = $d->negate if $s < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my ($r1, $f1, $r2, $f2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | ($r1, $f1) = $self->readRubber if $self->readKeyword('plus'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | ($r2, $f2) = $self->readRubber if $self->readKeyword('minus'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | return Glue($d->valueOf, $r1, $f1, $r2, $f2); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 4 | my %FILLS = (fil => 1, fill => 2, filll => 3); # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | sub readRubber { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | my ($self, $mu) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readRubber: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my $f = $self->readFactor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | if (!defined $f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | $f = ($mu ? $self->readMuDimension : $self->readDimension); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | return ($f->valueOf * $s, 0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | elsif (defined(my $fil = $self->readKeyword('filll', 'fill', 'fil'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | return ($s * $f, $FILLS{$fil}); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | elsif ($mu) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | my $u = $self->readMuUnit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if (!defined $u) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | Warn('expected', '<unit>', $self, "Illegal unit of measure (mu inserted)."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $u = $STATE->convertUnit('mu'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | return ($s * $f * $u, 0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my $u = $self->readUnit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | if (!defined $u) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | Warn('expected', '<unit>', $self, "Illegal unit of measure (pt inserted)."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $u = 65536; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | return ($s * $f * $u, 0); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | # Return a glue value or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | sub readInternalGlue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readInternalGlue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | return $self->readRegisterValue('Glue'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | # Mu Glue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # <muglue> = <optional signs><internal muglue> | <mudimen><mustretch><mushrink> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # <mustretch> = plus <mudimen> | plus <fil dimen> | <optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # <mushrink> = minus <mudimen> | minus <fil dimen> | <optional spaces> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | sub readMuGlue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMuGlue: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my $s = $self->readOptionalSigns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | if (defined($n = $self->readInternalMuGlue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | return ($s < 0 ? $n->negate : $n); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $d = $self->readMuDimension; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | if (!$d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | Warn('expected', '<number>', $self, "Missing number, treated as zero.", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | "while processing " . ToString($LaTeXML::CURRENT_TOKEN)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | return MuGlue(0); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | $d = $d->negate if $s < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | my ($r1, $f1, $r2, $f2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | ($r1, $f1) = $self->readRubber(1) if $self->readKeyword('plus'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | ($r2, $f2) = $self->readRubber(1) if $self->readKeyword('minus'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | return MuGlue($d->valueOf, $r1, $f1, $r2, $f2); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | # Return a muglue value or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | sub readInternalMuGlue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readInternalMuGlue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | return $self->readRegisterValue('MuGlue'); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | # See pp 272-275 for lists of the various registers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # These are implemented in Primitive.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | #********************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||