()
| 58402 | } |
| 58403 | |
| 58404 | function parseDecimalEscape() { |
| 58405 | // DecimalEscape :: |
| 58406 | // DecimalIntegerLiteral [lookahead ∉ DecimalDigit] |
| 58407 | // CharacterClassEscape :: one of d D s S w W |
| 58408 | |
| 58409 | var res, match; |
| 58410 | |
| 58411 | if (res = matchReg(/^(?!0)\d+/)) { |
| 58412 | match = res[0]; |
| 58413 | var refIdx = parseInt(res[0], 10); |
| 58414 | if (refIdx <= closedCaptureCounter) { |
| 58415 | // If the number is smaller than the normal-groups found so |
| 58416 | // far, then it is a reference... |
| 58417 | return createReference(res[0]); |
| 58418 | } else { |
| 58419 | // ... otherwise it needs to be interpreted as a octal (if the |
| 58420 | // number is in an octal format). If it is NOT octal format, |
| 58421 | // then the slash is ignored and the number is matched later |
| 58422 | // as normal characters. |
| 58423 | |
| 58424 | // Recall the negative decision to decide if the input must be parsed |
| 58425 | // a second time with the total normal-groups. |
| 58426 | backrefDenied.push(refIdx); |
| 58427 | |
| 58428 | // Reset the position again, as maybe only parts of the previous |
| 58429 | // matched numbers are actual octal numbers. E.g. in '019' only |
| 58430 | // the '01' should be matched. |
| 58431 | incr(-res[0].length); |
| 58432 | if (res = matchReg(/^[0-7]{1,3}/)) { |
| 58433 | return createEscaped('octal', parseInt(res[0], 8), res[0], 1); |
| 58434 | } else { |
| 58435 | // If we end up here, we have a case like /\91/. Then the |
| 58436 | // first slash is to be ignored and the 9 & 1 to be treated |
| 58437 | // like ordinary characters. Create a character for the |
| 58438 | // first number only here - other number-characters |
| 58439 | // (if available) will be matched later. |
| 58440 | res = createCharacter(matchReg(/^[89]/)); |
| 58441 | return updateRawStart(res, res.range[0] - 1); |
| 58442 | } |
| 58443 | } |
| 58444 | } |
| 58445 | // Only allow octal numbers in the following. All matched numbers start |
| 58446 | // with a zero (if the do not, the previous if-branch is executed). |
| 58447 | // If the number is not octal format and starts with zero (e.g. `091`) |
| 58448 | // then only the zeros `0` is treated here and the `91` are ordinary |
| 58449 | // characters. |
| 58450 | // Example: |
| 58451 | // /\091/.exec('\091')[0].length === 3 |
| 58452 | else if (res = matchReg(/^[0-7]{1,3}/)) { |
| 58453 | match = res[0]; |
| 58454 | if (/^0{1,3}$/.test(match)) { |
| 58455 | // If they are all zeros, then only take the first one. |
| 58456 | return createEscaped('null', 0x0000, '0', match.length + 1); |
| 58457 | } else { |
| 58458 | return createEscaped('octal', parseInt(match, 8), match, 1); |
| 58459 | } |
| 58460 | } else if (res = matchReg(/^[dDsSwW]/)) { |
| 58461 | return createCharacterClassEscape(res[0]); |
no test coverage detected