Skip to content

Commit

Permalink
Add support for yield statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkoopman committed May 28, 2020
1 parent 2ddcfd3 commit b46d1f0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public Void visitBindingPattern(BindingPatternTree node, Void unused) {
@Override
public Void visitYield(YieldTree node, Void aVoid) {
sync(node);
return super.visitYield(node, aVoid);
token("yield");
builder.space();
scan(node.getValue(), null);
token(";");
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,23 @@ class Java14 {
{
for (var arg : List.of()) {}
}

{
int f = switch (i) {
case 0 -> 0;
default -> {
yield n / i;
}
};

int g = switch (i) {
case 0: yield 0;
default: yield n/i;
};

switch (i) {
case 0 -> { System.out.println("0"); }
default -> System.out.println("default");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,29 @@ class Java14 {
{
for (var arg : List.of()) {}
}

{
int f =
switch (i) {
case 0 -> 0;
default -> {
yield n / i;
}
};

int g =
switch (i) {
case 0:
yield 0;
default:
yield n / i;
};

switch (i) {
case 0 -> {
System.out.println("0");
}
default -> System.out.println("default");
}
}
}

0 comments on commit b46d1f0

Please sign in to comment.