|
536 | 536 |
|
537 | 537 | for (; index < max; index++) { |
538 | 538 | ch = data[index]; |
539 | | - if (ch === '_') continue; |
540 | 539 | if (ch !== '0' && ch !== '1') return false; |
541 | 540 | hasDigits = true; |
542 | 541 | } |
543 | | - return hasDigits && ch !== '_'; |
| 542 | + return hasDigits; |
544 | 543 | } |
545 | 544 |
|
546 | 545 |
|
|
550 | 549 |
|
551 | 550 | for (; index < max; index++) { |
552 | 551 | ch = data[index]; |
553 | | - if (ch === '_') continue; |
554 | 552 | if (!isHexCode(data.charCodeAt(index))) return false; |
555 | 553 | hasDigits = true; |
556 | 554 | } |
557 | | - return hasDigits && ch !== '_'; |
| 555 | + return hasDigits; |
558 | 556 | } |
559 | 557 |
|
560 | | - |
561 | 558 | if (ch === 'o') { |
562 | 559 | // base 8 |
563 | 560 | index++; |
564 | 561 |
|
565 | 562 | for (; index < max; index++) { |
566 | 563 | ch = data[index]; |
567 | | - if (ch === '_') continue; |
568 | 564 | if (!isOctCode(data.charCodeAt(index))) return false; |
569 | 565 | hasDigits = true; |
570 | 566 | } |
571 | | - return hasDigits && ch !== '_'; |
| 567 | + return hasDigits; |
572 | 568 | } |
573 | 569 | } |
574 | 570 |
|
575 | 571 | // base 10 (except 0) |
576 | 572 |
|
577 | | - // value should not start with `_`; |
578 | | - if (ch === '_') return false; |
579 | | - |
580 | 573 | for (; index < max; index++) { |
581 | 574 | ch = data[index]; |
582 | | - if (ch === '_') continue; |
583 | 575 | if (!isDecCode(data.charCodeAt(index))) { |
584 | 576 | return false; |
585 | 577 | } |
586 | 578 | hasDigits = true; |
587 | 579 | } |
588 | 580 |
|
589 | | - // Should have digits and should not end with `_` |
590 | | - if (!hasDigits || ch === '_') return false; |
591 | | - |
592 | | - return true; |
| 581 | + // Should have digits |
| 582 | + return hasDigits; |
593 | 583 | } |
594 | 584 |
|
595 | 585 | function constructYamlInteger(data) { |
596 | 586 | var value = data, sign = 1, ch; |
597 | 587 |
|
598 | | - if (value.indexOf('_') !== -1) { |
599 | | - value = value.replace(/_/g, ''); |
600 | | - } |
601 | | - |
602 | 588 | ch = value[0]; |
603 | 589 |
|
604 | 590 | if (ch === '-' || ch === '+') { |
|
646 | 632 |
|
647 | 633 | var YAML_FLOAT_PATTERN = new RegExp( |
648 | 634 | // 2.5e4, 2.5 and integers |
649 | | - '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + |
| 635 | + '^(?:[-+]?(?:[0-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?' + |
650 | 636 | // .2e4, .2 |
651 | 637 | // special case, seems not from spec |
652 | | - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + |
| 638 | + '|\\.[0-9]+(?:[eE][-+]?[0-9]+)?' + |
653 | 639 | // .inf |
654 | 640 | '|[-+]?\\.(?:inf|Inf|INF)' + |
655 | 641 | // .nan |
|
671 | 657 | function constructYamlFloat(data) { |
672 | 658 | var value, sign; |
673 | 659 |
|
674 | | - value = data.replace(/_/g, '').toLowerCase(); |
| 660 | + value = data.toLowerCase(); |
675 | 661 | sign = value[0] === '-' ? -1 : 1; |
676 | 662 |
|
677 | 663 | if ('+-'.indexOf(value[0]) >= 0) { |
|
0 commit comments