feat: implement async generators

This commit is contained in:
2023-08-26 00:41:28 +03:00
parent 8a0d309f0f
commit 7a745faacf
2 changed files with 58 additions and 11 deletions

View File

@@ -981,7 +981,14 @@ public class Parsing {
}
@SuppressWarnings("all")
public static ParseRes<? extends Statement> parseSimple(String filename, List<Token> tokens, int i, boolean statement) {
var res = new ArrayList<>(List.of(
var res = new ArrayList<>();
if (!statement) {
res.add(parseObject(filename, tokens, i));
res.add(parseFunction(filename, tokens, i, false));
}
res.addAll(List.of(
parseVariable(filename, tokens, i),
parseLiteral(filename, tokens, i),
parseString(filename, tokens, i),
@@ -997,11 +1004,6 @@ public class Parsing {
parseDelete(filename, tokens, i)
));
if (!statement) {
res.add(parseObject(filename, tokens, i));
res.add(parseFunction(filename, tokens, i, false));
}
return ParseRes.any(res.toArray(ParseRes[]::new));
}
@@ -1795,7 +1797,6 @@ public class Parsing {
parseContinue(filename, tokens, i),
parseBreak(filename, tokens, i),
parseDebug(filename, tokens, i),
parseValueStatement(filename, tokens, i),
parseIf(filename, tokens, i),
parseWhile(filename, tokens, i),
parseSwitch(filename, tokens, i),
@@ -1804,7 +1805,8 @@ public class Parsing {
parseDoWhile(filename, tokens, i),
parseCatch(filename, tokens, i),
parseCompound(filename, tokens, i),
parseFunction(filename, tokens, i, true)
parseFunction(filename, tokens, i, true),
parseValueStatement(filename, tokens, i)
);
}