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

Side by Side Diff: frog/leg/scanner/parser.dart

Issue 9418045: Support for native in leg, and start moving native tests to a specific test suite. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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. 7 * all tokens in a linked list.
8 */ 8 */
9 class Parser { 9 class Parser {
10 final Listener listener; 10 final Listener listener;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (value === 'default') return true; 190 if (value === 'default') return true;
191 if (value === 'factory') { 191 if (value === 'factory') {
192 listener.recoverableError("expected 'default'", token: token); 192 listener.recoverableError("expected 'default'", token: token);
193 return true; 193 return true;
194 } 194 }
195 return false; 195 return false;
196 } 196 }
197 197
198 Token skipBlock(Token token) { 198 Token skipBlock(Token token) {
199 if (!optional('{', token)) { 199 if (!optional('{', token)) {
200 return listener.unexpected(token); 200 return listener.expectedBlockToSkip(token);
201 } 201 }
202 BeginGroupToken beginGroupToken = token; 202 BeginGroupToken beginGroupToken = token;
203 assert(beginGroupToken.endGroup === null || 203 assert(beginGroupToken.endGroup === null ||
204 beginGroupToken.endGroup.kind === $CLOSE_CURLY_BRACKET); 204 beginGroupToken.endGroup.kind === $CLOSE_CURLY_BRACKET);
205 return beginGroupToken.endGroup; 205 return beginGroupToken.endGroup;
206 } 206 }
207 207
208 Token parseClass(Token token) { 208 Token parseClass(Token token) {
209 Token begin = token; 209 Token begin = token;
210 listener.beginClassDeclaration(token); 210 listener.beginClassDeclaration(token);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 return gtToken.next; 520 return gtToken.next;
521 } 521 }
522 } 522 }
523 return peek; 523 return peek;
524 } 524 }
525 525
526 Token parseClassBody(Token token) { 526 Token parseClassBody(Token token) {
527 Token begin = token; 527 Token begin = token;
528 listener.beginClassBody(token); 528 listener.beginClassBody(token);
529 if (!optional('{', token)) { 529 if (!optional('{', token)) {
530 token = listener.unexpected(token); 530 token = listener.expectedClassBody(token);
531 listener.endClassBody(0, begin, null);
532 return token;
533 } 531 }
534 token = token.next; 532 token = token.next;
535 int count = 0; 533 int count = 0;
536 while (notEofOrValue('}', token)) { 534 while (notEofOrValue('}', token)) {
537 token = parseMember(token); 535 token = parseMember(token);
538 ++count; 536 ++count;
539 } 537 }
540 listener.endClassBody(count, begin, token); 538 listener.endClassBody(count, begin, token);
541 return token; 539 return token;
542 } 540 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 expectSemicolon(token); 750 expectSemicolon(token);
753 listener.endReturnStatement(true, begin, token); 751 listener.endReturnStatement(true, begin, token);
754 } else { 752 } else {
755 listener.endReturnStatement(true, begin, null); 753 listener.endReturnStatement(true, begin, null);
756 } 754 }
757 return token; 755 return token;
758 } 756 }
759 Token begin = token; 757 Token begin = token;
760 int statementCount = 0; 758 int statementCount = 0;
761 listener.beginFunctionBody(begin); 759 listener.beginFunctionBody(begin);
762 token = expect('{', token); 760 if (!optional('{', token)) {
761 return listener.expectedFunctionBody(token);
762 } else {
763 token = token.next;
764 }
763 while (notEofOrValue('}', token)) { 765 while (notEofOrValue('}', token)) {
764 token = parseStatement(token); 766 token = parseStatement(token);
765 ++statementCount; 767 ++statementCount;
766 } 768 }
767 listener.endFunctionBody(statementCount, begin, token); 769 listener.endFunctionBody(statementCount, begin, token);
768 expect('}', token); 770 expect('}', token);
769 return token; 771 return token;
770 } 772 }
771 773
772 Token parseStatement(Token token) { 774 Token parseStatement(Token token) {
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 } 1631 }
1630 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1632 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1631 return expectSemicolon(token); 1633 return expectSemicolon(token);
1632 } 1634 }
1633 1635
1634 Token parseEmptyStatement(Token token) { 1636 Token parseEmptyStatement(Token token) {
1635 listener.handleEmptyStatement(token); 1637 listener.handleEmptyStatement(token);
1636 return expectSemicolon(token); 1638 return expectSemicolon(token);
1637 } 1639 }
1638 } 1640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698