Skip to content

Commit c8d8d10

Browse files
committed
fix whitespace, add test
1 parent 1eeaf9f commit c8d8d10

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/main/java/com/shapesecurity/shift/es2017/parser/PatternAcceptor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ private Maybe<Integer> acceptCharacterEscape(State superState) {
574574
).apply(superState);
575575
}
576576

577+
// all `Maybe<Maybe<Integer>>` types represent matched, not terminating, and contain in the character value for ranges
577578
private Maybe<Maybe<Integer>> acceptClassEscape(State superState) {
578579
return this.<Maybe<Integer>>anyOf(
579580
state -> state.backtrackOnFailureMaybe(subState -> {
@@ -601,15 +602,15 @@ private Maybe<Maybe<Integer>> acceptClassEscape(State superState) {
601602

602603
private Maybe<Maybe<Integer>> acceptClassAtomNoDash(State state) {
603604
if (state.eat("\\")) {
604-
return this.anyOf(
605-
this::acceptClassEscape,
605+
return this.anyOf(
606+
this::acceptClassEscape,
606607
subState -> subState.backtrackOnFailureMaybe(subState2 -> {
607-
if (!this.unicode && subState2.match("c")) {
608-
return Maybe.of(0x005C); // reverse solidus
609-
}
610-
return Maybe.empty();
611-
}).map(Maybe::of)
612-
).apply(state);
608+
if (!this.unicode && subState2.match("c")) {
609+
return Maybe.of(0x005C); // reverse solidus
610+
}
611+
return Maybe.empty();
612+
}).map(Maybe::of)
613+
).apply(state);
613614
}
614615
Maybe<String> nextCodePoint = state.nextCodePoint();
615616
if (nextCodePoint.isNothing() || nextCodePoint.fromJust().equals("]") || nextCodePoint.fromJust().equals("-")) {
@@ -670,7 +671,6 @@ private Maybe<Maybe<Integer>> acceptNonEmptyClassRangesNoDash(State state) {
670671
return finishClassRange(state, atom.fromJust());
671672
}
672673

673-
// all `Maybe<Maybe<Integer>>` types represent matched, not terminating, and contain in the character value for ranges
674674
private boolean acceptCharacterClass(State superState) {
675675
return superState.backtrackOnFailure(state -> {
676676
if (!state.eat("[")) {

src/test/java/com/shapesecurity/shift/es2017/Serialization/DeserializerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public void testLiterals() throws IllegalAccessException, NoSuchMethodException,
137137
testHelperFromScriptCode("1.5");
138138
testHelperFromScriptCode("/[a-z]/i");
139139
testHelperFromScriptCode("/(?!.){0,}?/");
140+
testHelperFromScriptCode("/(.){0,}?/u");
140141
testHelperFromScriptCode("('x')");
141142
testHelperFromScriptCode("('\\\n')");
142143
}

0 commit comments

Comments
 (0)