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

Side by Side Diff: lib/compiler/implementation/scanner/parser.dart

Issue 11014010: Made assert a keyword. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renamed Assert to assertHelper. Switched parser to use parseArguments. Added assert argument checki… Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * An event generating parser of Dart programs. This parser expects 6 * An event generating parser of Dart programs. This parser expects
7 * all tokens in a linked list (aka a token stream). 7 * all tokens in a linked list (aka a token stream).
8 * 8 *
9 * The class [Scanner] is used to generate a token stream. See the 9 * The class [Scanner] is used to generate a token stream. See the
10 * file scanner.dart. 10 * file scanner.dart.
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 } else if (value === 'do') { 1139 } else if (value === 'do') {
1140 return parseDoWhileStatement(token); 1140 return parseDoWhileStatement(token);
1141 } else if (value === 'try') { 1141 } else if (value === 'try') {
1142 return parseTryStatement(token); 1142 return parseTryStatement(token);
1143 } else if (value === 'switch') { 1143 } else if (value === 'switch') {
1144 return parseSwitchStatement(token); 1144 return parseSwitchStatement(token);
1145 } else if (value === 'break') { 1145 } else if (value === 'break') {
1146 return parseBreakStatement(token); 1146 return parseBreakStatement(token);
1147 } else if (value === 'continue') { 1147 } else if (value === 'continue') {
1148 return parseContinueStatement(token); 1148 return parseContinueStatement(token);
1149 } else if (value === 'assert') {
1150 return parseAssertStatement(token);
1149 } else if (value === ';') { 1151 } else if (value === ';') {
1150 return parseEmptyStatement(token); 1152 return parseEmptyStatement(token);
1151 } else if (value === 'const') { 1153 } else if (value === 'const') {
1152 return parseExpressionStatementOrConstDeclaration(token); 1154 return parseExpressionStatementOrConstDeclaration(token);
1153 } else if (token.isIdentifier()) { 1155 } else if (token.isIdentifier()) {
1154 return parseExpressionStatementOrDeclaration(token); 1156 return parseExpressionStatementOrDeclaration(token);
1155 } else { 1157 } else {
1156 return parseExpressionStatement(token); 1158 return parseExpressionStatement(token);
1157 } 1159 }
1158 } 1160 }
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 token = token.next; 2122 token = token.next;
2121 bool hasTarget = false; 2123 bool hasTarget = false;
2122 if (token.isIdentifier()) { 2124 if (token.isIdentifier()) {
2123 token = parseIdentifier(token); 2125 token = parseIdentifier(token);
2124 hasTarget = true; 2126 hasTarget = true;
2125 } 2127 }
2126 listener.handleBreakStatement(hasTarget, breakKeyword, token); 2128 listener.handleBreakStatement(hasTarget, breakKeyword, token);
2127 return expectSemicolon(token); 2129 return expectSemicolon(token);
2128 } 2130 }
2129 2131
2132 Token parseAssertStatement(Token token) {
2133 Token assertKeyword = token;
2134 token = expect('assert', token);
2135 token = parseArguments(token);
2136 listener.handleAssertStatement(assertKeyword, token);
2137 return expectSemicolon(token);
2138 }
2139
2130 Token parseContinueStatement(Token token) { 2140 Token parseContinueStatement(Token token) {
2131 assert(optional('continue', token)); 2141 assert(optional('continue', token));
2132 Token continueKeyword = token; 2142 Token continueKeyword = token;
2133 token = token.next; 2143 token = token.next;
2134 bool hasTarget = false; 2144 bool hasTarget = false;
2135 if (token.isIdentifier()) { 2145 if (token.isIdentifier()) {
2136 token = parseIdentifier(token); 2146 token = parseIdentifier(token);
2137 hasTarget = true; 2147 hasTarget = true;
2138 } 2148 }
2139 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2149 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2140 return expectSemicolon(token); 2150 return expectSemicolon(token);
2141 } 2151 }
2142 2152
2143 Token parseEmptyStatement(Token token) { 2153 Token parseEmptyStatement(Token token) {
2144 listener.handleEmptyStatement(token); 2154 listener.handleEmptyStatement(token);
2145 return expectSemicolon(token); 2155 return expectSemicolon(token);
2146 } 2156 }
2147 } 2157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698