lib/LaTeXML/Core/Gullet.pm

filter: Statementstmt 8.3% 54 / 645 Branchbran 0.0% 0 / 384 Conditioncond 0.0% 0 / 220 MC/DCmcdc 0.0% 0 / 118 Subroutinesub 22.8% 16 / 70 Podpod 44.4% 24 / 54 totaltotal 6.3% 94 / 1491 CC 274 SCAR 56.0
CC
274
Cov
4%
readXToken
1640.0
readUntil
420.0
readToken
306.0
CRAP 270.5
« lib/LaTeXML/Post/CrossRef.pm ↑ Summary lib/LaTeXML/Post/LaTeXImages.pm »
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 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use LaTeXML::Common::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use LaTeXML::Core::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use LaTeXML::Core::Tokens;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use LaTeXML::Core::Mouth;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use LaTeXML::Util::Pathname;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use LaTeXML::Common::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use LaTeXML::Common::Float;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 5 ▶use LaTeXML::Common::Dimension;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use LaTeXML::Common::Glue;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use LaTeXML::Core::MuDimension;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use LaTeXML::Core::MuGlue;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 ▶use base qw(LaTeXML::Common::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 #**********************************************************************
31 sub new {
32 0 ▶ my ($class, %options) = @_;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
33 return bless {
34 mouth => undef, mouthstack => [], pushback => [], autoclose => 1, pending_comments => [],
35 0 ▶ verbosity => $options{verbosity} || 0,
Condition0%0/2
$options{'verbosity'} || 0
l!l
00
MC/DC0%0/1
$options{'verbosity'} || 0
$options{'verbosity'}
Truth table0%0/2
A
A= $options{'verbosity'}
Aresult
11
00
36 progress => 0,
37 }, $class; }
38  
39 5 our $TOKEN_PROGRESS_QUANTUM = 30000;
40  
41 #**********************************************************************
42 # Start reading tokens from a new Mouth.
43 # This pushes the mouth as the current source that $gullet->readToken (etc) will read from.
44 # Once this Mouth has been exhausted, readToken, etc, will return undef,
45 # until you call $gullet->closeMouth to clear the source.
46 # Exception: if $toplevel=1, readXToken will step to next source
47 # Note that a Tokens can act as a Mouth.
48 sub openMouth {
49 0 ▶ my ($self, $mouth, $noautoclose) = @_;
Subroutine openMouth: not called CC=3 SCAR=24.8
Pod documented
50 0 ▶ return unless $mouth;
Branch: 1 branch
BranchTrueFalseTotal
unless $mouth 0 0 0
51 0 ▶ unshift(@{ $$self{mouthstack} }, [$$self{mouth}, $$self{pushback}, $$self{autoclose}]) if $$self{mouth};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"mouth"} 0 0 0
52 0 $$self{mouth} = $mouth;
53 0 $$self{pushback} = [];
54 0 $$self{autoclose} = !$noautoclose;
55 0 return; }
56  
57 sub closeMouth {
58 0 ▶ my ($self, $forced) = @_;
Subroutine closeMouth: not called CC=5 SCAR=34.0
Pod documented
59 0 ▶ if (!$forced && (@{ $$self{pushback} } || $$self{mouth}->hasMoreInput)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $forced and @{$self->{"pushback"};} || $self->{"mouth"}->hasMoreInput) 0 0 0
Condition0%0/6
not $forced and @{$self->{"pushback"};} || $self->{"mouth"}->hasMoreInput
!ll&&!rl&&r
000
@{$self->{"pushback"};} or $self->{"mouth"}->hasMoreInput
l!l&&r!l&&!r
000
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
ABCresult
0XX0
1000
11X1
1011
60 0 my $next = Stringify($self->readToken);
61 0 Error('unexpected', $next, $self, "Closing mouth with input remaining '$next'"); }
62 0 $$self{mouth}->finish;
63 0 ▶ if (@{ $$self{mouthstack} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'mouthstack'};}) { } 0 0 0
64 0 ($$self{mouth}, $$self{pushback}, $$self{autoclose}) = @{ shift(@{ $$self{mouthstack} }) }; }
65 else {
66 0 $$self{pushback} = [];
67 0 $$self{mouth} = LaTeXML::Core::Mouth->new();
68 0 $$self{autoclose} = 1; }
69 0 return; }
70  
71 sub getMouth {
72 0 ▶ my ($self) = @_;
Subroutine getMouth: not called CC=1 SCAR=6.9
Pod undocumented
73 0 return $$self{mouth}; }
74  
75 sub mouthIsOpen {
76 0 ▶ my ($self, $mouth) = @_;
Subroutine mouthIsOpen: not called CC=3 SCAR=24.8
Pod undocumented
77 return ($$self{mouth} eq $mouth)
78 0 ▶ || grep { $_ && ($$_[0] eq $mouth) } @{ $$self{mouthstack} }; }
Branch: 1 branch
BranchTrueFalseTotal
$_ and $_->[0] eq $mouth 0 0 0
Condition0%0/3
$self->{'mouth'} eq $mouth || grep({$_ and $_->[0] eq $mouth;} @{$$self{'mouthstack'};})
l!l&&r!l&&!r
000
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'};})
ABresult
1X1
011
000
79  
80 # This flushes a mouth so that it will be automatically closed, next time it's read
81 # Corresponds to TeX's \endinput
82 sub flushMouth {
83 0 ▶ my ($self) = @_;
Subroutine flushMouth: not called CC=2 SCAR=17.9
Pod undocumented
84 0 my $mouth = $$self{mouth};
85 # Put the remainder of Mouth's current line at the END of the pushback stack, to be read
86 0 ▶ while (!$mouth->isEOL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mouth->isEOL) 0 0 0
87 0 push(@{ $$self{pushback} }, $mouth->readToken); }
88 0 $mouth->finish; # then finish the mouth (it'll get closed on next read)
89 0 return; }
90  
91 # Obscure, but the only way I can think of to End!! (see \bye or \end{document})
92 # Flush all sources (close all pending mouth's)
93 sub flush {
94 0 ▶ my ($self) = @_;
Subroutine flush: not called CC=2 SCAR=17.9
Pod documented
95 0 $$self{mouth}->finish;
96 0 ▶ while (@{ $$self{mouthstack} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"mouthstack"};}) 0 0 0
97 0 my $entry = shift @{ $$self{mouthstack} };
98 0 $$entry[0]->finish; }
99 0 $$self{pushback} = [];
100 0 $$self{mouth} = LaTeXML::Core::Mouth->new();
101 0 $$self{mouthstack} = [];
102 0 return; }
103  
104 sub setup_scan {
105 0 ▶ my ($self) = @_;
Subroutine setup_scan: not called CC=4 SCAR=30.0
Pod undocumented
106 0 ▶ if ($$self{pushback_has_smuggled_the}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pushback_has_smuggled_the"}) 0 0 0
107 0 $$self{pushback_has_smuggled_the} = 0;
108 # setup new scan by removing any smuggle CCs
109 0 for my $token (@{ $$self{pushback} }) {
110 0 ▶ if ($$token[1] == CC_SMUGGLE_THE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] == 19) 0 0 0
111 0 $token = $$token[2]; } } }
112 0 return; }
113  
114 # Do something, while reading stuff from a specific Mouth.
115 # This reads ONLY from that mouth (or any mouth openned by code in that source),
116 # and the mouth should end up empty afterwards, and only be closed here.
117 sub readingFromMouth {
118 0 ▶ my ($self, $mouth, $closure) = @_;
Subroutine readingFromMouth: not called CC=8 SCAR=42.8
Pod undocumented
119 0 $self->openMouth($mouth, 1); # only allow mouth to be explicitly closed here.
120 0 my ($result, @result);
121 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
122 0 @result = &$closure($self); }
123 else {
124 0 $result = &$closure($self); }
125 # $mouth must still be open, with (at worst) empty autoclosable mouths in front of it
126 0 while (1) {
127 0 ▶ if ($$self{mouth} eq $mouth) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'mouth'} eq $mouth) { } 0 0 0
elsif (not @{$self->{'mouthstack'};}) { } 0 0 0
elsif (not $self->{'autoclose'} or @{$self->{'pushback'};} or $self->{'mouth'}->hasMoreInput) { } 0 0 0
128 0 $self->closeMouth(1); last; }
129 0 elsif (!@{ $$self{mouthstack} }) {
130 0 Error('unexpected', '<closed>', $self, "Mouth is unexpectedly already closed",
131 0 "Reading from " . Stringify($mouth) . ", but it has already been closed."); last; }
132 0 ▶ elsif (!$$self{autoclose} || @{ $$self{pushback} } || $$self{mouth}->hasMoreInput) {
Condition0%0/6
not $self->{"autoclose"} or @{$self->{"pushback"};} or $self->{"mouth"}->hasMoreInput
l!l&&r!l&&!r
000
not $self->{"autoclose"} or @{$self->{"pushback"};}
l!l&&r!l&&!r
000
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
ABCresult
1XX1
01X1
0011
0000
133 0 my $next = Stringify($self->readToken);
134 0 Error('unexpected', $next, $self, "Unexpected input remaining: '$next'",
135 "Finished reading from " . Stringify($mouth) . ", but it still has input.");
136 0 $$self{mouth}->finish;
137 0 $self->closeMouth(1); } # ?? if we continue?
138 else {
139 0 $self->closeMouth; } }
140 0 ▶ return (wantarray ? @result : $result); }
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
141  
142 # User feedback for where something (error?) occurred.
143 sub getLocator {
144 0 ▶ my ($self) = @_;
Subroutine getLocator: not called CC=8 SCAR=42.8
Pod documented
145 0 my $mouth = $$self{mouth};
146 0 my $i = 0;
147 0 ▶ while ((defined $mouth) && (!defined $$mouth{source})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mouth and not defined $mouth->{"source"} and $i < scalar @{$self->{"mouthstack"};}) 0 0 0
Condition0%0/6
defined $mouth and not defined $mouth->{"source"} and $i < scalar @{$self->{"mouthstack"};}
!ll&&!rl&&r
000
defined $mouth and not defined $mouth->{"source"}
!ll&&!rl&&r
000
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"};}
ABCresult
0XX0
10X0
1100
1111
148 0 && ($i < scalar(@{ $$self{mouthstack} }))) {
149 0 $mouth = $$self{mouthstack}[$i++][0]; }
150 0 ▶ my $loc = (defined $mouth ? $mouth->getLocator : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $mouth ? : 0 0 0
151 0 ▶ return $loc if defined $loc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $loc 0 0 0
152 0 foreach my $frame (@{ $$self{mouthstack} }) {
153 0 my $ml = $$frame[0]->getLocator;
154 0 ▶ return $ml if defined $ml; }
Branch: 1 branch
BranchTrueFalseTotal
if defined $ml 0 0 0
155 0 return; }
156  
157 sub getSource {
158 0 ▶ my ($self) = @_;
Subroutine getSource: not called CC=5 SCAR=34.0
Pod undocumented
159 0 ▶ my $source = defined $$self{mouth} && $$self{mouth}->getSource;
Condition0%0/3
defined $self->{'mouth'} && $self->{'mouth'}->getSource
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
160 0 ▶ if (!defined($source)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source) 0 0 0
161 0 foreach my $frame (@{ $$self{mouthstack} }) {
162 0 $source = $$frame[0]->getSource;
163 0 ▶ last if defined($source); } }
Branch: 1 branch
BranchTrueFalseTotal
if defined $source 0 0 0
164 0 return $source; }
165  
166 sub getSourceMouth {
167 0 ▶ my ($self) = @_;
Subroutine getSourceMouth: not called CC=5 SCAR=34.0
Pod undocumented
168 0 my $mouth = $$self{mouth};
169 0 ▶ my $source = defined $mouth && $mouth->getSource;
Condition0%0/3
defined $mouth && $mouth->getSource
!ll&&!rl&&r
000
MC/DC0%0/2
defined $mouth && $mouth->getSource
defined $mouth $mouth->getSource
Truth table0%0/3
A && B
A= defined $mouthB= $mouth->getSource
ABresult
0X0
100
111
170 0 ▶ if (!defined($source)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source) 0 0 0
171 0 foreach my $frame (@{ $$self{mouthstack} }) {
172 0 $mouth = $$frame[0];
173 0 $source = $mouth->getSource;
174 0 ▶ last if defined($source); } }
Branch: 1 branch
BranchTrueFalseTotal
if defined $source 0 0 0
175 0 return $mouth; }
176  
177 # Handy message generator when we didn't get something expected.
178 sub showUnexpected {
179 0 ▶ my ($self) = @_;
Subroutine showUnexpected: not called CC=3 SCAR=24.8
Pod undocumented
180 0 my $message = "Input is empty";
181 0 ▶ if (my $token = $self->readToken) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $self->readToken) 0 0 0
182 0 my @pb = @{ $$self{pushback} };
183 0 ▶ $message = "Next token is " . Stringify($token)
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 0 0 0
184 . " ( == " . Stringify($STATE->lookupMeaning($token)) . ")"
185 . (@pb ? " more: " . ToString(Tokens(@pb)) : '');
186 0 unshift(@{ $$self{pushback} }, $token);
187 }
188 0 return $message; }
189  
190 sub show_pushback {
191 0 ▶ my ($pb) = @_;
Subroutine show_pushback: not called CC=3 SCAR=24.8
Pod undocumented
192 0 my @pb = @$pb;
193 0 ▶ @pb = (@pb[0 .. 50], T_OTHER('...')) if scalar(@pb) > 55;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @pb > 55 0 0 0
194 0 ▶ return (@pb ? "\n To be read again " . ToString(Tokens(@pb)) : ''); }
Branch: 1 branch
BranchTrueFalseTotal
@pb ? : 0 0 0
195  
196 #**********************************************************************
197 # Low-level readers: read token, read expanded token
198 #**********************************************************************
199 # Note that every char (token) comes through here (maybe even twice, through args parsing),
200 # So, be Fast & Clean! This method only reads from the current input stream (Mouth).
201 5 our @CATCODE_HOLD = (
202 0, 0, 0, 0,
203 0, 0, 0, 0,
204 0, 0, 0, 0,
205 0, 0, 1, 0,
206 0, 1, 0, 0);
207  
208 sub handleMarker {
209 0 ▶ my ($self, $markertoken) = @_;
Subroutine handleMarker: not called CC=6 SCAR=37.4
Pod undocumented
210 0 my $arg = $$markertoken[0];
211 0 ▶ if (ref $arg) {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $arg) { } 0 0 0
elsif ($arg eq 'before-column') { } 0 0 0
elsif ($arg eq 'after-column') { } 0 0 0
212 0 LaTeXML::Core::Definition::stopProfiling($markertoken, 'expand'); }
213 elsif ($arg eq 'before-column') { # Were in before-column template
214 0 my $alignment = $STATE->lookupValue('Alignment');
215 0 ▶ Debug("Halign $alignment: alignment state => 0") if $LaTeXML::DEBUG{halign};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"halign"} 0 0 0
216 0 $LaTeXML::ALIGN_STATE = 0; } # switch to column proper!
217 elsif ($arg eq 'after-column') { # Were in before-column template
218 0 my $alignment = $STATE->lookupValue('Alignment');
219 0 ▶ Debug("Halign $alignment: alignment state: after column") if $LaTeXML::DEBUG{halign};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"halign"} 0 0 0
220 }
221 0 return; }
222  
223 sub handleTemplate {
224 0 ▶ my ($self, $alignment, $token, $type, $hidden) = @_;
Subroutine handleTemplate: not called CC=10 SCAR=47.0
Pod undocumented
225 Debug("Halign $alignment: ALIGNMENT Column ended at " . Stringify($token)
226 . " type $type [" . Stringify($STATE->lookupMeaning($token)) . "]"
227 . "@ " . ToString($self->getLocator))
228 0 ▶ if $LaTeXML::DEBUG{halign};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"halign"} 0 0 0
229 # Append expansion to end!?!?!?!
230 0 local $LaTeXML::CURRENT_TOKEN = $token;
231 0 my $post = $alignment->getColumnAfter;
232 0 $LaTeXML::ALIGN_STATE = 1000000;
233 ### NOTE: Truly fishy smuggling w/ \hidden@cr
234 0 my $arg;
235 0 ▶ if (($type eq 'cr') && $hidden) { # \hidden@cr gets an argument as payload!!!!!
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "cr" and $hidden) 0 0 0
Condition0%0/3
$type eq "cr" and $hidden
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq "cr" and $hidden
$type eq "cr" $hidden
Truth table0%0/3
A and B
A= $type eq "cr"B= $hidden
ABresult
0X0
100
111
236 0 $arg = $self->readArg(); }
237 0 ▶ Debug("Halign $alignment: column after " . ToString($post)) if $LaTeXML::DEBUG{halign};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"halign"} 0 0 0
238 0 ▶ if ((($type eq 'cr') || ($type eq 'crcr'))
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "cr" || $type eq "crcr" and $alignment->{"in_row"} and not $alignment->currentRow->{"pseudorow"}) 0 0 0
Condition0%0/9
$type eq "cr" || $type eq "crcr" and $alignment->{"in_row"} and not $alignment->currentRow->{"pseudorow"}
!ll&&!rl&&r
000
$type eq "cr" || $type eq "crcr" and $alignment->{"in_row"}
!ll&&!rl&&r
000
$type eq "cr" or $type eq "crcr"
l!l&&r!l&&!r
000
MC/DC0%0/4
$type eq "cr" || $type eq "crcr" and $alignment->{"in_row"} and not $alignment->currentRow->{"pseudorow"}
$type eq "cr" $type eq "crcr" $alignment->{"in_row"} not $alignment->currentRow->{"pseudorow"}
Truth table0%0/7
A or B and C and not(D)
A= $type eq "cr"B= $type eq "crcr"C= $alignment->{"in_row"}D= not $alignment->currentRow->{"pseudorow"}
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
239 && $$alignment{in_row} && !$alignment->currentRow->{pseudorow}) {
240 0 unshift(@{ $$self{pushback} }, T_CS('\@row@after')); }
241 0 ▶ if ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
242 0 unshift(@{ $$self{pushback} }, T_BEGIN, $arg->unlist, T_END); }
243 0 unshift(@{ $$self{pushback} }, $token);
244 0 unshift(@{ $$self{pushback} }, $post->unlist);
245 0 return; }
246  
247 # If it is a column ending token, Returns the token, a keyword and whether it is "hidden"
248 5 our @column_ends = (
249 [T_ALIGN, 'align', 0],
250 [T_CS('\cr'), 'cr', 0],
251 [T_CS('\crcr'), 'crcr', 0],
252 [T_CS('\hidden@cr'), 'cr', 1],
253 [T_CS('\hidden@crcr'), 'crcr', 1],
254 [T_CS('\hidden@align'), 'insert', 1],
255 [T_CS('\span'), 'span', 0]);
256  
257 sub isColumnEnd {
258 0 ▶ my ($self, $token) = @_;
Subroutine isColumnEnd: not called CC=7 SCAR=40.3
Pod undocumented
259 0 my $cc = $$token[1];
260 0 ▶ return unless ($cc == CC_ALIGN) || ($cc == CC_CS);
Branch: 1 branch
BranchTrueFalseTotal
unless $cc == 4 or $cc == 16 0 0 0
Condition0%0/3
$cc == 4 or $cc == 16
l!l&&r!l&&!r
000
MC/DC0%0/2
$cc == 4 or $cc == 16
$cc == 4 $cc == 16
Truth table0%0/3
A or B
A= $cc == 4B= $cc == 16
ABresult
1X1
011
000
261 # Embedded version of Equals, knowing both are tokens
262 0 ▶ my $defn = $STATE->lookupMeaning($token) || $token;
Condition0%0/3
$LaTeXML::Core::Gullet::STATE->lookupMeaning($token) || $token
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Core::Gullet::STATE->lookupMeaning($token) || $token
$LaTeXML::Core::Gullet::STATE->lookupMeaning($token) $token
Truth table0%0/3
A || B
A= $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)B= $token
ABresult
1X1
011
000
263 0 foreach my $end (@column_ends) {
264 0 my $e = $$end[0];
265 # Would be nice to cache the defns, but don't know when they're present & constant!
266 0 ▶ return @$end if $defn->equals($STATE->lookupMeaning($e) || $e); }
Branch: 1 branch
BranchTrueFalseTotal
if $defn->equals($LaTeXML::Core::Gullet::STATE->lookupMeaning($e) || $e) 0 0 0
Condition0%0/3
$LaTeXML::Core::Gullet::STATE->lookupMeaning($e) || $e
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Core::Gullet::STATE->lookupMeaning($e) || $e
$LaTeXML::Core::Gullet::STATE->lookupMeaning($e) $e
Truth table0%0/3
A || B
A= $LaTeXML::Core::Gullet::STATE->lookupMeaning($e)B= $e
ABresult
1X1
011
000
267 0 return; }
268  
269 sub readToken {
270 0 ▶ my ($self) = @_;
Subroutine readToken: not called CC=17 SCAR=57.2
Pod documented
271 # my $token = shift(@{$$self{pushback}});
272 0 my ($token, $cc, $atoken, $atype, $ahidden);
273 0 while (1) {
274 0 ▶ while (($token = shift(@{ $$self{pushback} }))
Branch: 1 branch
BranchTrueFalseTotal
if ($token = shift @{$$self{"pushback"};} and $token->[1] != 19 || ($token = $token->[2]) and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]) 0 0 0
Condition0%0/9
$token = shift @{$$self{"pushback"};} and $token->[1] != 19 || ($token = $token->[2]) and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
!ll&&!rl&&r
000
$token = shift @{$$self{"pushback"};} and $token->[1] != 19 || ($token = $token->[2])
!ll&&!rl&&r
000
$token->[1] != 19 or $token = $token->[2]
l!l&&r!l&&!r
000
MC/DC0%0/4
$token = shift @{$$self{"pushback"};} and $token->[1] != 19 || ($token = $token->[2]) and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
$token = shift @{$$self{"pushback"};} $token->[1] != 19 $token = $token->[2] $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
Truth table0%0/6
A and B or C and D
A= $token = shift @{$$self{"pushback"};}B= $token->[1] != 19C= $token = $token->[2]D= $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
275 && (($$token[1] != CC_SMUGGLE_THE) || ($token = $$token[2]))
276 && $CATCODE_HOLD[$cc = $$token[1]]) {
277 0 ▶ if ($cc == CC_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cc == 14) { } 0 0 0
elsif ($cc == 17) { } 0 0 0
278 0 push(@{ $$self{pending_comments} }, $token); }
279 elsif ($cc == CC_MARKER) {
280 0 $self->handleMarker($token); } }
281 # Not in pushback, use the current mouth
282 0 ▶ if (!defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $token) 0 0 0
283 0 ▶ while (($token = $$self{mouth}->readToken()) && $CATCODE_HOLD[$cc = $$token[1]]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]) 0 0 0
Condition0%0/3
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
$token = $self->{"mouth"}->readToken $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
Truth table0%0/3
A and B
A= $token = $self->{"mouth"}->readTokenB= $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
ABresult
0X0
100
111
284 0 ▶ if ($cc == CC_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cc == 14) { } 0 0 0
elsif ($cc == 17) { } 0 0 0
285 0 push(@{ $$self{pending_comments} }, $token); } # What to do with comments???
286 elsif ($cc == CC_MARKER) {
287 0 $self->handleMarker($token); } } }
288 0 ▶ ProgressStep() if ($$self{progress}++ % $TOKEN_PROGRESS_QUANTUM) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"progress"}++ % $LaTeXML::Core::Gullet::TOKEN_PROGRESS_QUANTUM == 0 0 0 0
289 # Wow!!!!! See TeX the Program \S 309
290 0 ▶ if ((defined $token)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)) { } 0 0 0
Condition0%0/9
defined $token and not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)
!ll&&!rl&&r
000
defined $token and not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT
!ll&&!rl&&r
000
defined $token and not $LaTeXML::ALIGN_STATE
!ll&&!rl&&r
000
MC/DC0%0/4
defined $token and not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)
defined $token not $LaTeXML::ALIGN_STATE $LaTeXML::READING_ALIGNMENT () = $self->isColumnEnd($token)
Truth table0%0/5
A and not(B) and C and D
A= defined $tokenB= not $LaTeXML::ALIGN_STATEC= $LaTeXML::READING_ALIGNMENTD= () = $self->isColumnEnd($token)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
291 && !$LaTeXML::ALIGN_STATE # SHOULD count nesting of { }!!! when SCANNED (not digested)
292 && $LaTeXML::READING_ALIGNMENT
293 && (($atoken, $atype, $ahidden) = $self->isColumnEnd($token))) {
294 0 $self->handleTemplate($LaTeXML::READING_ALIGNMENT, $token, $atype, $ahidden); }
295 else {
296 0 last; } }
297 0 return $token; }
298  
299 # Unread tokens are assumed to be not-yet expanded.
300 sub unread {
301 0 ▶ my ($self, @tokens) = @_;
Subroutine unread: not called CC=5 SCAR=34.0
Pod documented
302 0 my $r;
303 0 unshift(@{ $$self{pushback} },
304 0 ▶ map { (!defined $_ ? ()
Branch: 3 branches
BranchTrueFalseTotal
!defined($_) ? : 0 0 0
($r = ref $_) eq 'LaTeXML::Core::Token' ? : 0 0 0
$r eq 'LaTeXML::Core::Tokens' ? : 0 0 0
Condition0%0/3
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_)) or T_OTHER(Stringify($_))
l!l&&r!l&&!r
000
MC/DC0%0/2
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_)) or T_OTHER(Stringify($_))
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_)) T_OTHER(Stringify($_))
Truth table0%0/3
A or B
A= Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_))B= T_OTHER(Stringify($_))
ABresult
1X1
011
000
305 : (($r = ref $_) eq 'LaTeXML::Core::Token' ? $_
306 : ($r eq 'LaTeXML::Core::Tokens' ? @$_
307 : Error('misdefined', $r, undef, "Expected a Token, got " . Stringify($_)) || T_OTHER(Stringify($_))))) }
308 @tokens);
309 0 return; }
310  
311 # Read the next non-expandable token (expanding tokens until there's a non-expandable one).
312 # Note that most tokens pass through here, so be Fast & Clean! readToken is folded in.
313 # `Toplevel' processing, (if $toplevel is true), used at the toplevel processing by Stomach,
314 # will step to the next input stream (Mouth) if one is available,
315 # If $commentsok is true, will also pass comments.
316 # $toplevel is doing TWO distinct things. When true:
317 # * If a mouth is exhausted, move on to the containing mouth to continue reading
318 # * expand even protected defns, essentially this means expand "for execution"
319 sub readXToken {
320 0 ▶ my ($self, $toplevel, $commentsok) = @_;
Subroutine readXToken: not called CC=40 SCAR=74.0
Pod documented
321 0 ▶ $toplevel = 1 unless defined $toplevel;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $toplevel 0 0 0
322 0 my $autoclose = $toplevel; # Potentially, these should have distinct controls?
323 0 my $for_evaluation = $toplevel;
324 0 ▶ return shift(@{ $$self{pending_comments} }) if $commentsok && @{ $$self{pending_comments} };
Branch: 1 branch
BranchTrueFalseTotal
if $commentsok and @{$self->{"pending_comments"};} 0 0 0
Condition0%0/3
$commentsok and @{$self->{"pending_comments"};}
!ll&&!rl&&r
000
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"};}
ABresult
0X0
100
111
325 0 my ($token, $cc, $defn, $atoken, $atype, $ahidden);
326 0 while (1) {
327 # NOTE: CC_SMUGGLE_THE should ONLY appear in pushback!
328 0 ▶ while (($token = shift(@{ $$self{pushback} })) && $CATCODE_HOLD[$cc = $$token[1]]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = shift @{$$self{"pushback"};} and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]) 0 0 0
Condition0%0/3
$token = shift @{$$self{"pushback"};} and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
$token = shift @{$$self{"pushback"};} and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
$token = shift @{$$self{"pushback"};} $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
Truth table0%0/3
A and B
A= $token = shift @{$$self{"pushback"};}B= $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
ABresult
0X0
100
111
329 0 ▶ if ($cc == CC_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cc == 14) { } 0 0 0
elsif ($cc == 17) { } 0 0 0
330 0 ▶ return $token if $commentsok;
Branch: 1 branch
BranchTrueFalseTotal
if $commentsok 0 0 0
331 0 push(@{ $$self{pending_comments} }, $token); }
332 elsif ($cc == CC_MARKER) {
333 0 $self->handleMarker($token); } }
334 0 ▶ if (!defined $token) { # Else read from current mouth
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $token) 0 0 0
335 0 ▶ while (($token = $$self{mouth}->readToken()) && $CATCODE_HOLD[$cc = $$token[1]]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]) 0 0 0
Condition0%0/3
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
$token = $self->{"mouth"}->readToken and $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
$token = $self->{"mouth"}->readToken $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
Truth table0%0/3
A and B
A= $token = $self->{"mouth"}->readTokenB= $LaTeXML::Core::Gullet::CATCODE_HOLD[$cc = $token->[1]]
ABresult
0X0
100
111
336 0 ▶ if ($cc == CC_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cc == 14) { } 0 0 0
elsif ($cc == 17) { } 0 0 0
337 0 ▶ return $token if $commentsok;
Branch: 1 branch
BranchTrueFalseTotal
if $commentsok 0 0 0
338 0 push(@{ $$self{pending_comments} }, $token); }
339 elsif ($cc == CC_MARKER) {
340 0 $self->handleMarker($token); } } }
341 0 ▶ ProgressStep() if ($$self{progress}++ % $TOKEN_PROGRESS_QUANTUM) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"progress"}++ % $LaTeXML::Core::Gullet::TOKEN_PROGRESS_QUANTUM == 0 0 0 0
342 0 ▶ if (!defined $token) {
Branch: 5 branches
BranchTrueFalseTotal
if (not defined $token) { } 0 0 0
elsif (my $unexpanded = $token->[2]) { } 0 0 0
elsif (not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)) { } 0 0 0
elsif ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) and ref $defn ne 'LaTeXML::Core::Token' and $defn->{'isExpandable'} and $for_evaluation || !$defn->{'isProtected'}) { } 0 0 0
elsif ($token->[1] == 16 and not defined $defn) { } 0 0 0
343 0 ▶ return unless $autoclose && $$self{autoclose} && @{ $$self{mouthstack} };
Branch: 1 branch
BranchTrueFalseTotal
unless $autoclose and $self->{"autoclose"} and @{$self->{"mouthstack"};} 0 0 0
Condition0%0/6
$autoclose and $self->{"autoclose"} and @{$self->{"mouthstack"};}
!ll&&!rl&&r
000
$autoclose and $self->{"autoclose"}
!ll&&!rl&&r
000
MC/DC0%0/3
$autoclose and $self->{"autoclose"} and @{$self->{"mouthstack"};}
$autoclose $self->{"autoclose"} @{$self->{"mouthstack"};}
Truth table0%0/4
A and B and C
A= $autocloseB= $self->{"autoclose"}C= @{$self->{"mouthstack"};}
ABCresult
0XX0
10X0
1100
1111
344 0 $self->closeMouth; } # Next input stream.
345 # Handle \noexpand and smuggled tokens; either expand to $$token[2] or defer till later
346 elsif (my $unexpanded = $$token[2]) { # Inline get_dont_expand
347 0 ▶ return ($cc != CC_SMUGGLE_THE) || $LaTeXML::SMUGGLE_THE ? $token : $unexpanded; }
Branch: 1 branch
BranchTrueFalseTotal
$cc != 19 || $LaTeXML::SMUGGLE_THE ? : 0 0 0
Condition0%0/3
$cc != 19 or $LaTeXML::SMUGGLE_THE
l!l&&r!l&&!r
000
MC/DC0%0/2
$cc != 19 or $LaTeXML::SMUGGLE_THE
$cc != 19 $LaTeXML::SMUGGLE_THE
Truth table0%0/3
A or B
A= $cc != 19B= $LaTeXML::SMUGGLE_THE
ABresult
1X1
011
000
348 ## Wow!!!!! See TeX the Program \S 309
349 ▶ elsif (!$LaTeXML::ALIGN_STATE # SHOULD count nesting of { }!!! when SCANNED (not digested)
Condition0%0/6
not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)
!ll&&!rl&&r
000
not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT
!ll&&!rl&&r
000
MC/DC0%0/3
not $LaTeXML::ALIGN_STATE and $LaTeXML::READING_ALIGNMENT and () = $self->isColumnEnd($token)
not $LaTeXML::ALIGN_STATE $LaTeXML::READING_ALIGNMENT () = $self->isColumnEnd($token)
Truth table0%0/4
not(A) and B and C
A= not $LaTeXML::ALIGN_STATEB= $LaTeXML::READING_ALIGNMENTC= () = $self->isColumnEnd($token)
ABCresult
0XX0
10X0
1100
1111
350 && $LaTeXML::READING_ALIGNMENT
351 && (($atoken, $atype, $ahidden) = $self->isColumnEnd($token))) {
352 0 $self->handleTemplate($LaTeXML::READING_ALIGNMENT, $token, $atype, $ahidden); }
353 ## Note: use general-purpose lookup, since we may reexamine $defn below
354 ▶ elsif ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]
Condition0%0/15
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"} and $for_evaluation || !$defn->{"isProtected"}
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"}
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) and ref $defn ne "LaTeXML::Core::Token"
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token))
!ll&&!rl&&r
000
$for_evaluation or not $defn->{"isProtected"}
l!l&&r!l&&!r
000
MC/DC0%0/6
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] and defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"} and $for_evaluation || !$defn->{"isProtected"}
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token)) ref $defn ne "LaTeXML::Core::Token" $defn->{"isExpandable"} $for_evaluation not $defn->{"isProtected"}
Truth table0%0/7
A and B and C and D and E or not(F)
A= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]B= defined($defn = $LaTeXML::Core::Gullet::STATE->lookupMeaning($token))C= ref $defn ne "LaTeXML::Core::Token"D= $defn->{"isExpandable"}E= $for_evaluationF= not $defn->{"isProtected"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
1111000
11111X1
1111011
355 && defined($defn = $STATE->lookupMeaning($token))
356 && ((ref $defn) ne 'LaTeXML::Core::Token') # an actual definition
357 && $$defn{isExpandable}
358 && ($for_evaluation || !$$defn{isProtected})) { # is this the right logic here? don't expand unless di
359 0 local $LaTeXML::CURRENT_TOKEN = $token;
360 0 my $r;
361 0 ▶ my @expansion = map { (($r = ref $_) eq 'LaTeXML::Core::Token' ? $_
Branch: 2 branches
BranchTrueFalseTotal
($r = ref $_) eq 'LaTeXML::Core::Token' ? : 0 0 0
$r eq 'LaTeXML::Core::Tokens' ? : 0 0 0
Condition0%0/3
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_), 'in ' . ToString($defn)) or T_OTHER(Stringify($_))
l!l&&r!l&&!r
000
MC/DC0%0/2
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_), 'in ' . ToString($defn)) or T_OTHER(Stringify($_))
Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_), 'in ' . ToString($defn)) T_OTHER(Stringify($_))
Truth table0%0/3
A or B
A= Error("misdefined", $r, undef, 'Expected a Token, got ' . Stringify($_), 'in ' . ToString($defn))B= T_OTHER(Stringify($_))
ABresult
1X1
011
000
362 : ($r eq 'LaTeXML::Core::Tokens' ? @$_
363 : Error('misdefined', $r, undef, "Expected a Token, got " . Stringify($_),
364 "in " . ToString($defn)) || T_OTHER(Stringify($_)))) }
365 $defn->invoke($self);
366 0 ▶ next unless @expansion;
Branch: 1 branch
BranchTrueFalseTotal
unless @expansion 0 0 0
367 0 ▶ if ($$LaTeXML::Core::Token::SMUGGLE_THE_COMMANDS{ $$defn{cs}[0] }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$LaTeXML::Core::Token::SMUGGLE_THE_COMMANDS{$defn->{"cs"}[0]}) 0 0 0
368 # magic THE_TOKS handling, add to pushback with a single-use noexpand flag only valid
369 # at the exact time the token leaves the pushback.
370 # This is *required to be different* from the noexpand flag, as per the B Book
371 0 ▶ @expansion = map { ($LaTeXML::Core::Token::CATCODE_CAN_SMUGGLE_THE[$$_[1]] ? bless ["SMUGGLE_THE", CC_SMUGGLE_THE, $_], 'LaTeXML::Core::Token' : $_) } @expansion;
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::Token::CATCODE_CAN_SMUGGLE_THE[$_->[1]] ? : 0 0 0
372 # PERFORMANCE:
373 # explicitly flag that we've seen this case, so that higher levels know to
374 # unset the flag from the entire {pushback}
375 0 $$self{pushback_has_smuggled_the} = 1; }
376 # add the newly expanded tokens back into the gullet stream, in the ordinary case.
377 0 unshift(@{ $$self{pushback} }, @expansion); }
378 ▶ elsif ($$token[1] == CC_CS && !(defined $defn)) {
Condition0%0/3
$token->[1] == 16 and not defined $defn
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[1] == 16 and not defined $defn
$token->[1] == 16 not defined $defn
Truth table0%0/3
A and not(B)
A= $token->[1] == 16B= not defined $defn
ABresult
0X0
100
111
379 0 $STATE->generateErrorStub($self, $token); # cs SHOULD have defn by now; report early!
380 0 return $token; }
381 else {
382 0 return $token; } # just return it
383 }
384 0 return; } # never get here.
385  
386 # Read the next raw line (string);
387 # primarily to read from the Mouth, but keep any unread input!
388 sub readRawLine {
389 0 ▶ my ($self) = @_;
Subroutine readRawLine: not called CC=4 SCAR=30.0
Pod undocumented
390 # If we've got unread tokens, they presumably should come before the Mouth's raw data
391 # but we'll convert them back to string.
392 0 ▶ my @tokens = map { ($$_[1] == CC_SMUGGLE_THE ? $$_[2] : $_) } @{ $$self{pushback} };
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] == 19 ? : 0 0 0
393 0 my @markers = grep { $_->getCatcode == CC_MARKER } @tokens;
394 0 ▶ if (@markers) { # Whoops, profiling markers!
Branch: 1 branch
BranchTrueFalseTotal
if (@markers) 0 0 0
395 0 @tokens = grep { $_->getCatcode != CC_MARKER } @tokens; # Remove
396 0 map { LaTeXML::Core::Definition::stopProfiling($_, 'expand') } @markers; }
397 0 $$self{pushback} = [];
398 # If we still have peeked tokens, we ONLY want to combine it with the remainder
399 # of the current line from the Mouth (NOT reading a new line)
400 0 ▶ if (@tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (@tokens) { } 0 0 0
401 0 return ToString(Tokens(@tokens)) . $$self{mouth}->readRawLine(1); }
402 # Otherwise, read the next line from the Mouth.
403 else {
404 0 return $$self{mouth}->readRawLine; } }
405  
406 #**********************************************************************
407 # Mid-level readers: checking and matching tokens, strings etc.
408 #**********************************************************************
409 # General note: TeX uses different tests for Space tokens in different places
410 # (possibilities: catcode equality, ->equals, Equals and XEquals)
411  
412 # The following higher-level parsing methods are built upon readToken & unread.
413 sub readNonSpace {
414 0 ▶ my ($self) = @_;
Subroutine readNonSpace: not called CC=3 SCAR=24.8
Pod documented
415 0 my $token;
416 0 ▶ do { $token = $self->readToken();
Branch: 1 branch
BranchTrueFalseTotal
defined $token and $token->[1] == 10 and do { do { $token = $self->readToken } } 0 0 0
Condition0%0/3
defined $token and $token->[1] == 10
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
417 } while (defined $token && $$token[1] == CC_SPACE); # Inline ->getCatcode!
418 0 return $token; }
419  
420 sub readXNonSpace {
421 0 ▶ my ($self) = @_;
Subroutine readXNonSpace: not called CC=3 SCAR=24.8
Pod undocumented
422 0 my $token;
423 0 ▶ do { $token = $self->readXToken(0);
Branch: 1 branch
BranchTrueFalseTotal
defined $token and $token->[1] == 10 and do { do { $token = $self->readXToken(0) } } 0 0 0
Condition0%0/3
defined $token and $token->[1] == 10
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
424 } while (defined $token && $$token[1] == CC_SPACE); # Inline ->getCatcode!
425 0 return $token; }
426  
427 sub skipSpaces {
428 0 ▶ my ($self) = @_;
Subroutine skipSpaces: not called CC=2 SCAR=17.9
Pod documented
429 0 my $tok = $self->readNonSpace;
430 0 ▶ unshift(@{ $$self{pushback} }, $tok) if defined $tok; # Unread
Branch: 1 branch
BranchTrueFalseTotal
if defined $tok 0 0 0
431 0 return; }
432  
433 # Skip one space
434 # if $expanded is true, it acts like <one optional space>, expanding the next token.
435 sub skip1Space {
436 0 ▶ my ($self, $expanded) = @_;
Subroutine skip1Space: not called CC=4 SCAR=30.0
Pod documented
437 0 ▶ my $token = ($expanded ? $self->readXToken : $self->readToken);
Branch: 1 branch
BranchTrueFalseTotal
$expanded ? : 0 0 0
438 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token && !Equals($token, T_SPACE);
Branch: 1 branch
BranchTrueFalseTotal
if $token and not Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' )) 0 0 0
Condition0%0/3
$token and not Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
!ll&&!rl&&r
000
MC/DC0%0/2
$token and not Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
$token not Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
Truth table0%0/3
A and not(B)
A= $tokenB= not Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
ABresult
0X0
100
111
439 0 return; }
440  
441 # <filler> = <optional spaces> | <filler>\relax<optional spaces>
442 sub skipFiller {
443 0 ▶ my ($self) = @_;
Subroutine skipFiller: not called CC=3 SCAR=24.8
Pod undocumented
444 0 while (1) {
445 0 my $tok = $self->readNonSpace;
446 0 ▶ return unless defined $tok;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tok 0 0 0
447 # Should \foo work too (where \let\foo\relax) ??
448 0 ▶ if (!$tok->equals(T_CS('\relax'))) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tok->equals(T_CS("\\relax"))) 0 0 0
449 0 unshift(@{ $$self{pushback} }, $tok); # Unread
450 0 return; }
451 }
452 0 return; }
453  
454 # Read a sequence of tokens balanced in {}
455 # assuming the { has already been read.
456 # Returns a Tokens list of the balanced sequence, omitting the closing }
457 5 our @CATCODE_BALANCED_INTERESTING = (
458 0, 1, 1, 0,
459 0, 0, 0, 0,
460 0, 0, 0, 0,
461 0, 0, 0, 0,
462 0, 1, 0, 0);
463  
464 sub readBalanced {
465 0 ▶ my ($self, $expanded) = @_;
Subroutine readBalanced: not called CC=11 SCAR=48.8
Pod documented
466 0 local $LaTeXML::ALIGN_STATE = 1000000;
467 0 my @tokens = ();
468 0 my ($token, $level) = (undef, 1);
469 0 ▶ my $startloc = ($$self{verbosity} > 0) && $self->getLocator;
Condition0%0/3
$self->{'verbosity'} > 0 && $self->getLocator
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'verbosity'} > 0 && $self->getLocator
$self->{'verbosity'} > 0 $self->getLocator
Truth table0%0/3
A && B
A= $self->{'verbosity'} > 0B= $self->getLocator
ABresult
0X0
100
111
470 # Inlined readToken (we'll keep comments in the result)
471 0 ▶ while ($token = ($expanded ? $self->readXToken(0, 1) : $self->readToken())) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token = $expanded ? $self->readXToken(0, 1) : $self->readToken) 0 0 0
$expanded ? : 0 0 0
472 0 my $cc = $$token[1];
473 0 ▶ if (!$CATCODE_BALANCED_INTERESTING[$cc]) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $LaTeXML::Core::Gullet::CATCODE_BALANCED_INTERESTING[$cc]) { } 0 0 0
elsif ($cc == 2) { } 0 0 0
elsif ($cc == 1) { } 0 0 0
elsif ($cc == 17) { } 0 0 0
474 0 push(@tokens, $token); }
475 elsif ($cc == CC_END) {
476 0 $level--;
477 0 ▶ if (!$level) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($level) 0 0 0
478 0 last; }
479 0 push(@tokens, $token); }
480 elsif ($cc == CC_BEGIN) {
481 0 $level++;
482 0 push(@tokens, $token); }
483 elsif ($cc == CC_MARKER) {
484 0 LaTeXML::Core::Definition::stopProfiling($token, 'expand'); } }
485 0 ▶ if ($level > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level > 0) 0 0 0
486 # TODO: The current implementation has a limitation where if the balancing end is in a different mouth,
487 # it will not be recognized.
488 0 ▶ my $loc_message = $startloc ? ("Started at " . ToString($startloc)) : ("Ended at " . ToString($self->getLocator));
Branch: 1 branch
BranchTrueFalseTotal
$startloc ? : 0 0 0
489 0 Error('expected', "}", $self, "Gullet->readBalanced ran out of input in an unbalanced state.",
490 $loc_message); }
491 0 return Tokens(@tokens); }
492  
493 sub ifNext {
494 0 ▶ my ($self, $token) = @_;
Subroutine ifNext: not called CC=2 SCAR=17.9
Pod documented
495 0 ▶ if (my $tok = $self->readToken()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tok = $self->readToken) { } 0 0 0
496 0 unshift(@{ $$self{pushback} }, $tok); # Unread
497 0 return $tok->equals($token); }
498 0 else { return 0; } }
499  
500 # Match the input against one of the Token or Tokens in @choices; return the matching one or undef.
501 sub readMatch {
502 0 ▶ my ($self, @choices) = @_;
Subroutine readMatch: not called CC=11 SCAR=48.8
Pod documented
503 0 foreach my $choice (@choices) {
504 0 my @tomatch = $choice->unlist;
505 0 my @matched = ();
506 0 my $token;
507 0 ▶ while (@tomatch && defined($token = $self->readToken)
Branch: 1 branch
BranchTrueFalseTotal
if (@tomatch and defined($token = $self->readToken) and push @matched, $token and $token->equals($tomatch[0])) 0 0 0
Condition0%0/9
@tomatch and defined($token = $self->readToken) and push @matched, $token and $token->equals($tomatch[0])
!ll&&!rl&&r
000
@tomatch and defined($token = $self->readToken) and push @matched, $token
!ll&&!rl&&r
000
@tomatch and defined($token = $self->readToken)
!ll&&!rl&&r
000
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])
ABCDresult
0XXX0
10XX0
110X0
11100
11111
508 && push(@matched, $token) && ($token->equals($tomatch[0]))) {
509 0 shift(@tomatch);
510 0 ▶ if ($$token[1] == CC_SPACE) { # If this was space, SKIP any following!!!
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] == 10) 0 0 0
511 0 ▶ while (defined($token = $self->readToken) && ($$token[1] == CC_SPACE)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($token = $self->readToken) and $token->[1] == 10) 0 0 0
Condition0%0/3
defined($token = $self->readToken) and $token->[1] == 10
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
512 0 push(@matched, $token); }
513 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token; } # Unread
Branch: 1 branch
BranchTrueFalseTotal
if $token 0 0 0
514 }
515 0 ▶ return $choice unless @tomatch; # All matched!!!
Branch: 1 branch
BranchTrueFalseTotal
unless @tomatch 0 0 0
516 0 unshift(@{ $$self{pushback} }, @matched); # Put 'em back and try next!
517 }
518 0 return; }
519  
520 # Match the input against a set of keywords; Similar to readMatch, but the keywords are strings,
521 # and Case and catcodes are ignored; additionally, leading spaces are skipped.
522 # AND, macros are expanded.
523 sub readKeyword {
524 0 ▶ my ($self, @keywords) = @_;
Subroutine readKeyword: not called CC=8 SCAR=42.8
Pod documented
525 0 $self->skipSpaces;
526 0 foreach my $keyword (@keywords) {
527 0 ▶ $keyword = ToString($keyword) if ref $keyword;
Branch: 1 branch
BranchTrueFalseTotal
if ref $keyword 0 0 0
528 0 my @tomatch = split('', uc($keyword));
529 0 my @matched = ();
530 0 my $tok;
531 0 ▶ while (@tomatch && defined($tok = $self->readXToken(0)) && push(@matched, $tok)
Branch: 1 branch
BranchTrueFalseTotal
if (@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok and uc $tok->toString eq $tomatch[0]) 0 0 0
Condition0%0/9
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok and uc $tok->toString eq $tomatch[0]
!ll&&!rl&&r
000
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok
!ll&&!rl&&r
000
@tomatch and defined($tok = $self->readXToken(0))
!ll&&!rl&&r
000
MC/DC0%0/4
@tomatch and defined($tok = $self->readXToken(0)) and push @matched, $tok and uc $tok->toString eq $tomatch[0]
@tomatch defined($tok = $self->readXToken(0)) push @matched, $tok uc $tok->toString 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->toString eq $tomatch[0]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
532 && (uc($tok->toString) eq $tomatch[0])) {
533 0 shift(@tomatch); }
534 0 ▶ return $keyword unless @tomatch; # All matched!!!
Branch: 1 branch
BranchTrueFalseTotal
unless @tomatch 0 0 0
535 0 unshift(@{ $$self{pushback} }, @matched); # Put 'em back and try next!
536 }
537 0 return; }
538  
539 # Return a (balanced) sequence tokens until a match against one of the Tokens in @delims.
540 # Note that Braces on input hides the contents from matching,
541 # so this assumes there wont be braces in $delim!
542 # But, see readUntilBrace for that case.
543 sub readUntil {
544 0 ▶ my ($self, $delim) = @_;
Subroutine readUntil: not called CC=20 SCAR=60.4
Pod documented
545 0 my @tokens = ();
546 0 my $token;
547 0 my $nbraces = 0;
548 0 my @want = $delim->unlist;
549 0 my $ntomatch = scalar(@want);
550 0 ▶ if ($ntomatch == 1) { # Common, easy case: read till we match a single token
Branch: 1 branch
BranchTrueFalseTotal
if ($ntomatch == 1) { } 0 0 0
551 0 my $want = $want[0];
552 # while(($token = $self->readToken) && !$token->equals($want)){
553 0 ▶ while (($token = shift(@{ $$self{pushback} }) || $$self{mouth}->readToken())
Branch: 1 branch
BranchTrueFalseTotal
if ($token = shift @{$$self{"pushback"};} || $self->{"mouth"}->readToken and $token->[1] != 19 || ($token = $token->[2]) and not $token->equals($want)) 0 0 0
Condition0%0/12
$token = shift @{$$self{"pushback"};} || $self->{"mouth"}->readToken and $token->[1] != 19 || ($token = $token->[2]) and not $token->equals($want)
!ll&&!rl&&r
000
$token = shift @{$$self{"pushback"};} || $self->{"mouth"}->readToken and $token->[1] != 19 || ($token = $token->[2])
!ll&&!rl&&r
000
shift @{$$self{'pushback'};} || $self->{'mouth'}->readToken
l!l&&r!l&&!r
000
$token->[1] != 19 or $token = $token->[2]
l!l&&r!l&&!r
000
MC/DC0%0/5
$token = shift @{$$self{"pushback"};} || $self->{"mouth"}->readToken and $token->[1] != 19 || ($token = $token->[2]) and not $token->equals($want)
shift @{$$self{'pushback'};} $self->{'mouth'}->readToken $token->[1] != 19 $token = $token->[2] not $token->equals($want)
Truth table0%0/11
A || B and C or D and not(E)
A= shift @{$$self{'pushback'};}B= $self->{'mouth'}->readTokenC= $token->[1] != 19D= $token = $token->[2]E= not $token->equals($want)
ABCDEresult
00XXX0
1X00X0
0100X0
1X1X00
1X0100
011X00
010100
1X1X11
1X0111
011X11
010111
554 && (($$token[1] != CC_SMUGGLE_THE) || ($token = $$token[2]))
555 && !$token->equals($want)) {
556 0 push(@tokens, $token);
557 0 ▶ if ($$token[1] == CC_BEGIN) { # And if it's a BEGIN, copy till balanced END
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] == 1) 0 0 0
558 0 $nbraces++;
559 0 push(@tokens, $self->readBalanced, T_END); } } }
560 else {
561  
562 0 my @ring = ();
563 0 while (1) {
564 # prefill the required number of tokens
565 0 ▶ while ((scalar(@ring) < $ntomatch) && ($token = $self->readToken)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @ring < $ntomatch and $token = $self->readToken) 0 0 0
Condition0%0/3
scalar @ring < $ntomatch and $token = $self->readToken
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @ring < $ntomatch and $token = $self->readToken
scalar @ring < $ntomatch $token = $self->readToken
Truth table0%0/3
A and B
A= scalar @ring < $ntomatchB= $token = $self->readToken
ABresult
0X0
100
111
566 0 ▶ if ($$token[1] == CC_BEGIN) { # read balanced, and refill ring.
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] == 1) { } 0 0 0
567 0 $nbraces++;
568 0 push(@tokens, @ring, $token, $self->readBalanced, T_END); # Copy directly to result
569 0 @ring = (); } # and retry
570 else {
571 0 push(@ring, $token); } }
572 0 my $i;
573 0 ▶ for ($i = 0 ; ($i < $ntomatch) && $ring[$i] && ($ring[$i]->equals($want[$i])) ; $i++) { } # Test match
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $ntomatch and $ring[$i] and $ring[$i]->equals($want[$i])) 0 0 0
Condition0%0/6
$i < $ntomatch and $ring[$i] and $ring[$i]->equals($want[$i])
!ll&&!rl&&r
000
$i < $ntomatch and $ring[$i]
!ll&&!rl&&r
000
MC/DC0%0/3
$i < $ntomatch and $ring[$i] and $ring[$i]->equals($want[$i])
$i < $ntomatch $ring[$i] $ring[$i]->equals($want[$i])
Truth table0%0/4
A and B and C
A= $i < $ntomatchB= $ring[$i]C= $ring[$i]->equals($want[$i])
ABCresult
0XX0
10X0
1100
1111
574 0 ▶ last if $i >= $ntomatch; # Matched all!
Branch: 1 branch
BranchTrueFalseTotal
if $i >= $ntomatch 0 0 0
575 0 ▶ last unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
576 0 push(@tokens, shift(@ring)); } }
577 0 ▶ if (!defined $token) { # Ran out!
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $token) 0 0 0
578 0 $self->unread(@tokens); # Not more correct, but maybe less confusing?
579 0 return; }
580 # Notice that IFF the arg looks like {balanced}, the outer braces are stripped
581 # so that delimited arguments behave more similarly to simple, undelimited arguments.
582 0 ▶ if (($nbraces == 1) && ($tokens[0][1] == CC_BEGIN) && ($tokens[-1][1] == CC_END)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nbraces == 1 and $tokens[0][1] == 1 and $tokens[-1][1] == 2) 0 0 0
Condition0%0/6
$nbraces == 1 and $tokens[0][1] == 1 and $tokens[-1][1] == 2
!ll&&!rl&&r
000
$nbraces == 1 and $tokens[0][1] == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$nbraces == 1 and $tokens[0][1] == 1 and $tokens[-1][1] == 2
$nbraces == 1 $tokens[0][1] == 1 $tokens[-1][1] == 2
Truth table0%0/4
A and B and C
A= $nbraces == 1B= $tokens[0][1] == 1C= $tokens[-1][1] == 2
ABCresult
0XX0
10X0
1100
1111
583 0 shift(@tokens); pop(@tokens); }
584 0 return Tokens(@tokens); }
585  
586 sub readUntilBrace {
587 0 ▶ my ($self) = @_;
Subroutine readUntilBrace: not called CC=3 SCAR=24.8
Pod undocumented
588 0 my @tokens = ();
589 0 my $token;
590 0 ▶ while (defined($token = $self->readToken())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($token = $self->readToken)) 0 0 0
591 0 ▶ if ($$token[1] == CC_BEGIN) { # INLINE Catcode
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1] == 1) 0 0 0
592 0 unshift(@{ $$self{pushback} }, $token); # Unread
593 0 last; }
594 0 push(@tokens, $token); }
595 0 return Tokens(@tokens); }
596  
597 #**********************************************************************
598 # Higher-level readers: Read various types of things from the input:
599 # tokens, non-expandable tokens, args, Numbers, ...
600 #**********************************************************************
601 sub readArg {
602 0 ▶ my ($self) = @_;
Subroutine readArg: not called CC=3 SCAR=24.8
Pod documented
603 0 my $token = $self->readNonSpace;
604 0 ▶ if (!defined $token) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $token) { } 0 0 0
elsif ($token->[1] == 1) { } 0 0 0
605 0 return; }
606 elsif ($$token[1] == CC_BEGIN) { # Inline ->getCatcode!
607 0 return $self->readBalanced(0); }
608 else {
609 0 return Tokens($token); } }
610  
611 # Note that this returns an empty array if [] is present,
612 # otherwise $default or undef.
613 sub readOptional {
614 0 ▶ my ($self, $default) = @_;
Subroutine readOptional: not called CC=3 SCAR=24.8
Pod documented
615 0 my $tok = $self->readNonSpace;
616 0 ▶ if (!defined $tok) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $tok) { } 0 0 0
elsif ($tok->equals(T_OTHER('['))) { } 0 0 0
617 0 return; }
618 elsif (($tok->equals(T_OTHER('[')))) {
619 0 return $self->readUntil(T_OTHER(']')); }
620 else {
621 0 unshift(@{ $$self{pushback} }, $tok); # Unread
622 0 return $default; } }
623  
624 #**********************************************************************
625 # Numbers, Dimensions, Glue
626 # See TeXBook, Ch.24, pp.269-271.
627 #**********************************************************************
628 sub readValue {
629 0 ▶ my ($self, $type) = @_;
Subroutine readValue: not called CC=8 SCAR=42.8
Pod documented
630 0 ▶ if ($type eq 'Number') { return $self->readNumber; }
Branch: 7 branches
BranchTrueFalseTotal
if ($type eq 'Number') { } 0 0 0
elsif ($type eq 'Dimension') { } 0 0 0
elsif ($type eq 'Glue') { } 0 0 0
elsif ($type eq 'MuGlue') { } 0 0 0
elsif ($type eq 'Tokens') { } 0 0 0
elsif ($type eq 'Token') { } 0 0 0
elsif ($type eq 'any') { } 0 0 0
631 0 elsif ($type eq 'Dimension') { return $self->readDimension; }
632 0 elsif ($type eq 'Glue') { return $self->readGlue; }
633 0 elsif ($type eq 'MuGlue') { return $self->readMuGlue; }
634 0 elsif ($type eq 'Tokens') { return $self->readTokensValue; }
635 0 elsif ($type eq 'Token') { return $self->readToken; }
636 0 elsif ($type eq 'any') { return $self->readArg; }
637 else {
638 0 Error('unexpected', $type, $self,
639 "Gullet->readValue Didn't expect this type: $type");
640 0 return; }
641 }
642  
643 sub readRegisterValue {
644 0 ▶ my ($self, $type) = @_;
Subroutine readRegisterValue: not called CC=5 SCAR=34.0
Pod documented
645 0 my $token = $self->readXToken;
646 0 ▶ return unless defined $token;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $token 0 0 0
647 0 my $defn = $STATE->lookupDefinition($token);
648 0 ▶ if ((defined $defn) && ($defn->isRegister eq $type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defn and $defn->isRegister eq $type) { } 0 0 0
Condition0%0/3
defined $defn and $defn->isRegister eq $type
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
649 0 local $LaTeXML::CURRENT_TOKEN = $token;
650 0 my $parms = $$defn{parameters};
651 0 ▶ return $defn->valueOf(($parms ? $parms->readArguments($self) : ())); }
Branch: 1 branch
BranchTrueFalseTotal
$parms ? : 0 0 0
652 else {
653 0 unshift(@{ $$self{pushback} }, $token); # Unread
654 0 return; } }
655  
656 # Apparent behaviour of a token value (ie \toks#=<arg>)
657 sub readTokensValue {
658 0 ▶ my ($self) = @_;
Subroutine readTokensValue: not called CC=8 SCAR=42.8
Pod undocumented
659 0 my $token = $self->readNonSpace;
660 0 ▶ if (!defined $token) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $token) { } 0 0 0
elsif ($token->[1] == 1) { } 0 0 0
elsif (my $defn = $LaTeXML::Core::Gullet::STATE->lookupDefinition($token)) { } 0 0 0
661 0 return; }
662 elsif ($$token[1] == CC_BEGIN) { # Inline ->getCatcode!
663 0 return $self->readBalanced; }
664 elsif (my $defn = $STATE->lookupDefinition($token)) {
665 0 ▶ if ($defn->isRegister eq 'Tokens') {
Branch: 2 branches
BranchTrueFalseTotal
if ($defn->isRegister eq 'Tokens') { } 0 0 0
elsif ($defn->isExpandable) { } 0 0 0
666 0 my $parms = $$defn{parameters};
667 0 ▶ return $defn->valueOf(($parms ? $parms->readArguments($self) : ())); }
Branch: 1 branch
BranchTrueFalseTotal
$parms ? : 0 0 0
668 elsif ($defn->isExpandable) {
669 0 ▶ if (my $x = $defn->invoke($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $x = $defn->invoke($self)) 0 0 0
670 0 $self->unread(@{$x}); }
671 0 return $self->readTokensValue; }
672 else {
673 0 return $token; } } # ?
674 else {
675 0 return $token; } }
676  
677 #======================================================================
678 # some helpers...
679 # Note that <one optional space> is kinda special:
680 # The following Token(s) are expanded until an unexpandable token is found;
681 # it is discarded if it is a space, but with an Equals() equality test!
682  
683 # <optional signs> = <optional spaces> | <optional signs><plus or minus><optional spaces>
684 # return +1 or -1
685 sub readOptionalSigns {
686 0 ▶ my ($self) = @_;
Subroutine readOptionalSigns: not called CC=7 SCAR=40.3
Pod undocumented
687 0 my ($sign, $t) = ("+1", '');
688 0 ▶ while (defined($t = $self->readXToken)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($t = $self->readXToken) and $t->getString eq "+" || $t->getString eq "-" || Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))) 0 0 0
Condition0%0/9
defined($t = $self->readXToken) and $t->getString eq "+" || $t->getString eq "-" || Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))
!ll&&!rl&&r
000
$t->getString eq "+" or $t->getString eq "-" or Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))
l!l&&r!l&&!r
000
$t->getString eq "+" or $t->getString eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/4
defined($t = $self->readXToken) and $t->getString eq "+" || $t->getString eq "-" || Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))
defined($t = $self->readXToken) $t->getString eq "+" $t->getString eq "-" Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))
Truth table0%0/5
A and B or C or D
A= defined($t = $self->readXToken)B= $t->getString eq "+"C= $t->getString eq "-"D= Equals($t, bless( [" ",10], 'LaTeXML::Core::Token' ))
ABCDresult
0XXX0
10000
11XX1
101X1
10011
689 && (($t->getString eq '+') || ($t->getString eq '-') || Equals($t, T_SPACE))) {
690 0 ▶ $sign = -$sign if ($t->getString eq '-'); }
Branch: 1 branch
BranchTrueFalseTotal
if $t->getString eq "-" 0 0 0
691 0 ▶ unshift(@{ $$self{pushback} }, $t) if $t; # Unread
Branch: 1 branch
BranchTrueFalseTotal
if $t 0 0 0
692 0 return $sign; }
693  
694 # Read digits (within $range), while expanding and if $skip, skip <one optional space> (expanded!)
695 sub readDigits {
696 0 ▶ my ($self, $range, $skip) = @_;
Subroutine readDigits: not called CC=6 SCAR=37.4
Pod undocumented
697 0 my $string = '';
698 0 my ($token, $digit);
699 0 ▶ while (($token = $self->readXToken) && (($digit = $token->toString) =~ /^[$range]$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $self->readXToken and ($digit = $token->toString) =~ /^[$range]$/) 0 0 0
Condition0%0/3
$token = $self->readXToken and ($digit = $token->toString) =~ /^[$range]$/
!ll&&!rl&&r
000
MC/DC0%0/2
$token = $self->readXToken and ($digit = $token->toString) =~ /^[$range]$/
$token = $self->readXToken ($digit = $token->toString) =~ /^[$range]$/
Truth table0%0/3
A and B
A= $token = $self->readXTokenB= ($digit = $token->toString) =~ /^[$range]$/
ABresult
0X0
100
111
700 0 $string .= $digit; }
701 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token && !($skip && Equals($token, T_SPACE)); #Inline
Branch: 1 branch
BranchTrueFalseTotal
if $token and not $skip && Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' )) 0 0 0
Condition0%0/6
$token and not $skip && Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
!ll&&!rl&&r
000
$skip && Equals($token, [' ', 10])
!ll&&!rl&&r
000
MC/DC0%0/3
$token and not $skip && Equals($token, bless( [" ",10], 'LaTeXML::Core::Token' ))
$token $skip Equals($token, [' ', 10])
Truth table0%0/4
A and not(B && C)
A= $tokenB= $skipC= Equals($token, [' ', 10])
ABCresult
0XX0
1110
10X1
1101
702 0 return $string; }
703  
704 # <factor> = <normal integer> | <decimal constant>
705 # <decimal constant> = . | , | <digit><decimal constant> | <decimal constant><digit>
706 # Return a number (perl number)
707 sub readFactor {
708 0 ▶ my ($self) = @_;
Subroutine readFactor: not called CC=7 SCAR=40.3
Pod undocumented
709 0 my $string = $self->readDigits('0-9');
710 0 my $token = $self->readXToken;
711 0 ▶ if ($token && $token->getString =~ /^[\.\,]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token and $token->getString =~ /^[\.\,]$/) 0 0 0
Condition0%0/3
$token and $token->getString =~ /^[\.\,]$/
!ll&&!rl&&r
000
MC/DC0%0/2
$token and $token->getString =~ /^[\.\,]$/
$token $token->getString =~ /^[\.\,]$/
Truth table0%0/3
A and B
A= $tokenB= $token->getString =~ /^[\.\,]$/
ABresult
0X0
100
111
712 0 $string .= '.' . $self->readDigits('0-9');
713 0 $token = $self->readXToken; }
714 0 ▶ if (length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) { } 0 0 0
715 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token && $$token[1] != CC_SPACE; # Inline ->getCatcode, unread
Branch: 1 branch
BranchTrueFalseTotal
if $token and $token->[1] != 10 0 0 0
Condition0%0/3
$token and $token->[1] != 10
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
716 0 return $string; }
717 else {
718 0 unshift(@{ $$self{pushback} }, $token); # Unread
719 0 my $n = $self->readNormalInteger;
720 0 ▶ return (defined $n ? $n->valueOf : undef); } }
Branch: 1 branch
BranchTrueFalseTotal
defined $n ? : 0 0 0
721  
722 #======================================================================
723 # Integer, Number
724 #======================================================================
725 # <number> = <optional signs><unsigned number>
726 # <unsigned number> = <normal integer> | <coerced integer>
727 # <coerced integer> = <internal dimen> | <internal glue>
728  
729 sub readNumber {
730 0 ▶ my ($self) = @_;
Subroutine readNumber: not called CC=5 SCAR=34.0
Pod documented
731 0 my $s = $self->readOptionalSigns;
732 0 ▶ if (defined(my $n = $self->readNormalInteger)) { return ($s < 0 ? $n->negate : $n); }
Branch: 4 branches
BranchTrueFalseTotal
if (defined(my $n = $self->readNormalInteger)) { } 0 0 0
elsif (defined($n = $self->readInternalDimension)) { } 0 0 0
elsif (defined($n = $self->readInternalGlue)) { } 0 0 0
$s < 0 ? : 0 0 0
733 0 elsif (defined($n = $self->readInternalDimension)) { return Number($s * $n->valueOf); }
734 0 elsif (defined($n = $self->readInternalGlue)) { return Number($s * $n->valueOf); }
735 else {
736 0 my $next = $self->readToken();
737 0 unshift(@{ $$self{pushback} }, $next); # Unread
738 0 Warn('expected', '<number>', $self, "Missing number, treated as zero",
739 "while processing " . ToString($LaTeXML::CURRENT_TOKEN), $self->showUnexpected);
740 0 return Number(0); } }
741  
742 # <normal integer> = <internal integer> | <integer constant>
743 # | '<octal constant><one optional space> | "<hexadecimal constant><one optional space>
744 # | `<character token><one optional space>
745 # Return a Number or undef
746 sub readNormalInteger {
747 0 ▶ my ($self) = @_;
Subroutine readNormalInteger: not called CC=9 SCAR=45.0
Pod undocumented
748 0 my $token = $self->readXToken; # expand more
749 0 ▶ if (!defined $token) {
Branch: 5 branches
BranchTrueFalseTotal
if (not defined $token) { } 0 0 0
elsif ($token->[1] == 12 and $token->toString =~ /^[0-9]$/) { } 0 0 0
elsif ($token->equals(T_OTHER(q[']))) { } 0 0 0
elsif ($token->equals(T_OTHER('"'))) { } 0 0 0
elsif ($token->equals(T_OTHER('`'))) { } 0 0 0
750 0 return; }
751 ▶ elsif (($$token[1] == CC_OTHER) && ($token->toString =~ /^[0-9]$/)) { # Read decimal literal
Condition0%0/3
$token->[1] == 12 and $token->toString =~ /^[0-9]$/
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[1] == 12 and $token->toString =~ /^[0-9]$/
$token->[1] == 12 $token->toString =~ /^[0-9]$/
Truth table0%0/3
A and B
A= $token->[1] == 12B= $token->toString =~ /^[0-9]$/
ABresult
0X0
100
111
752 0 return Number(int($token->getString . $self->readDigits('0-9', 1))); }
753 elsif ($token->equals(T_OTHER("'"))) { # Read Octal literal
754 0 return Number(oct($self->readDigits('0-7', 1))); }
755 elsif ($token->equals(T_OTHER("\""))) { # Read Hex literal
756 0 return Number(hex($self->readDigits('0-9A-F', 1))); }
757 elsif ($token->equals(T_OTHER("`"))) { # Read Charcode
758 0 my $next = $self->readToken;
759 0 ▶ my $s = ($next && $next->toString) || '';
Condition0%0/5
$next && $next->toString || ''
l!l
00
$next and $next->toString
!ll&&!rl&&r
000
MC/DC0%0/2
$next && $next->toString || ''
$next $next->toString
Truth table0%0/3
A and B
A= $nextB= $next->toString
ABresult
111
0X0
100
760 0 $s =~ s/^\\//;
761 0 $self->skip1Space(1);
762 0 return Number(ord($s)); } # Only a character token!!! NOT expanded!!!!
763 else {
764 0 unshift(@{ $$self{pushback} }, $token); # Unread
765 0 return $self->readInternalInteger; } }
766  
767 sub readInternalInteger {
768 0 ▶ my ($self) = @_;
Subroutine readInternalInteger: not called CC=1 SCAR=6.9
Pod undocumented
769 0 return $self->readRegisterValue('Number'); }
770  
771 #======================================================================
772 # Float, a floating point number.
773 # Similar to factor, but does NOT accept comma!
774 # This is NOT part of TeX, but is convenient.
775 sub readFloat {
776 0 ▶ my ($self) = @_;
Subroutine readFloat: not called CC=9 SCAR=45.0
Pod undocumented
777 0 my $s = $self->readOptionalSigns;
778 0 my $string = $self->readDigits('0-9');
779 0 my $token = $self->readXToken;
780 0 ▶ if ($token && $token->getString =~ /^[\.]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token and $token->getString =~ /^[\.]$/) 0 0 0
Condition0%0/3
$token and $token->getString =~ /^[\.]$/
!ll&&!rl&&r
000
MC/DC0%0/2
$token and $token->getString =~ /^[\.]$/
$token $token->getString =~ /^[\.]$/
Truth table0%0/3
A and B
A= $tokenB= $token->getString =~ /^[\.]$/
ABresult
0X0
100
111
781 0 $string .= '.' . $self->readDigits('0-9');
782 0 $token = $self->readXToken; }
783 0 my $n;
784 0 ▶ if (length($string) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) { } 0 0 0
785 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token && $$token[1] != CC_SPACE; # Inline ->getCatcode, unread
Branch: 1 branch
BranchTrueFalseTotal
if $token and $token->[1] != 10 0 0 0
Condition0%0/3
$token and $token->[1] != 10
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
786 0 $n = $string; }
787 else {
788 0 ▶ unshift(@{ $$self{pushback} }, $token) if $token; # Unread
Branch: 1 branch
BranchTrueFalseTotal
if $token 0 0 0
789 0 $n = $self->readNormalInteger;
790 0 ▶ $n = $n->valueOf if defined $n; }
Branch: 1 branch
BranchTrueFalseTotal
if defined $n 0 0 0
791 0 ▶ return (defined $n ? Float($s * $n) : undef); }
Branch: 1 branch
BranchTrueFalseTotal
defined $n ? : 0 0 0
792  
793 #======================================================================
794 # Dimensions
795 #======================================================================
796 # <dimen> = <optional signs><unsigned dimen>
797 # <unsigned dimen> = <normal dimen> | <coerced dimen>
798 # <coerced dimen> = <internal glue>
799 sub readDimension {
800 0 ▶ my ($self) = @_;
Subroutine readDimension: not called CC=6 SCAR=37.4
Pod documented
801 0 my $s = $self->readOptionalSigns;
802 0 ▶ if (defined(my $d = $self->readInternalDimension)) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined(my $d = $self->readInternalDimension)) { } 0 0 0
elsif (defined($d = $self->readInternalGlue)) { } 0 0 0
elsif (defined($d = $self->readFactor)) { } 0 0 0
803 0 ▶ return ($s < 0 ? $d->negate : $d); }
Branch: 1 branch
BranchTrueFalseTotal
$s < 0 ? : 0 0 0
804 elsif (defined($d = $self->readInternalGlue)) {
805 0 return Dimension($s * $d->valueOf); }
806 elsif (defined($d = $self->readFactor)) {
807 0 my $unit = $self->readUnit;
808 0 ▶ if (!defined $unit) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $unit) 0 0 0
809 0 Warn('expected', '<unit>', $self, "Illegal unit of measure (pt inserted).");
810 0 $unit = 65536; }
811 0 return Dimension($s * $d * $unit); }
812 else {
813 0 Warn('expected', '<number>', $self, "Missing number (Dimension), treated as zero.",
814 "while processing " . ToString($LaTeXML::CURRENT_TOKEN), $self->showUnexpected);
815 0 return Dimension(0); } }
816  
817 # <unit of measure> = <optional spaces><internal unit>
818 # | <optional true><physical unit><one optional space>
819 # <internal unit> = em <one optional space> | ex <one optional space>
820 # | <internal integer> | <internal dimen> | <internal glue>
821 # <physical unit> = pt | pc | in | bp | cm | mm | dd | cc | sp
822  
823 # Read a unit, returning the equivalent number of scaled points,
824 sub readUnit {
825 0 ▶ my ($self) = @_;
Subroutine readUnit: not called CC=6 SCAR=37.4
Pod undocumented
826 0 ▶ if (defined(my $u = $self->readKeyword('ex', 'em'))) {
Branch: 4 branches
BranchTrueFalseTotal
if (defined(my $u = $self->readKeyword('ex', 'em'))) { } 0 0 0
elsif (defined($u = $self->readInternalInteger)) { } 0 0 0
elsif (defined($u = $self->readInternalDimension)) { } 0 0 0
elsif (defined($u = $self->readInternalGlue)) { } 0 0 0
827 0 $self->skip1Space(1);
828 0 return $STATE->convertUnit($u); }
829 elsif (defined($u = $self->readInternalInteger)) {
830 0 return $u->valueOf; } # These are coerced to number=>sp
831 elsif (defined($u = $self->readInternalDimension)) {
832 0 return $u->valueOf; }
833 elsif (defined($u = $self->readInternalGlue)) {
834 0 return $u->valueOf; }
835 else {
836 0 $self->readKeyword('true'); # But ignore, we're not bothering with mag...
837 0 my $units = $STATE->lookupValue('UNITS');
838 0 $u = $self->readKeyword(keys %$units);
839 0 ▶ if ($u) {
Branch: 1 branch
BranchTrueFalseTotal
if ($u) { } 0 0 0
840 0 $self->skip1Space(1);
841 0 return $STATE->convertUnit($u); }
842 else {
843 0 return; } } }
844  
845 # Return a dimension value or undef
846 sub readInternalDimension {
847 0 ▶ my ($self) = @_;
Subroutine readInternalDimension: not called CC=1 SCAR=6.9
Pod undocumented
848 0 return $self->readRegisterValue('Dimension'); }
849  
850 #======================================================================
851 # Mu Dimensions
852 #======================================================================
853 # <mudimen> = <optional signs><unsigned mudimem>
854 # <unsigned mudimen> = <normal mudimen> | <coerced mudimen>
855 # <normal mudimen> = <factor><mu unit>
856 # <mu unit> = <optional spaces><internal muglue> | mu <one optional space>
857 # <coerced mudimen> = <internal muglue>
858 sub readMuDimension {
859 0 ▶ my ($self) = @_;
Subroutine readMuDimension: not called CC=4 SCAR=30.0
Pod documented
860 0 my $s = $self->readOptionalSigns;
861 0 ▶ if (defined(my $m = $self->readFactor)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $m = $self->readFactor)) { } 0 0 0
elsif (defined($m = $self->readInternalMuGlue)) { } 0 0 0
862 0 my $munit = $self->readMuUnit;
863 0 ▶ if (!defined $munit) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $munit) 0 0 0
864 0 Warn('expected', '<unit>', $self, "Illegal unit of measure (mu inserted).");
865 0 $munit = $STATE->convertUnit('mu'); }
866 0 return MuDimension($s * $m * $munit); }
867 elsif (defined($m = $self->readInternalMuGlue)) {
868 0 return MuDimension($s * $m->valueOf); }
869 else {
870 0 Warn('expected', '<mudimen>', $self, "Expecting mudimen; assuming 0");
871 0 return MuDimension(0); } }
872  
873 sub readMuUnit {
874 0 ▶ my ($self) = @_;
Subroutine readMuUnit: not called CC=3 SCAR=24.8
Pod undocumented
875 0 ▶ if (my $m = $self->readKeyword('mu')) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $m = $self->readKeyword('mu')) { } 0 0 0
elsif ($m = $self->readInternalMuGlue) { } 0 0 0
876 0 $self->skip1Space(1);
877 0 return $STATE->convertUnit($m); }
878 elsif ($m = $self->readInternalMuGlue) {
879 0 return $m->valueOf; }
880 else {
881 0 return; } }
882  
883 #======================================================================
884 # Glue
885 #======================================================================
886 # <glue> = <optional signs><internal glue> | <dimen><stretch><shrink>
887 # <stretch> = plus <dimen> | plus <fil dimen> | <optional spaces>
888 # <shrink> = minus <dimen> | minus <fil dimen> | <optional spaces>
889 sub readGlue {
890 0 ▶ my ($self) = @_;
Subroutine readGlue: not called CC=7 SCAR=40.3
Pod documented
891 0 my $s = $self->readOptionalSigns;
892 0 my $n;
893 0 ▶ if (defined($n = $self->readInternalGlue)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($n = $self->readInternalGlue)) { } 0 0 0
894 0 ▶ return ($s < 0 ? $n->negate : $n); }
Branch: 1 branch
BranchTrueFalseTotal
$s < 0 ? : 0 0 0
895 else {
896 0 my $d = $self->readDimension;
897 0 ▶ if (!$d) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($d) 0 0 0
898 0 Warn('expected', '<number>', $self, "Missing number (Glue), treated as zero.",
899 "while processing " . ToString($LaTeXML::CURRENT_TOKEN), $self->showUnexpected);
900 0 return Glue(0); }
901 0 ▶ $d = $d->negate if $s < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $s < 0 0 0 0
902 0 my ($r1, $f1, $r2, $f2);
903 0 ▶ ($r1, $f1) = $self->readRubber if $self->readKeyword('plus');
Branch: 1 branch
BranchTrueFalseTotal
if $self->readKeyword("plus") 0 0 0
904 0 ▶ ($r2, $f2) = $self->readRubber if $self->readKeyword('minus');
Branch: 1 branch
BranchTrueFalseTotal
if $self->readKeyword("minus") 0 0 0
905 0 return Glue($d->valueOf, $r1, $f1, $r2, $f2); } }
906  
907 5 my %FILLS = (fil => 1, fill => 2, filll => 3); # [CONSTANT]
908  
909 sub readRubber {
910 0 ▶ my ($self, $mu) = @_;
Subroutine readRubber: not called CC=7 SCAR=40.3
Pod undocumented
911 0 my $s = $self->readOptionalSigns;
912 0 my $f = $self->readFactor;
913 0 ▶ if (!defined $f) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $f) { } 0 0 0
elsif (defined(my $fil = $self->readKeyword('filll', 'fill', 'fil'))) { } 0 0 0
elsif ($mu) { } 0 0 0
914 0 ▶ $f = ($mu ? $self->readMuDimension : $self->readDimension);
Branch: 1 branch
BranchTrueFalseTotal
$mu ? : 0 0 0
915 0 return ($f->valueOf * $s, 0); }
916 elsif (defined(my $fil = $self->readKeyword('filll', 'fill', 'fil'))) {
917 0 return ($s * $f, $FILLS{$fil}); }
918 elsif ($mu) {
919 0 my $u = $self->readMuUnit;
920 0 ▶ if (!defined $u) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $u) 0 0 0
921 0 Warn('expected', '<unit>', $self, "Illegal unit of measure (mu inserted).");
922 0 $u = $STATE->convertUnit('mu'); }
923 0 return ($s * $f * $u, 0); }
924 else {
925 0 my $u = $self->readUnit;
926 0 ▶ if (!defined $u) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $u) 0 0 0
927 0 Warn('expected', '<unit>', $self, "Illegal unit of measure (pt inserted).");
928 0 $u = 65536; }
929 0 return ($s * $f * $u, 0); } }
930  
931 # Return a glue value or undef.
932 sub readInternalGlue {
933 0 ▶ my ($self) = @_;
Subroutine readInternalGlue: not called CC=1 SCAR=6.9
Pod undocumented
934 0 return $self->readRegisterValue('Glue'); }
935  
936 #======================================================================
937 # Mu Glue
938 #======================================================================
939 # <muglue> = <optional signs><internal muglue> | <mudimen><mustretch><mushrink>
940 # <mustretch> = plus <mudimen> | plus <fil dimen> | <optional spaces>
941 # <mushrink> = minus <mudimen> | minus <fil dimen> | <optional spaces>
942 sub readMuGlue {
943 0 ▶ my ($self) = @_;
Subroutine readMuGlue: not called CC=7 SCAR=40.3
Pod documented
944 0 my $s = $self->readOptionalSigns;
945 0 my $n;
946 0 ▶ if (defined($n = $self->readInternalMuGlue)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($n = $self->readInternalMuGlue)) { } 0 0 0
947 0 ▶ return ($s < 0 ? $n->negate : $n); }
Branch: 1 branch
BranchTrueFalseTotal
$s < 0 ? : 0 0 0
948 else {
949 0 my $d = $self->readMuDimension;
950 0 ▶ if (!$d) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($d) 0 0 0
951 0 Warn('expected', '<number>', $self, "Missing number (MuGlue), treated as zero.",
952 "while processing " . ToString($LaTeXML::CURRENT_TOKEN), $self->showUnexpected);
953 0 return MuGlue(0); }
954 0 ▶ $d = $d->negate if $s < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $s < 0 0 0 0
955 0 my ($r1, $f1, $r2, $f2);
956 0 ▶ ($r1, $f1) = $self->readRubber(1) if $self->readKeyword('plus');
Branch: 1 branch
BranchTrueFalseTotal
if $self->readKeyword("plus") 0 0 0
957 0 ▶ ($r2, $f2) = $self->readRubber(1) if $self->readKeyword('minus');
Branch: 1 branch
BranchTrueFalseTotal
if $self->readKeyword("minus") 0 0 0
958 0 return MuGlue($d->valueOf, $r1, $f1, $r2, $f2); } }
959  
960 # Return a muglue value or undef.
961 sub readInternalMuGlue {
962 0 ▶ my ($self) = @_;
Subroutine readInternalMuGlue: not called CC=1 SCAR=6.9
Pod undocumented
963 0 return $self->readRegisterValue('MuGlue'); }
964  
965 #======================================================================
966 # See pp 272-275 for lists of the various registers.
967 # These are implemented in Primitive.pm
968  
969 #**********************************************************************
970 5 1;
971  
972 __END__
« lib/LaTeXML/Post/CrossRef.pm ↑ Summary lib/LaTeXML/Post/LaTeXImages.pm »