| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Here is the exhaustive list of difficulties with the ECMAScript grammar: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # * The list of reserved keywords is context sensitive (depend on strict mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # * The source CAN be not ok v.s. semi-colon: automatic semi-colon insertion will then happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # * Allowed separators is contextual (sometimes no line terminator is allowed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # * RegularExpressionLiteral ambiguity with AssignmentExpression or MultiplicativeExpression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use parent qw/MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::Semantics; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::RegularExpressionLiteral; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::StringLiteral; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::NumericLiteral; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use MarpaX::Languages::ECMAScript::AST::Exceptions qw/:all/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #use Log::Any qw/$log/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use SUPER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # ABSTRACT: ECMAScript-262, Edition 5, lexical program grammar written in Marpa BNF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | our $VERSION = '0.020'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | our $WhiteSpace = qr/(?:[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsWhiteSpace}])/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | our $LineTerminator = qr/(?:[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsLineTerminator}])/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | our $SingleLineComment = qr/(?:\/\/[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsSourceCharacterButNotLineTerminator}]*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | our $MultiLineComment = qr/(?:(?:\/\*)(?:(?:[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsSourceCharacterButNotStar}]+|\*(?![\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsSourceCharacterButNotSlash}]))*)(?:\*\/))/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | our $UnicodeLetter = qr/[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsUnicodeLetter}]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | our $HexDigit4 = qr/[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsHexDigit}]{4}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | our $S = qr/(?:$WhiteSpace|$LineTerminator|$SingleLineComment|$MultiLineComment)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | our $isPostLineTerminatorLength = qr/\G$S+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | our $isPreSLength = qr/\G$S+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | our $isRcurly = qr/\G$S*\}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | our $isEnd = qr/\G$S*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | our $isDecimalDigit = qr/\G[\p{MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::CharacterClasses::IsDecimalDigit}]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | our $isIdentifierStart = qr/\G(?:$UnicodeLetter|\$|_|\\u$HexDigit4)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | our @Keyword = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | qw/break do instanceof typeof | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | case else new var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | catch finally return void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | continue for switch while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | debugger function this with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | default if throw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | delete in try/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | our @FutureReservedWord = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | qw/class enum extends super | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | const export import/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | our @FutureReservedWordStrict = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | qw/implements let private public yield | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | interface package protected static/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | our @NullLiteral = qw/null/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | our @BooleanLiteral = qw/true false/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Force eventual higher priority | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | our %PRIORITY = (FUNCTION => 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | our $grammar_content = do {local $/; <DATA>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # It is clearer to have reserved words in an array. But for efficienvy the hash is better, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # so I create on-the-fly associated hashes using the arrays. Convention is: the lexeme name of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # a reserved word is this word, but in capital letters (since none of them is in capital letter) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | our %Keyword = map {($_, uc($_))} @Keyword; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | our %FutureReservedWord = map {($_, uc($_))} @FutureReservedWord; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | our %FutureReservedWordStrict = map {($_, uc($_))} @FutureReservedWordStrict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | our %NullLiteral = map {($_, uc($_))} @NullLiteral; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | our %BooleanLiteral = map {($_, uc($_))} @BooleanLiteral; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # ... And we inject in the grammar those that exist (FutureReservedWord do not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | $grammar_content .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # ... Priorities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | map {$grammar_content .= ":lexeme ~ <$_> priority => " . ($PRIORITY{$_} || 1) . "\n"} values %Keyword; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
MC/DC100%1/1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
Truth table100%2/2
A
A= $MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | map {$grammar_content .= ":lexeme ~ <$_> priority => " . ($PRIORITY{$_} || 1) . "\n"} values %NullLiteral; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
MC/DC0%0/1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
Truth table50%1/2
A
A= $MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | ▶ | map {$grammar_content .= ":lexeme ~ <$_> priority => " . ($PRIORITY{$_} || 1) . "\n"} values %BooleanLiteral; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
MC/DC0%0/1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_} || 1
$MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
Truth table50%1/2
A
A= $MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program::PRIORITY{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # ... Definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | map {$grammar_content .= uc($_) . " ~ '$_'\n"} @Keyword; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | map {$grammar_content .= uc($_) . " ~ '$_'\n"} @NullLiteral; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | map {$grammar_content .= uc($_) . " ~ '$_'\n"} @BooleanLiteral; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # Injection of grammars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | our $StringLiteral = MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::StringLiteral->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | our $RegularExpressionLiteral = MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::RegularExpressionLiteral->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 5 | our $NumericLiteral = MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Lexical::NumericLiteral->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 5 | $grammar_content .= $StringLiteral->extract; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 5 | $grammar_content .= $NumericLiteral->extract; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | $grammar_content .= $RegularExpressionLiteral->extract; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # For convenience in the IDENTIFIER$ lexeme callback, we merge Keyword, FutureReservedWord, NullLiteral, BooleanLiteral into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # a single hash ReservedWord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | our %ReservedWord = map {$_ => 1} (keys %Keyword, keys %FutureReservedWord, keys %NullLiteral, keys %BooleanLiteral); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub make_grammar_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_grammar_content: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $grammar_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub make_semantics_package { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_semantics_package: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return join('::', $class, 'Semantics'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub spacesAny { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spacesAny: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{_spacesAny} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return $self->{_spacesAny}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($self, $source, $impl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # Because of Automatic Semicolon Insertion that may happen at the end, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # a space is appended to a copy of the source to be parsed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->{programCompleted} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $source .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return $self->SUPER($source, $impl, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | callback => \&_eventCallback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | callbackargs => [ $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | failure => \&_failureCallback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | failureargs => [ $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | end => \&_endCallback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | endargs => [ $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub _eventCallback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eventCallback: not called CC=38 SCAR=73.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($self, $source, $pos, $max, $impl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # $pos is the exact position where SLIF stopped because of an event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $rc = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my %lastLexeme = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $lastLexemeDoneb = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Cache of some call results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->{_isIdentifierStart} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $self->{_isDecimalDigit} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->{_preSLength} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->{_isEnd} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{_postLineTerminatorLength} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | foreach (@{$impl->events()}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ($name) = @{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Events are always in this order: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # --------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # 1. Completion events first (XXX$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # --------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($name eq 'Program$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Program$ will happen rarely, so even it does cost it is ok to do so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $self->{programCompleted} = ($self->{_isEnd}->{$pos} //= $self->_isEnd($source, $pos, $impl)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_isEnd"}{$pos} //= $self->_isEnd($source, $pos, $impl)
MC/DC0%0/2
$self->{"_isEnd"}{$pos} //= $self->_isEnd($source, $pos, $impl)
$self->{"_isEnd"}{$pos}
$self->_isEnd($source, $pos, $impl)
Truth table0%0/3
A //= B
A= $self->{"_isEnd"}{$pos}B= $self->_isEnd($source, $pos, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ($name eq 'NumericLiteral$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # The source character immediately following a NumericLiteral must not be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # an IdentifierStart or DecimalDigit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if (($self->{_isIdentifierStart}->{$pos} //= $self->_isIdentifierStart($source, $pos, $impl)) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->{"_isIdentifierStart"}{$pos} //= $self->_isIdentifierStart($source, $pos, $impl) or $self->{"_isDecimalDigit"}{$pos} //= $self->_isDecimalDigit($source, $pos, $impl)
$self->{"_isIdentifierStart"}{$pos} //= $self->_isIdentifierStart($source, $pos, $impl)
$self->{"_isDecimalDigit"}{$pos} //= $self->_isDecimalDigit($source, $pos, $impl)
MC/DC0%0/4
$self->{"_isIdentifierStart"}{$pos} //= $self->_isIdentifierStart($source, $pos, $impl) or $self->{"_isDecimalDigit"}{$pos} //= $self->_isDecimalDigit($source, $pos, $impl)
$self->{"_isIdentifierStart"}{$pos}
$self->_isIdentifierStart($source, $pos, $impl)
$self->{"_isDecimalDigit"}{$pos}
$self->_isDecimalDigit($source, $pos, $impl)
Truth table0%0/5
A //= B or C //= D
A= $self->{"_isIdentifierStart"}{$pos}B= $self->_isIdentifierStart($source, $pos, $impl)C= $self->{"_isDecimalDigit"}{$pos}D= $self->_isDecimalDigit($source, $pos, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ($self->{_isDecimalDigit}->{$pos} //= $self->_isDecimalDigit($source, $pos, $impl))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my ($start, $end) = $impl->last_completed_range('NumericLiteral'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $lastNumericLiteral = $impl->range_to_string($start, $end); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | SyntaxError(error => "NumericLiteral $lastNumericLiteral must not be immediately followed by an IdentifierStart or DecimalDigit"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | elsif ($name eq 'IDENTIFIER$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if (! $lastLexemeDoneb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->getLastLexeme(\%lastLexeme, $impl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $lastLexemeDoneb = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if (exists($ReservedWord{$lastLexeme{value}})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | SyntaxError(error => "Identifier $lastLexeme{value} is a reserved word"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # ------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # 2. nulled events (XXX[]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # ------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # ------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # 3. prediction events (^XXX or ^^XXX) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # ------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | elsif ($name eq '^INVISIBLE_SEMICOLON') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # In the AST, we explicitely associate the ';' to the missing semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (! $lastLexemeDoneb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->getLastLexeme(\%lastLexeme, $impl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $lastLexemeDoneb = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $Slength = ($self->{_preSLength}->{$rc} //= $self->_preSLength($source, $rc, $impl)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
MC/DC0%0/2
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
$self->{"_preSLength"}{$rc}
$self->_preSLength($source, $rc, $impl)
Truth table0%0/3
A //= B
A= $self->{"_preSLength"}{$rc}B= $self->_preSLength($source, $rc, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->_insertInvisibleSemiColon($impl, $rc, $Slength); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $rc += $Slength; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # ^PLUSPLUS_POSTFIX, ^MINUSMINUS_POSTFIX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # -------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ▶ | elsif ($name eq '^PLUSPLUS_POSTFIX' || $name eq '^MINUSMINUS_POSTFIX') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$name eq "^PLUSPLUS_POSTFIX" or $name eq "^MINUSMINUS_POSTFIX"
MC/DC0%0/2
$name eq "^PLUSPLUS_POSTFIX" or $name eq "^MINUSMINUS_POSTFIX"
$name eq "^PLUSPLUS_POSTFIX"
$name eq "^MINUSMINUS_POSTFIX"
Truth table0%0/3
A or B
A= $name eq "^PLUSPLUS_POSTFIX"B= $name eq "^MINUSMINUS_POSTFIX"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (! $lastLexemeDoneb) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->getLastLexeme(\%lastLexeme, $impl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $lastLexemeDoneb = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $postLineTerminatorPos = $lastLexeme{start} + $lastLexeme{length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $postLineTerminatorLength = ($self->{_postLineTerminatorLength}->{$postLineTerminatorPos} //= $self->_postLineTerminatorLength($source, $postLineTerminatorPos, $impl)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_postLineTerminatorLength"}{$postLineTerminatorPos} //= $self->_postLineTerminatorLength($source, $postLineTerminatorPos, $impl)
MC/DC0%0/2
$self->{"_postLineTerminatorLength"}{$postLineTerminatorPos} //= $self->_postLineTerminatorLength($source, $postLineTerminatorPos, $impl)
$self->{"_postLineTerminatorLength"}{$postLineTerminatorPos}
$self->_postLineTerminatorLength($source, $postLineTerminatorPos, $impl)
Truth table0%0/3
A //= B
A= $self->{"_postLineTerminatorLength"}{$postLineTerminatorPos}B= $self->_postLineTerminatorLength($source, $postLineTerminatorPos, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $asi = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ($postLineTerminatorLength > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if (! $impl->lexeme_read('SEMICOLON', $postLineTerminatorPos, $postLineTerminatorLength, ';')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | SyntaxError(error => "SEMICOLON lexeme_read failure at position $rc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $asi = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $lname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | substr($lname, 0, 1, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | my $lvalue = ($lname eq 'PLUSPLUS_POSTFIX') ? '++' : '--'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # The value does not change if ASI was performed. But the name, yes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($asi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | $lname = ($lname eq 'PLUSPLUS_POSTFIX') ? 'PLUSPLUS' : 'MINUSMINUS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (! $impl->lexeme_read($lname, $rc, 2, $lvalue)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | SyntaxError(error => "$lname lexeme_read failure at position $rc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $rc += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # ^^DIV (because of REGULAREXPRESSIONLITERAL that can eat it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # ----------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif ($name eq '^^DIV') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my $realpos = $rc + ($self->{_preSLength}->{$rc} //= $self->_preSLength($source, $rc, $impl)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
MC/DC0%0/2
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
$self->{"_preSLength"}{$rc}
$self->_preSLength($source, $rc, $impl)
Truth table0%0/3
A //= B
A= $self->{"_preSLength"}{$rc}B= $self->_preSLength($source, $rc, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if (index($source, '/', $realpos) == $realpos && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
index($source, "/", $realpos) == $realpos and index($source, "/=", $realpos) != $realpos and index($source, "//", $realpos) != $realpos and index($source, "/*", $realpos) != $realpos
index($source, "/", $realpos) == $realpos and index($source, "/=", $realpos) != $realpos and index($source, "//", $realpos) != $realpos
index($source, "/", $realpos) == $realpos and index($source, "/=", $realpos) != $realpos
MC/DC0%0/4
index($source, "/", $realpos) == $realpos and index($source, "/=", $realpos) != $realpos and index($source, "//", $realpos) != $realpos and index($source, "/*", $realpos) != $realpos
index($source, "/", $realpos) == $realpos
index($source, "/=", $realpos) != $realpos
index($source, "//", $realpos) != $realpos
index($source, "/*", $realpos) != $realpos
Truth table0%0/5
A and B and C and D
A= index($source, "/", $realpos) == $realposB= index($source, "/=", $realpos) != $realposC= index($source, "//", $realpos) != $realposD= index($source, "/*", $realpos) != $realpos
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | index($source, '/=', $realpos) != $realpos && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | index($source, '//', $realpos) != $realpos && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | index($source, '/*', $realpos) != $realpos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if (! $impl->lexeme_read('DIV', $realpos, 1, '/')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | SyntaxError(error => "DIV lexeme_read failure at position $rc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $rc = $realpos + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # ^^DIVASSIGN (because of REGULAREXPRESSIONLITERAL that can eat it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | elsif ($name eq '^^DIVASSIGN') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $realpos = $rc + ($self->{_preSLength}->{$rc} //= $self->_preSLength($source, $rc, $impl)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
MC/DC0%0/2
$self->{"_preSLength"}{$rc} //= $self->_preSLength($source, $rc, $impl)
$self->{"_preSLength"}{$rc}
$self->_preSLength($source, $rc, $impl)
Truth table0%0/3
A //= B
A= $self->{"_preSLength"}{$rc}B= $self->_preSLength($source, $rc, $impl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if (index($source, '/=', $realpos) == $realpos && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
index($source, "/=", $realpos) == $realpos and index($source, "//", $realpos) != $realpos and index($source, "/*", $realpos) != $realpos
index($source, "/=", $realpos) == $realpos and index($source, "//", $realpos) != $realpos
MC/DC0%0/3
index($source, "/=", $realpos) == $realpos and index($source, "//", $realpos) != $realpos and index($source, "/*", $realpos) != $realpos
index($source, "/=", $realpos) == $realpos
index($source, "//", $realpos) != $realpos
index($source, "/*", $realpos) != $realpos
Truth table0%0/4
A and B and C
A= index($source, "/=", $realpos) == $realposB= index($source, "//", $realpos) != $realposC= index($source, "/*", $realpos) != $realpos
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | index($source, '//', $realpos) != $realpos && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | index($source, '/*', $realpos) != $realpos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if (! $impl->lexeme_read('DIVASSIGN', $realpos, 2, '/=')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | SyntaxError(error => "DIVASSIGN lexeme_read failure at position $rc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $rc = $realpos + 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # Remove cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | delete($self->{_isIdentifierStart}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | delete($self->{_isDecimalDigit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | delete($self->{_preSLength}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | delete($self->{_isEnd}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | delete($self->{_postLineTerminatorLength}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | #if ($rc != $pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # $log->tracef('[_eventCallback] Resuming at position %d (was %d when called)', $rc, $pos); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub _postLineTerminatorLength { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_postLineTerminatorLength: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $prevpos = pos($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | pos($_[1]) = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # Take care: the separator is: _WhiteSpace | _LineTerminator | _SingleLineComment | _MultiLineComment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # where a _MultiLineComment that contains a _LineTerminator is considered equivalent to a _LineTerminator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # This is why if we find a separator just before $pos, we check again the presence of _LineTerminator in the match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($_[1] =~ $isPostLineTerminatorLength) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $length = $+[0] - $-[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if (substr($_[1], $-[0], $length) =~ /$LineTerminator/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $rc = $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | #if ($rc > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # $log->tracef('[_postLineTerminatorLength] Found postLineTerminator of length %d', $rc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | pos($_[1]) = $prevpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub _preSLength { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_preSLength: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $prevpos = pos($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | pos($_[1]) = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($_[1] =~ $isPreSLength) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $length = $+[0] - $-[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $rc = $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | #if ($rc > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # $log->tracef('[_preSLength] Found S of length %d', $rc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | pos($_[1]) = $prevpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub _isRcurly { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isRcurly: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $prevpos = pos($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | pos($_[1]) = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ($_[1] =~ $isRcurly) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $rc = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | #if ($rc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # $log->tracef('[_isRcurly] Found \'}\''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | pos($_[1]) = $prevpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub _isIdentifierStart { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isIdentifierStart: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $prevpos = pos($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | pos($_[1]) = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($_[1] =~ $isIdentifierStart) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $rc = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | #if ($rc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # $log->tracef('[_isIdentifierStart] Found \'%s\'', $&); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | pos($_[1]) = $prevpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub _isDecimalDigit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isDecimalDigit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $rc = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $prevpos = pos($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | pos($_[1]) = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ($_[1] =~ $isDecimalDigit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $rc = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | #if ($rc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # $log->tracef('[_isDecimalDigit] Found \'%s\'', $&); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | pos($_[1]) = $prevpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | sub _isEnd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isEnd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # my ($self, $source, $pos, $impl) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $grammar = $_[0]->spacesAny->{grammar}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $impl = $_[0]->spacesAny->{impl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $grammar->parse($_[1], $impl, $_[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | return $grammar->endReached; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | sub _insertSemiColon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insertSemiColon: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ($self, $impl, $pos, $length) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (! $impl->lexeme_read('SEMICOLON', $pos, $length, ';')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | SyntaxError(error => "Automatic Semicolon Insertion not allowed at position $pos"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub _insertInvisibleSemiColon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insertInvisibleSemiColon: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my ($self, $impl, $pos, $length) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if (! $impl->lexeme_read('INVISIBLE_SEMICOLON', $pos, $length, ';')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | SyntaxError(error => "Automatic Invisible Semicolon Insertion not allowed at position $pos"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | sub _failureCallback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_failureCallback: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my ($self, $source, $pos, $max, $impl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # The position of failure is exactly the end of the very last lexeme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my %lastLexeme = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->getLastLexeme(\%lastLexeme, $impl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $rc = $lastLexeme{start} + $lastLexeme{length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # Automatic Semicolon Insertion rules apply here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # 1. When, as the program is parsed from left to right, a token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # (called the offending token) is encountered that is not allowed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # by any production of the grammar, then a semicolon is automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # inserted before the offending token if one or more of the following conditions is true: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # - The offending token is separated from the previous token by at least one LineTerminator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # - The offending token is }. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $length = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if (($length = $self->_postLineTerminatorLength($source, $rc, $impl)) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $self->_insertSemiColon($impl, $rc, $length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $rc += $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } elsif ($self->_isRcurly($source, $rc, $impl)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $self->_insertSemiColon($impl, $rc, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | SyntaxError(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub _endCallback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_endCallback: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my ($self, $source, $pos, $max, $impl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if ($self->{programCompleted}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # Automatic Semicolon Insertion rules apply here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # 2. When, as the program is parsed from left to right, the end of the input stream of tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # is encountered and the parser is unable to parse the input token stream as a single complete ECMAScript Program | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # then a semicolon is automatically inserted at the end of the input stream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if (! $self->{programCompleted}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my %lastLexeme = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $self->getLastLexeme(\%lastLexeme, $impl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my $lastValidPos = $lastLexeme{start} + $lastLexeme{length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $self->_insertSemiColon($impl, $lastValidPos, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $haveProgramCompletion = grep {$_ eq 'Program$'} map {$_->[0]} @{$impl->events}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if (! $haveProgramCompletion) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | SyntaxError(error => "Incomplete program"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program - ECMAScript-262, Edition 5, lexical program grammar written in Marpa BNF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | version 0.020 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | use MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | my $grammar = MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Program->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | my $grammar_content = $grammar->content(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | my $grammar_option = $grammar->grammar_option(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | my $recce_option = $grammar->recce_option(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | This modules returns describes the ECMAScript 262, Edition 5 lexical program grammar written in Marpa BNF, as of L<http://www.ecma-international.org/publications/standards/Ecma-262.htm>. This module inherits the methods from MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | =head2 make_grammar_content($class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | Returns the grammar. This will be injected in the Program's grammar. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | =head2 semantics_package($class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | Class method that returns Program default recce semantics_package. These semantics are adding ruleId to all values, and execute eventually StringLiteral lexical grammar. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | =head2 spacesAny($self, $spacesAny) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | Getter/Setter of a SpacesAny grammar implementation, used internally by the Program grammar. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | =head2 parse($self, $source, $impl) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | Parse the source given as $source using implementation $impl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | L<MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Base> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | Jean-Damien Durand <jeandamiendurand@free.fr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | This software is copyright (c) 2013 by Jean-Damien Durand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||