| 1 | # /=====================================================================\ # | ||||||||||||||||||||||||||||||||||
| 2 | # | LaTeXML::Core::Parameters | # | ||||||||||||||||||||||||||||||||||
| 3 | # | Representation of Parameters for Control Sequences | # | ||||||||||||||||||||||||||||||||||
| 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 | package LaTeXML::Core::Parameters; | ||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use LaTeXML::Global; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use LaTeXML::Common::Object; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use LaTeXML::Common::Error; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use LaTeXML::Core::Parameter; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use LaTeXML::Core::Tokens; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use base qw(LaTeXML::Common::Object); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 23 | 0 | my ($class, @paramspecs) = @_; | |||||||||||||||||||||||||||||||||
| 24 | 0 | return bless [@paramspecs], $class; } | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub getParameters { | ||||||||||||||||||||||||||||||||
|
Subroutine
getParameters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 27 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 28 | 0 | return @$self; } | |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 31 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 32 | 0 | my $string = ''; | |||||||||||||||||||||||||||||||||
| 33 | 0 | foreach my $parameter (@$self) { | |||||||||||||||||||||||||||||||||
| 34 | 0 | my $s = $parameter->stringify; | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $string .= ' ' if ($string =~ /\w$/) && ($s =~ /^\w/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$string =~ /\w$/ and $s =~ /^\w/
MC/DC0%0/2
$string =~ /\w$/ and $s =~ /^\w/
$string =~ /\w$/
$s =~ /^\w/
Truth table0%0/3
A and B
A= $string =~ /\w$/B= $s =~ /^\w/
| |||||||||||||||||||||||||||||||||||
| 36 | 0 | $string .= $s; } | |||||||||||||||||||||||||||||||||
| 37 | 0 | return $string; } | |||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub equals { | ||||||||||||||||||||||||||||||||
|
Subroutine
equals: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 40 | 0 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return (defined $other) | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $other && ref $self eq ref $other && $self->stringify eq $other->stringify
defined $other and ref $self eq ref $other
MC/DC0%0/3
defined $other && ref $self eq ref $other && $self->stringify eq $other->stringify
defined $other
ref $self eq ref $other
$self->stringify eq $other->stringify
Truth table0%0/4
A and B && C
A= defined $otherB= ref $self eq ref $otherC= $self->stringify eq $other->stringify
| |||||||||||||||||||||||||||||||||||
| 42 | && ((ref $self) eq (ref $other)) && ($self->stringify eq $other->stringify); } | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub getNumArgs { | ||||||||||||||||||||||||||||||||
|
Subroutine
getNumArgs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 46 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||
| 47 | 0 | foreach my $parameter (@$self) { | |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $n++ unless $$parameter{novalue}; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 49 | 0 | return $n; } | |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub revertArguments { | ||||||||||||||||||||||||||||||||
|
Subroutine
revertArguments: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 52 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||
| 53 | 0 | my @tokens = (); | |||||||||||||||||||||||||||||||||
| 54 | 0 | foreach my $parameter (@$self) { | |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | next if $$parameter{novalue}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 56 | 0 | push(@tokens, $parameter->revert(shift(@args))); } | |||||||||||||||||||||||||||||||||
| 57 | 0 | return @tokens; } | |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub readArguments { | ||||||||||||||||||||||||||||||||
|
Subroutine
readArguments: not called CC=3 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $gullet, $fordefn) = @_; | |||||||||||||||||||||||||||||||||
| 62 | 0 | my @args = (); | |||||||||||||||||||||||||||||||||
| 63 | 0 | my ($p, $v); | |||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return map { $p = $_; $v = $p && $p->read($gullet, $fordefn); ($$p{novalue} ? () : $v); } @$self; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p && $p->read($gullet, $fordefn)
MC/DC0%0/2
$p && $p->read($gullet, $fordefn)
$p
$p->read($gullet, $fordefn)
Truth table0%0/3
A && B
A= $pB= $p->read($gullet, $fordefn)
| |||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub readArgumentsAndDigest { | ||||||||||||||||||||||||||||||||
|
Subroutine
readArgumentsAndDigest: not called CC=3 SCAR=20.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 68 | 0 | my ($self, $stomach, $fordefn) = @_; | |||||||||||||||||||||||||||||||||
| 69 | 0 | my @args = (); | |||||||||||||||||||||||||||||||||
| 70 | 0 | my $gullet = $stomach->getGullet; | |||||||||||||||||||||||||||||||||
| 71 | 0 | foreach my $parameter (@$self) { | |||||||||||||||||||||||||||||||||
| 72 | 0 | my $value = $parameter->read($gullet, $fordefn); | |||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (!$$parameter{novalue}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | 0 | $value = $parameter->digest($stomach, $value, $fordefn); | |||||||||||||||||||||||||||||||||
| 75 | 0 | push(@args, $value); } } | |||||||||||||||||||||||||||||||||
| 76 | 0 | return @args; } | |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub reparseArgument { | ||||||||||||||||||||||||||||||||
|
Subroutine
reparseArgument: not called CC=2 SCAR=13.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($self, $gullet, $tokens) = @_; | |||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if (defined $tokens) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return $gullet->readingFromMouth(LaTeXML::Core::Mouth->new(), sub { # start with empty mouth | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 83 | 0 | my ($gulletx) = @_; | |||||||||||||||||||||||||||||||||
| 84 | 0 | $gulletx->unread($tokens); # but put back tokens to be read | |||||||||||||||||||||||||||||||||
| 85 | 0 | my @values = $self->readArguments($gulletx); | |||||||||||||||||||||||||||||||||
| 86 | 0 | $gulletx->skipSpaces; | |||||||||||||||||||||||||||||||||
| 87 | 0 | return @values; }); } | |||||||||||||||||||||||||||||||||
| 88 | else { | ||||||||||||||||||||||||||||||||||
| 89 | 0 | return (); } } | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | #====================================================================== | ||||||||||||||||||||||||||||||||||
| 92 | 5 | 1; | |||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||||||||