Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10949015: Issue 5052. Analyzer should treat assert as a keyword (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index 9ddba7709f39567345aecab8249f2e07eb9d6c52..784348e271d0270d3c302fe43faadbe98c959e92 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -18,6 +18,7 @@ import com.google.dart.compiler.Source;
import com.google.dart.compiler.ast.DartAnnotation;
import com.google.dart.compiler.ast.DartArrayAccess;
import com.google.dart.compiler.ast.DartArrayLiteral;
+import com.google.dart.compiler.ast.DartAssertStatement;
import com.google.dart.compiler.ast.DartBinaryExpression;
import com.google.dart.compiler.ast.DartBlock;
import com.google.dart.compiler.ast.DartBooleanLiteral;
@@ -139,7 +140,6 @@ public class DartParser extends CompletionHooksParserBase {
// Pseudo-keywords that should also be valid identifiers.
private static final String ABSTRACT_KEYWORD = "abstract";
private static final String AS_KEYWORD = "as";
- private static final String ASSERT_KEYWORD = "assert";
private static final String CALL_KEYWORD = "call";
private static final String DYNAMIC_KEYWORD = "Dynamic";
private static final String EXPORT_KEYWORD = "export";
@@ -166,7 +166,6 @@ public class DartParser extends CompletionHooksParserBase {
public static final String[] PSEUDO_KEYWORDS = {
ABSTRACT_KEYWORD,
AS_KEYWORD,
- ASSERT_KEYWORD,
DYNAMIC_KEYWORD,
EXPORT_KEYWORD,
EXTERNAL_KEYWORD,
@@ -3921,6 +3920,16 @@ public class DartParser extends CompletionHooksParserBase {
return idents;
}
+ private DartAssertStatement parseAssertStatement() {
+ beginAssertStatement();
+ expect(Token.ASSERT);
+ expect(Token.LPAREN);
+ DartExpression condition = parseExpression();
+ expectCloseParen();
+ expectStatmentTerminator();
+ return done(new DartAssertStatement(condition));
+ }
+
/**
* <pre>
* abruptCompletingStatement
@@ -4078,9 +4087,12 @@ public class DartParser extends CompletionHooksParserBase {
}
// Check possible statement kind.
switch (peek(0)) {
+ case ASSERT:
+ return parseAssertStatement();
+
case IF:
return parseIfStatement();
-
+
case SWITCH:
return parseSwitchStatement();

Powered by Google App Engine
This is Rietveld 408576698