Skip to content

Commit e6753cc

Browse files
committed
Eliminate PeekToken overload
1 parent 7a5d09e commit e6753cc

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

src/core/IronPython/Compiler/Parser.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ private IReadOnlyList<Node> FinishArgListOrGenExpr() {
23402340

23412341
if (MaybeEat(TokenKind.Assign)) { // Keyword argument
23422342
a = FinishKeywordArgument(e);
2343-
} else if (PeekToken(Tokens.KeywordForToken)) { // Generator expression
2343+
} else if (PeekToken(TokenKind.KeywordFor)) { // Generator expression
23442344
a = ParseGeneratorExpression(e);
23452345
Eat(TokenKind.RightParenthesis);
23462346
a.SetLoc(_globalParent, start, GetEnd());
@@ -2599,7 +2599,7 @@ private Expression FinishTupleOrGenExp() {
25992599
if (MaybeEat(TokenKind.Comma)) {
26002600
// "(" expression "," ...
26012601
ret = FinishExpressionListAsExpr(expr);
2602-
} else if (PeekToken(Tokens.KeywordForToken)) {
2602+
} else if (PeekToken(TokenKind.KeywordFor)) {
26032603
// "(" expression "for" ...
26042604
if (expr is StarredExpression) ReportSyntaxError(expr.StartIndex, expr.EndIndex, "iterable unpacking cannot be used in comprehension");
26052605
ret = ParseGeneratorExpression(expr);
@@ -2634,9 +2634,9 @@ private Expression ParseGeneratorExpression(Expression expr) {
26342634
Statement current = root;
26352635

26362636
for (; ; ) {
2637-
if (PeekToken(Tokens.KeywordForToken)) {
2637+
if (PeekToken(TokenKind.KeywordFor)) {
26382638
current = NestGenExpr(current, ParseGenExprFor());
2639-
} else if (PeekToken(Tokens.KeywordIfToken)) {
2639+
} else if (PeekToken(TokenKind.KeywordIf)) {
26402640
current = NestGenExpr(current, ParseGenExprIf());
26412641
} else {
26422642
// Generator Expressions have an implicit function definition and yield around their expression.
@@ -2754,7 +2754,7 @@ private Expression FinishDictOrSetValue() {
27542754
}
27552755
var expr = ParseStarExpr();
27562756

2757-
if (PeekToken(Tokens.KeywordForToken)) {
2757+
if (PeekToken(TokenKind.KeywordFor)) {
27582758
if (!first) ReportSyntaxError("invalid syntax");
27592759
}
27602760

@@ -2770,7 +2770,7 @@ private Expression FinishDictOrSetValue() {
27702770
}
27712771
Expression e2 = ParseTest();
27722772

2773-
if (PeekToken(Tokens.KeywordForToken)) {
2773+
if (PeekToken(TokenKind.KeywordFor)) {
27742774
if (!first) {
27752775
ReportSyntaxError("invalid syntax");
27762776
}
@@ -2788,7 +2788,7 @@ private Expression FinishDictOrSetValue() {
27882788
first = true;
27892789
}
27902790

2791-
if (PeekToken(Tokens.KeywordForToken)) {
2791+
if (PeekToken(TokenKind.KeywordFor)) {
27922792
if (!first) {
27932793
ReportSyntaxError("invalid syntax");
27942794
}
@@ -2876,9 +2876,9 @@ private ComprehensionIterator[] ParseCompIter() {
28762876
iters.Add(firstFor);
28772877

28782878
while (true) {
2879-
if (PeekToken(Tokens.KeywordForToken)) {
2879+
if (PeekToken(TokenKind.KeywordFor)) {
28802880
iters.Add(ParseCompFor());
2881-
} else if (PeekToken(Tokens.KeywordIfToken)) {
2881+
} else if (PeekToken(TokenKind.KeywordIf)) {
28822882
iters.Add(ParseCompIf());
28832883
} else {
28842884
break;
@@ -2934,7 +2934,7 @@ private Expression FinishListValue() {
29342934
// (comp_for | (',' (test|star_expr))* [','] )
29352935

29362936
// comp_for
2937-
if (PeekToken(Tokens.KeywordForToken)) {
2937+
if (PeekToken(TokenKind.KeywordFor)) {
29382938
// although it's calling ParseCompIter(), because the peek token is a FOR it is going to
29392939
// do the right thing.
29402940
if (expr is StarredExpression) ReportSyntaxError(expr.StartIndex, expr.EndIndex, "iterable unpacking cannot be used in comprehension");
@@ -3177,7 +3177,7 @@ private PythonAst ParseFileWorker(bool makeModule, bool returnValue) {
31773177

31783178
// from __future__
31793179
if (_fromFutureAllowed) {
3180-
while (PeekToken(Tokens.KeywordFromToken)) {
3180+
while (PeekToken(TokenKind.KeywordFrom)) {
31813181
Statement s = ParseStmt();
31823182
l.Add(s);
31833183
if (s is FromImportStatement fis && !fis.IsFromFuture) {
@@ -3417,10 +3417,6 @@ private bool PeekToken(TokenKind kind) {
34173417
return PeekToken().Kind == kind;
34183418
}
34193419

3420-
private bool PeekToken(Token check) {
3421-
return PeekToken() == check;
3422-
}
3423-
34243420
private bool Eat(TokenKind kind) {
34253421
Token next = PeekToken();
34263422
if (next.Kind != kind) {

0 commit comments

Comments
 (0)