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

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.expectedBlock(token);
ahe 2012/02/19 14:38:02 I think this event should be "expectedBlockToSkip"
ngeoffray 2012/02/20 17:00:02 Done.
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);
211 if (optional('abstract', token)) { 211 if (optional('abstract', token)) {
212 // TODO(ahe): Notify listener about abstract modifier. 212 // TODO(ahe): Notify listener about abstract modifier.
213 token = token.next; 213 token = token.next;
214 } 214 }
215 Token id = token.next;
ahe 2012/02/19 14:38:02 I don't think id is used.
ngeoffray 2012/02/20 17:00:02 Done.
215 token = parseIdentifier(token.next); 216 token = parseIdentifier(token.next);
216 token = parseTypeVariablesOpt(token); 217 token = parseTypeVariablesOpt(token);
217 Token extendsKeyword; 218 Token extendsKeyword;
218 if (optional('extends', token)) { 219 if (optional('extends', token)) {
219 extendsKeyword = token; 220 extendsKeyword = token;
220 token = parseType(token.next); 221 token = parseType(token.next);
221 } else { 222 } else {
222 extendsKeyword = null; 223 extendsKeyword = null;
223 listener.handleNoType(token); 224 listener.handleNoType(token);
224 } 225 }
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 return gtToken.next; 521 return gtToken.next;
521 } 522 }
522 } 523 }
523 return peek; 524 return peek;
524 } 525 }
525 526
526 Token parseClassBody(Token token) { 527 Token parseClassBody(Token token) {
527 Token begin = token; 528 Token begin = token;
528 listener.beginClassBody(token); 529 listener.beginClassBody(token);
529 if (!optional('{', token)) { 530 if (!optional('{', token)) {
530 token = listener.unexpected(token); 531 token = listener.expectedClassBody(token);
531 listener.endClassBody(0, begin, null);
532 return token;
533 } 532 }
534 token = token.next; 533 token = token.next;
535 int count = 0; 534 int count = 0;
536 while (notEofOrValue('}', token)) { 535 while (notEofOrValue('}', token)) {
537 token = parseMember(token); 536 token = parseMember(token);
538 ++count; 537 ++count;
539 } 538 }
540 listener.endClassBody(count, begin, token); 539 listener.endClassBody(count, begin, token);
541 return token; 540 return token;
542 } 541 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 expectSemicolon(token); 751 expectSemicolon(token);
753 listener.endReturnStatement(true, begin, token); 752 listener.endReturnStatement(true, begin, token);
754 } else { 753 } else {
755 listener.endReturnStatement(true, begin, null); 754 listener.endReturnStatement(true, begin, null);
756 } 755 }
757 return token; 756 return token;
758 } 757 }
759 Token begin = token; 758 Token begin = token;
760 int statementCount = 0; 759 int statementCount = 0;
761 listener.beginFunctionBody(begin); 760 listener.beginFunctionBody(begin);
762 token = expect('{', token); 761 if (!optional('{', token)) {
762 return listener.expectedFunctionBody(token);
763 } else {
764 token = token.next;
765 }
763 while (notEofOrValue('}', token)) { 766 while (notEofOrValue('}', token)) {
764 token = parseStatement(token); 767 token = parseStatement(token);
765 ++statementCount; 768 ++statementCount;
766 } 769 }
767 listener.endFunctionBody(statementCount, begin, token); 770 listener.endFunctionBody(statementCount, begin, token);
768 expect('}', token); 771 expect('}', token);
769 return token; 772 return token;
770 } 773 }
771 774
772 Token parseStatement(Token token) { 775 Token parseStatement(Token token) {
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 } 1632 }
1630 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1633 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1631 return expectSemicolon(token); 1634 return expectSemicolon(token);
1632 } 1635 }
1633 1636
1634 Token parseEmptyStatement(Token token) { 1637 Token parseEmptyStatement(Token token) {
1635 listener.handleEmptyStatement(token); 1638 listener.handleEmptyStatement(token);
1636 return expectSemicolon(token); 1639 return expectSemicolon(token);
1637 } 1640 }
1638 } 1641 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698