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

Side by Side Diff: dart/frog/frogsh

Issue 8497042: Allow error-recovery in top-level nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased, address review comments, and frogsh Created 9 years, 1 month 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
« no previous file with comments | « no previous file | dart/frog/leg/scanner/listener.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env node 1 #!/usr/bin/env node
2 // ********** Library dart:core ************** 2 // ********** Library dart:core **************
3 // ********** Natives dart:core ************** 3 // ********** Natives dart:core **************
4 /** 4 /**
5 * Generates a dynamic call stub for a function. 5 * Generates a dynamic call stub for a function.
6 * Our goal is to create a stub method like this on-the-fly: 6 * Our goal is to create a stub method like this on-the-fly:
7 * function($0, $1, capture) { this($0, $1, true, capture); } 7 * function($0, $1, capture) { this($0, $1, true, capture); }
8 * 8 *
9 * This stub then replaces the dynamic one on Function, with one that is 9 * This stub then replaces the dynamic one on Function, with one that is
10 * specialized for that particular function, taking into account its default 10 * specialized for that particular function, taking into account its default
(...skipping 5495 matching lines...) Expand 10 before | Expand all | Expand 10 after
5506 default: 5506 default:
5507 5507
5508 previous = token; 5508 previous = token;
5509 token = this.next(token); 5509 token = this.next(token);
5510 break; 5510 break;
5511 5511
5512 } 5512 }
5513 } 5513 }
5514 token = this.parseIdentifier(previous); 5514 token = this.parseIdentifier(previous);
5515 var isField; 5515 var isField;
5516 if ($notnull_bool(this.optional('(', token))) { 5516 while ($notnull_bool(true)) {
5517 isField = false; 5517 if ($notnull_bool(this.optional('(', token))) {
5518 } 5518 isField = false;
5519 else if ($notnull_bool(this.optional('=', token) || this.optional(';', token)) ) { 5519 break;
5520 isField = true; 5520 }
5521 } 5521 else if ($notnull_bool(this.optional('=', token) || this.optional(';', token ))) {
5522 else { 5522 isField = true;
5523 token = this.listener.unexpected(token); 5523 break;
5524 }
5525 else {
5526 token = this.listener.unexpected(token);
5527 }
5524 } 5528 }
5525 while ($notnull_bool(token != null && token.kind !== 123/*null.LBRACE_TOKEN*/ && token.kind !== 59/*null.SEMICOLON_TOKEN*/)) { 5529 while ($notnull_bool(token != null && token.kind !== 123/*null.LBRACE_TOKEN*/ && token.kind !== 59/*null.SEMICOLON_TOKEN*/)) {
5526 token = this.next(token); 5530 token = this.next(token);
5527 } 5531 }
5528 if ($notnull_bool(!$notnull_bool(this.optional(';', token)))) { 5532 if ($notnull_bool(!$notnull_bool(this.optional(';', token)))) {
5529 token = this.skipBlock(token); 5533 token = this.skipBlock(token);
5530 } 5534 }
5531 if ($notnull_bool(isField)) { 5535 if ($notnull_bool(isField)) {
5532 this.listener.endTopLevelField(start, token); 5536 this.listener.endTopLevelField(start, token);
5533 } 5537 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5614 return this.parseExpressionStatement(token); 5618 return this.parseExpressionStatement(token);
5615 5619
5616 } 5620 }
5617 } 5621 }
5618 BodyParser.prototype.expectSemicolon = function(token) { 5622 BodyParser.prototype.expectSemicolon = function(token) {
5619 return this.expect(';', token); 5623 return this.expect(';', token);
5620 } 5624 }
5621 BodyParser.prototype.parseReturnStatement = function(token) { 5625 BodyParser.prototype.parseReturnStatement = function(token) {
5622 var begin = token; 5626 var begin = token;
5623 this.listener.beginReturnStatement(begin); 5627 this.listener.beginReturnStatement(begin);
5624 $assert('return' === token.get$stringValue(), "'return' === token.stringValue" , "parser.dart", 407, 12); 5628 $assert('return' === token.get$stringValue(), "'return' === token.stringValue" , "parser.dart", 413, 12);
5625 token = this.parseExpression(this.next(token)); 5629 token = this.parseExpression(this.next(token));
5626 this.listener.endReturnStatement(true, begin, token); 5630 this.listener.endReturnStatement(true, begin, token);
5627 return this.expectSemicolon(token); 5631 return this.expectSemicolon(token);
5628 } 5632 }
5629 BodyParser.prototype.parseExpressionStatementOrDeclaration = function(token) { 5633 BodyParser.prototype.parseExpressionStatementOrDeclaration = function(token) {
5630 $assert(token.kind === 97/*null.IDENTIFIER_TOKEN*/, "token.kind === IDENTIFIER _TOKEN", "parser.dart", 414, 12); 5634 $assert(token.kind === 97/*null.IDENTIFIER_TOKEN*/, "token.kind === IDENTIFIER _TOKEN", "parser.dart", 420, 12);
5631 var peek1 = this.next(token); 5635 var peek1 = this.next(token);
5632 if ($notnull_bool(peek1.kind === 97/*null.IDENTIFIER_TOKEN*/)) { 5636 if ($notnull_bool(peek1.kind === 97/*null.IDENTIFIER_TOKEN*/)) {
5633 return this.parseLocalDeclaration(token, peek1); 5637 return this.parseLocalDeclaration(token, peek1);
5634 } 5638 }
5635 else { 5639 else {
5636 return this.parseExpressionStatement(token); 5640 return this.parseExpressionStatement(token);
5637 } 5641 }
5638 } 5642 }
5639 BodyParser.prototype.parseLocalDeclaration = function(token, peek1) { 5643 BodyParser.prototype.parseLocalDeclaration = function(token, peek1) {
5640 var peek2 = this.next(peek1); 5644 var peek2 = this.next(peek1);
(...skipping 28 matching lines...) Expand all
5669 var question = token; 5673 var question = token;
5670 token = this.parseExpression(this.next(token)); 5674 token = this.parseExpression(this.next(token));
5671 var colon = token; 5675 var colon = token;
5672 token = this.expect(':', token); 5676 token = this.expect(':', token);
5673 token = this.parseExpression(token); 5677 token = this.parseExpression(token);
5674 this.listener.handleConditionalExpression(question, colon); 5678 this.listener.handleConditionalExpression(question, colon);
5675 } 5679 }
5676 return token; 5680 return token;
5677 } 5681 }
5678 BodyParser.prototype.parseBinaryExpression = function(token, precedence) { 5682 BodyParser.prototype.parseBinaryExpression = function(token, precedence) {
5679 $assert(precedence >= 4, "precedence >= 4", "parser.dart", 467, 12); 5683 $assert(precedence >= 4, "precedence >= 4", "parser.dart", 473, 12);
5680 token = this.parsePrimary(token); 5684 token = this.parsePrimary(token);
5681 var tokenLevel = this.getPrecedence(token); 5685 var tokenLevel = this.getPrecedence(token);
5682 for (var level = $assert_num(tokenLevel); 5686 for (var level = $assert_num(tokenLevel);
5683 $notnull_bool(level >= precedence); --level) { 5687 $notnull_bool(level >= precedence); --level) {
5684 while ($notnull_bool(tokenLevel === level)) { 5688 while ($notnull_bool(tokenLevel === level)) {
5685 var operator = token; 5689 var operator = token;
5686 token = this.parseBinaryExpression(this.next(token), level + 1); 5690 token = this.parseBinaryExpression(this.next(token), level + 1);
5687 this.listener.handleBinaryExpression(operator); 5691 this.listener.handleBinaryExpression(operator);
5688 tokenLevel = this.getPrecedence(token); 5692 tokenLevel = this.getPrecedence(token);
5689 } 5693 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
5934 this.listener.handleNoArguments(token); 5938 this.listener.handleNoArguments(token);
5935 return token; 5939 return token;
5936 } 5940 }
5937 else { 5941 else {
5938 return this.parseArguments(token); 5942 return this.parseArguments(token);
5939 } 5943 }
5940 } 5944 }
5941 BodyParser.prototype.parseArguments = function(token) { 5945 BodyParser.prototype.parseArguments = function(token) {
5942 var begin = token; 5946 var begin = token;
5943 this.listener.beginArguments(begin); 5947 this.listener.beginArguments(begin);
5944 $assert('(' === token.get$stringValue(), "'(' === token.stringValue", "parser. dart", 600, 12); 5948 $assert('(' === token.get$stringValue(), "'(' === token.stringValue", "parser. dart", 606, 12);
5945 var argumentCount = 0; 5949 var argumentCount = 0;
5946 if ($notnull_bool(this.optional(')', token.next))) { 5950 if ($notnull_bool(this.optional(')', token.next))) {
5947 this.listener.endArguments(argumentCount, begin, token.next); 5951 this.listener.endArguments(argumentCount, begin, token.next);
5948 return token.next.next; 5952 return token.next.next;
5949 } 5953 }
5950 do { 5954 do {
5951 token = this.parseExpression(this.next(token)); 5955 token = this.parseExpression(this.next(token));
5952 ++argumentCount; 5956 ++argumentCount;
5953 } 5957 }
5954 while ($notnull_bool(this.optional(',', token))) 5958 while ($notnull_bool(this.optional(',', token)))
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
6473 this.pushNode(new TypeAnnotation((($0 = this.popNode()) && $0.is$Identifier()) )); 6477 this.pushNode(new TypeAnnotation((($0 = this.popNode()) && $0.is$Identifier()) ));
6474 } 6478 }
6475 BodyListener.prototype.endThrowStatement = function(throwToken, endToken) { 6479 BodyListener.prototype.endThrowStatement = function(throwToken, endToken) {
6476 var $0; 6480 var $0;
6477 var expression = (($0 = this.popNode()) && $0.is$Expression()); 6481 var expression = (($0 = this.popNode()) && $0.is$Expression());
6478 this.pushNode(new Throw(expression, throwToken, endToken)); 6482 this.pushNode(new Throw(expression, throwToken, endToken));
6479 } 6483 }
6480 BodyListener.prototype.endRethrowStatement = function(throwToken, endToken) { 6484 BodyListener.prototype.endRethrowStatement = function(throwToken, endToken) {
6481 this.pushNode(new Throw(null, throwToken, endToken)); 6485 this.pushNode(new Throw(null, throwToken, endToken));
6482 } 6486 }
6487 BodyListener.prototype.handleNoType = function(token) {
6488 this.pushNode(null);
6489 }
6483 BodyListener.prototype.makeNodeList = function(count, beginToken, endToken, deli miter) { 6490 BodyListener.prototype.makeNodeList = function(count, beginToken, endToken, deli miter) {
6484 var $0; 6491 var $0;
6485 var nodes = const$228/*const EmptyLink()*/; 6492 var nodes = const$228/*const EmptyLink()*/;
6486 for (; $notnull_bool(count > 0); --count) { 6493 for (; $notnull_bool(count > 0); --count) {
6487 nodes = (($0 = nodes.prepend(this.popNode())) && $0.is$Link$Node()); 6494 nodes = (($0 = nodes.prepend(this.popNode())) && $0.is$Link$Node());
6488 } 6495 }
6489 var sourceDelimiter = (($0 = $notnull_bool((delimiter == null)) ? null : new S tringWrapper(delimiter)) && $0.is$SourceString()); 6496 var sourceDelimiter = (($0 = $notnull_bool((delimiter == null)) ? null : new S tringWrapper(delimiter)) && $0.is$SourceString());
6490 return new NodeList(beginToken, nodes, endToken, sourceDelimiter); 6497 return new NodeList(beginToken, nodes, endToken, sourceDelimiter);
6491 } 6498 }
6492 BodyListener.prototype.log = function(message) { 6499 BodyListener.prototype.log = function(message) {
(...skipping 13591 matching lines...) Expand 10 before | Expand all | Expand 10 after
20084 INTERFACE, 20091 INTERFACE,
20085 LIBRARY, 20092 LIBRARY,
20086 NATIVE, 20093 NATIVE,
20087 NEGATE, 20094 NEGATE,
20088 OPERATOR, 20095 OPERATOR,
20089 SET, 20096 SET,
20090 SOURCE, 20097 SOURCE,
20091 STATIC, 20098 STATIC,
20092 TYPEDEF ]*/; 20099 TYPEDEF ]*/;
20093 RunEntry(function () {main();}, []); 20100 RunEntry(function () {main();}, []);
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698