AST/Grammar/ECMAScript_262_5/StringNumericLiteral.pm

filter: Statementstmt 34.8% 23 / 66 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 24.0% 6 / 25 Podpod 100% 3 / 3 totaltotal 32.3% 32 / 99 CC 3 SCAR 10.6
CC
3
Cov
33%
new
12.0
make_grammar_content
2.0
recce_option
2.0
CRAP 2.9
« AST/Grammar/ECMAScript_262_5.pm ↑ Summary AST/Grammar/ECMAScript_262_5/Program/Semantics.pm »
1 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral;
5 5 ▶use parent qw/MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral::NativeNumberSemantics;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use SUPER;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: ECMAScript-262, Edition 5, string numeric literal grammar written in Marpa BNF
11  
12 5 our $VERSION = '0.020'; # VERSION
13  
14  
15 #
16 # Note that this grammar is NOT supposed to be injected in Program
17 #
18 5 our $grammar_content = do {local $/; <DATA>};
19  
20  
21 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
22 0 my ($class, $optionsp) = @_;
23  
24 0 ▶ $optionsp //= {};
Condition0%0/2
$optionsp //= {}
l!l
00
MC/DC0%0/1
$optionsp //= {}
$optionsp
Truth table0%0/2
A
A= $optionsp
Aresult
11
00
25  
26 0 ▶ my $semantics_package = exists($optionsp->{semantics_package}) ? $optionsp->{semantics_package} : join('::', $class, 'NativeNumberSemantics');
Branch: 1 branch
BranchTrueFalseTotal
exists $optionsp->{'semantics_package'} ? : 0 0 0
27  
28 0 my $self = $class->SUPER();
29  
30 #
31 # Add semantics package to self
32 #
33 0 $self->{_semantics_package} = $semantics_package;
34  
35 0 return $self;
36 }
37  
38  
39 0 ▶sub make_grammar_content {
Subroutine make_grammar_content: not called CC=1 SCAR=6.9
Pod documented
40 0 my ($class) = @_;
41 0 return $grammar_content;
42 }
43  
44  
45 0 ▶sub recce_option {
Subroutine recce_option: not called CC=1 SCAR=6.9
Pod documented
46 0 my ($self) = @_;
47 #
48 # Get default hash
49 #
50 0 my $default = $self->SUPER();
51 #
52 # And overwrite the semantics_package
53 #
54 0 $default->{semantics_package} = $self->{_semantics_package};
55  
56 0 return $default;
57 }
58  
59 #
60 # INTERNAL ACTIONS
61 #
62  
63 0 ▶sub _secondArg {
Subroutine _secondArg: not called CC=1 SCAR=6.9
64 0 return $_[2];
65 }
66  
67 0 ▶sub _value {
Subroutine _value: not called CC=1 SCAR=6.9
68 0 return _secondArg(@_)->host_value;
69 }
70  
71 0 ▶sub _value_zero {
Subroutine _value_zero: not called CC=1 SCAR=6.9
72 0 return $_[0]->pos_zero->host_value;
73 }
74  
75 0 ▶sub _Infinity {
Subroutine _Infinity: not called CC=1 SCAR=6.9
76 0 return $_[0]->pos_inf;
77 }
78  
79 #
80 # Note that HexIntegerLiteral output is a HexDigit modified
81 #
82 0 ▶sub _HexIntegerLiteral_HexDigit {
Subroutine _HexIntegerLiteral_HexDigit: not called CC=1 SCAR=6.9
83 0 my $sixteen = $_[0]->clone_init->int("16");
84  
85 0 return $_[1]->mul($sixteen)->add($_[2]);
86 }
87  
88 #
89 # Note that DecimalDigits output is a DecimalDigit modified
90 #
91 0 ▶sub _DecimalDigits_DecimalDigit {
Subroutine _DecimalDigits_DecimalDigit: not called CC=1 SCAR=6.9
92 0 my $ten = $_[0]->clone_init->int("10");
93 0 return $_[1]->mul($ten)->add($_[2])->inc_length;
94 }
95  
96 0 ▶sub _Dot_DecimalDigits_ExponentPart {
Subroutine _Dot_DecimalDigits_ExponentPart: not called CC=1 SCAR=6.9
97 0 my $n = $_[2]->new_from_length;
98 0 my $tenpowexponentminusn = $_[0]->clone_init->int("10")->pow($_[3]->sub($n));
99  
100 0 $_[2]->decimalOn;
101 0 return $_[2]->mul($tenpowexponentminusn);
102 }
103  
104 0 ▶sub _DecimalDigits_Dot {
Subroutine _DecimalDigits_Dot: not called CC=1 SCAR=6.9
105 0 $_[1]->decimalOn;
106 0 return $_[1];
107 }
108  
109 0 ▶sub _DecimalDigits_Dot_DecimalDigits_ExponentPart {
Subroutine _DecimalDigits_Dot_DecimalDigits_ExponentPart: not called CC=1 SCAR=6.9
110 #
111 # Done using polish logic -;
112 #
113 0 $_[1]->decimalOn;
114 0 return $_[1]->add(
115 _DecimalDigits_ExponentPart(
116 $_[0],
117 _Dot_DecimalDigits($_[0], '.', $_[3]),
118 $_[4])
119 );
120 }
121  
122 0 ▶sub _DecimalDigits_Dot_ExponentPart {
Subroutine _DecimalDigits_Dot_ExponentPart: not called CC=1 SCAR=6.9
123 0 my $tenpowexponent = $_[0]->clone_init->int("10")->pow($_[3]);
124 0 $_[1]->decimalOn;
125 0 return $_[1]->mul($tenpowexponent);
126 }
127  
128 0 ▶sub _DecimalDigits_Dot_DecimalDigits {
Subroutine _DecimalDigits_Dot_DecimalDigits: not called CC=1 SCAR=6.9
129 0 $_[1]->decimalOn;
130 0 return $_[1]->add(_Dot_DecimalDigits($_[0], '.', $_[3]));
131 }
132  
133 0 ▶sub _Dot_DecimalDigits {
Subroutine _Dot_DecimalDigits: not called CC=1 SCAR=6.9
134 0 my $n = $_[2]->new_from_length;
135 0 my $tenpowminusn = $_[0]->clone_init->int("10")->pow($n->neg);
136 0 $_[2]->decimalOn;
137 0 return $_[2]->mul($tenpowminusn);
138 }
139  
140 0 ▶sub _DecimalDigits_ExponentPart {
Subroutine _DecimalDigits_ExponentPart: not called CC=1 SCAR=6.9
141 0 my $tenpowexponent = $_[0]->clone_init->int("10")->pow($_[2]);
142  
143 0 $_[1]->decimalOn;
144 0 return $_[1]->mul($tenpowexponent);
145 }
146  
147 0 ▶sub _HexDigit {
Subroutine _HexDigit: not called CC=1 SCAR=6.9
148 0 return $_[0]->clone_init->hex("$_[1]");
149 }
150  
151 0 ▶sub _DecimalDigit {
Subroutine _DecimalDigit: not called CC=1 SCAR=6.9
152 0 return $_[0]->clone_init->int("$_[1]");
153 }
154  
155 0 ▶sub _neg {
Subroutine _neg: not called CC=1 SCAR=6.9
156 0 return $_[2]->neg;
157 }
158  
159  
160 5 1;
161  
162 =pod
163  
164 =encoding UTF-8
165  
166 =head1 NAME
167  
168 MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral - ECMAScript-262, Edition 5, string numeric literal grammar written in Marpa BNF
169  
170 =head1 VERSION
171  
172 version 0.020
173  
174 =head1 SYNOPSIS
175  
176 use strict;
177 use warnings FATAL => 'all';
178 use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral;
179  
180 my $grammar = MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral->new();
181  
182 my $grammar_content = $grammar->content();
183 my $grammar_option = $grammar->grammar_option();
184 my $recce_option = $grammar->recce_option();
185  
186 =head1 DESCRIPTION
187  
188 This modules returns describes the ECMAScript 262, Edition 5 string numeric literal grammar written in Marpa BNF, as of L<http://www.ecma-international.org/publications/standards/Ecma-262.htm>, section 9.3.1. This module inherits the methods from MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base package.
189  
190 =head1 SUBROUTINES/METHODS
191  
192 =head2 new($optionsp)
193  
194 $optionsp is a reference to hash that may contain the following key/value pair:
195  
196 =over
197  
198 =item semantics_package
199  
200 As per Marpa::R2, The semantics package is used when resolving action names to fully qualified Perl names. This package must support and behave as documented in the NativeNumberSemantics (c.f. SEE ALSO).
201  
202 =back
203  
204 =head2 make_grammar_content($class)
205  
206 Returns the grammar. This will be injected in the Program's grammar.
207  
208 =head2 recce_option($self)
209  
210 Returns option for Marpa::R2::Scanless::R->new(), returned as a reference to a hash.
211  
212 =head1 SEE ALSO
213  
214 L<Data::Float>
215  
216 L<Scalar::Util::Numeric>
217  
218 L<Math::BigFloat>
219  
220 L<MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base>
221  
222 L<MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral::NativeNumberSemantics>
223  
224 =head1 AUTHOR
225  
226 Jean-Damien Durand <jeandamiendurand@free.fr>
227  
228 =head1 COPYRIGHT AND LICENSE
229  
230 This software is copyright (c) 2013 by Jean-Damien Durand.
231  
232 This is free software; you can redistribute it and/or modify it under
233 the same terms as the Perl 5 programming language system itself.
234  
235 =cut
236  
237 __DATA__
« AST/Grammar/ECMAScript_262_5.pm ↑ Summary AST/Grammar/ECMAScript_262_5/Program/Semantics.pm »