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

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

Issue 10857013: Support for new catch syntax in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 4 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 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 return expectSemicolon(token); 1572 return expectSemicolon(token);
1573 } 1573 }
1574 } 1574 }
1575 1575
1576 Token parseTryStatement(Token token) { 1576 Token parseTryStatement(Token token) {
1577 assert(optional('try', token)); 1577 assert(optional('try', token));
1578 Token tryKeyword = token; 1578 Token tryKeyword = token;
1579 listener.beginTryStatement(tryKeyword); 1579 listener.beginTryStatement(tryKeyword);
1580 token = parseBlock(token.next); 1580 token = parseBlock(token.next);
1581 int catchCount = 0; 1581 int catchCount = 0;
1582 while (optional('catch', token)) { 1582
1583 Token catchKeyword = token; 1583 String value = token.stringValue;
1584 // TODO(ahe): Validate the "parameters". 1584 while (value === 'catch' || value === 'on') {
1585 token = parseFormalParameters(token.next); 1585 var onKeyword = null;
1586 if (value === 'on') {
1587 // on qualified catchPart?
1588 onKeyword = token;
1589 token = parseType(token.next);
1590 value = token.stringValue;
1591 }
1592 Token catchKeyword = null;
1593 if (value === 'catch') {
1594 catchKeyword = token;
1595 // TODO(ahe): Validate the "parameters".
1596 token = parseFormalParameters(token.next);
1597 }
1586 token = parseBlock(token); 1598 token = parseBlock(token);
1587 ++catchCount; 1599 ++catchCount;
1588 listener.handleCatchBlock(catchKeyword); 1600 listener.handleCatchBlock(onKeyword, catchKeyword);
1601 value = token.stringValue; // while condition
1589 } 1602 }
1603
1590 Token finallyKeyword = null; 1604 Token finallyKeyword = null;
1591 if (optional('finally', token)) { 1605 if (optional('finally', token)) {
1592 finallyKeyword = token; 1606 finallyKeyword = token;
1593 token = parseBlock(token.next); 1607 token = parseBlock(token.next);
1594 listener.handleFinallyBlock(finallyKeyword); 1608 listener.handleFinallyBlock(finallyKeyword);
1595 } 1609 }
1596 listener.endTryStatement(catchCount, tryKeyword, finallyKeyword); 1610 listener.endTryStatement(catchCount, tryKeyword, finallyKeyword);
1597 return token; 1611 return token;
1598 } 1612 }
1599 1613
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 } 1735 }
1722 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1736 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1723 return expectSemicolon(token); 1737 return expectSemicolon(token);
1724 } 1738 }
1725 1739
1726 Token parseEmptyStatement(Token token) { 1740 Token parseEmptyStatement(Token token) {
1727 listener.handleEmptyStatement(token); 1741 listener.handleEmptyStatement(token);
1728 return expectSemicolon(token); 1742 return expectSemicolon(token);
1729 } 1743 }
1730 } 1744 }
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