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

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

Issue 10915030: Parse argument definition test expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
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 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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 } else { 1199 } else {
1200 return listener.expectedExpression(token); 1200 return listener.expectedExpression(token);
1201 } 1201 }
1202 } else if (kind === OPEN_PAREN_TOKEN) { 1202 } else if (kind === OPEN_PAREN_TOKEN) {
1203 return parseParenthesizedExpressionOrFunctionLiteral(token); 1203 return parseParenthesizedExpressionOrFunctionLiteral(token);
1204 } else if ((kind === LT_TOKEN) || 1204 } else if ((kind === LT_TOKEN) ||
1205 (kind === OPEN_SQUARE_BRACKET_TOKEN) || 1205 (kind === OPEN_SQUARE_BRACKET_TOKEN) ||
1206 (kind === OPEN_CURLY_BRACKET_TOKEN) || 1206 (kind === OPEN_CURLY_BRACKET_TOKEN) ||
1207 token.stringValue === '[]') { 1207 token.stringValue === '[]') {
1208 return parseLiteralListOrMap(token); 1208 return parseLiteralListOrMap(token);
1209 } else if (kind === QUESTION_TOKEN) {
1210 return parseArgumentDefinitionTest(token);
1209 } else { 1211 } else {
1210 return listener.expectedExpression(token); 1212 return listener.expectedExpression(token);
1211 } 1213 }
1212 } 1214 }
1213 1215
1216 Token parseArgumentDefinitionTest(Token token) {
1217 Token questionToken = token;
1218 listener.beginArgumentDefinitionTest(questionToken);
1219 assert(optional('?', token));
1220 token = parseIdentifier(token.next);
1221 listener.endArgumentDefinitionTest(questionToken, token);
1222 return token;
1223 }
1224
1214 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) { 1225 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) {
1215 BeginGroupToken beginGroup = token; 1226 BeginGroupToken beginGroup = token;
1216 int kind = beginGroup.endGroup.next.kind; 1227 int kind = beginGroup.endGroup.next.kind;
1217 if (mayParseFunctionExpressions && 1228 if (mayParseFunctionExpressions &&
1218 (kind === FUNCTION_TOKEN || kind === OPEN_CURLY_BRACKET_TOKEN)) { 1229 (kind === FUNCTION_TOKEN || kind === OPEN_CURLY_BRACKET_TOKEN)) {
1219 return parseUnamedFunction(token); 1230 return parseUnamedFunction(token);
1220 } else { 1231 } else {
1221 bool old = mayParseFunctionExpressions; 1232 bool old = mayParseFunctionExpressions;
1222 mayParseFunctionExpressions = true; 1233 mayParseFunctionExpressions = true;
1223 token = parseParenthesizedExpression(token); 1234 token = parseParenthesizedExpression(token);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 } 1851 }
1841 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1852 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1842 return expectSemicolon(token); 1853 return expectSemicolon(token);
1843 } 1854 }
1844 1855
1845 Token parseEmptyStatement(Token token) { 1856 Token parseEmptyStatement(Token token) {
1846 listener.handleEmptyStatement(token); 1857 listener.handleEmptyStatement(token);
1847 return expectSemicolon(token); 1858 return expectSemicolon(token);
1848 } 1859 }
1849 } 1860 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/listener.dart ('k') | dart/lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698