@@ -408,12 +408,12 @@ private boolean acceptGrouping(State superState) {
408408 }
409409
410410 private boolean acceptAtomEscape (State state ) {
411- return acceptDecimalEscapeBackreference (state ) ||
411+ return acceptDecimalEscape (state ) ||
412412 acceptCharacterClassEscape (state ) ||
413413 acceptCharacterEscape (state ).map (i -> true ).orJust (false );
414414 }
415415
416- private boolean acceptDecimalEscapeBackreference (State superState ) {
416+ private boolean acceptDecimalEscape (State superState ) {
417417 return superState .backtrackOnFailure (state -> {
418418 StringBuilder digits = new StringBuilder ();
419419 Maybe <String > firstDecimal = state .eatAny (decimalDigits );
@@ -433,37 +433,6 @@ private boolean acceptDecimalEscapeBackreference(State superState) {
433433 });
434434 }
435435
436- @ Nonnull
437- private Maybe <Integer > acceptDecimalEscape (State superState ) {
438- return superState .backtrackOnFailureMaybe (state -> {
439- Maybe <String > firstDigit = state .eatAny (decimalDigits );
440- if (firstDigit .isNothing ()) {
441- return Maybe .empty ();
442- }
443- if (firstDigit .isJust () && firstDigit .fromJust ().equals ("0" )) {
444- return Maybe .of (0 );
445- }
446- if (this .unicode ) {
447- return Maybe .empty ();
448- }
449- StringBuilder digits = new StringBuilder ();
450- digits .append (firstDigit .fromJust ());
451- Maybe <String > digit = state .eatAny (decimalDigits );
452- if (digit .isJust ()) {
453- String justDigit = digit .fromJust ();
454- digits .append (justDigit );
455- if (firstDigit .fromJust ().equals ("1" )) {
456- if (justDigit .equals ("0" ) || justDigit .equals ("1" )) {
457- state .eatAny (decimalDigits ).foreach (digits ::append );
458- } else if (justDigit .equals ("2" )) {
459- state .eatAny (octalDigits ).foreach (digits ::append );
460- }
461- }
462- }
463- return Maybe .of (Integer .parseInt (digits .toString ()));
464- });
465- }
466-
467436 private boolean acceptCharacterClassEscape (State state ) {
468437 return state .eatAny ("d" , "D" , "s" , "S" , "w" , "W" ).isJust ();
469438 }
@@ -573,7 +542,7 @@ private Maybe<Integer> acceptCharacterEscape(State superState) {
573542 if (octal3 .isNothing ()) {
574543 return Maybe .of (octal1 .fromJust () << 3 | octal2 .fromJust ());
575544 }
576- return Maybe .of (octal1 .fromJust () << 6 | octal2 .fromJust () << 3 | octal1 .fromJust ());
545+ return Maybe .of (octal1 .fromJust () << 6 | octal2 .fromJust () << 3 | octal3 .fromJust ());
577546 } else {
578547 return Maybe .of (octal1 .fromJust () << 3 | octal2 .fromJust ());
579548 }
@@ -613,7 +582,6 @@ private Maybe<Maybe<Integer>> acceptClassEscape(State superState) {
613582 }
614583 return Maybe .of (0x0008 ); // backspace
615584 }).map (Maybe ::of ),
616- state -> acceptDecimalEscape (state ).map (Maybe ::of ),
617585 state -> {
618586 if (this .unicode && state .eat ("-" )) {
619587 return Maybe .of (Maybe .of ((int )"-" .charAt (0 )));
0 commit comments