File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
src/main/java/com/shapesecurity/shift/es2017/parser Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -248,20 +248,16 @@ private Maybe<String> eatUnicodeOrCharacter() {
248248 return Maybe .empty ();
249249 }
250250 return this .backtrackOnFailureMaybe (state -> {
251- int characterValue ;
252251 if (state .match ("\\ u" )) {
253252 state .skipCodePoint ();
254253 Maybe <Integer > maybeCharacterValue = acceptUnicodeEscape (state );
255- if (!maybeCharacterValue .isJust ()) {
256- return Maybe .empty ();
257- }
258- characterValue = maybeCharacterValue .fromJust ();
259- } else {
260- characterValue = pattern .codePointAt (state .index );
261- state .index += Character .toChars (characterValue ).length ;
254+ return maybeCharacterValue .map (value -> new String (Character .toChars (value )));
255+ }
256+ Maybe <String > character = state .nextCodePoint ();
257+ if (character .isJust ()) {
258+ state .skipCodePoint ();
262259 }
263- String character = new String (Character .toChars (characterValue ));
264- return Maybe .of (character );
260+ return character ;
265261 });
266262 }
267263
@@ -663,7 +659,7 @@ private Maybe<Integer> acceptUnicodeEscape(State superState) {
663659 }
664660 int value = Integer .parseInt (hex , 16 );
665661
666- if (value >= 0xD800 && value <= 0xDBFF ) {
662+ if (this . unicode && value >= 0xD800 && value <= 0xDBFF ) {
667663 Maybe <Integer > surrogatePairValue = state .backtrackOnFailureMaybe (subState -> {
668664 if (!subState .eat ("\\ u" )) {
669665 return Maybe .empty ();
You can’t perform that action at this time.
0 commit comments