OLD | NEW |
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 part of js; | 5 part of js; |
6 | 6 |
7 abstract class NodeVisitor<T> { | 7 abstract class NodeVisitor<T> { |
8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
9 | 9 |
10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 | 1074 |
1075 LiteralString string(String value) => js.string(value); | 1075 LiteralString string(String value) => js.string(value); |
1076 | 1076 |
1077 class MiniJsParserError { | 1077 class MiniJsParserError { |
1078 MiniJsParserError(this.parser, this.message) { } | 1078 MiniJsParserError(this.parser, this.message) { } |
1079 | 1079 |
1080 MiniJsParser parser; | 1080 MiniJsParser parser; |
1081 String message; | 1081 String message; |
1082 | 1082 |
1083 String toString() { | 1083 String toString() { |
1084 var codes = | 1084 var codes = new List.filled(parser.lastPosition, charCodes.$SPACE); |
1085 new List.fixedLength(parser.lastPosition, fill: charCodes.$SPACE); | |
1086 var spaces = new String.fromCharCodes(codes); | 1085 var spaces = new String.fromCharCodes(codes); |
1087 return "Error in MiniJsParser:\n${parser.src}\n$spaces^\n$spaces$message\n"; | 1086 return "Error in MiniJsParser:\n${parser.src}\n$spaces^\n$spaces$message\n"; |
1088 } | 1087 } |
1089 } | 1088 } |
1090 | 1089 |
1091 /// Mini JavaScript parser for tiny snippets of code that we want to make into | 1090 /// Mini JavaScript parser for tiny snippets of code that we want to make into |
1092 /// AST nodes. Handles: | 1091 /// AST nodes. Handles: |
1093 /// * identifiers. | 1092 /// * identifiers. |
1094 /// * dot access. | 1093 /// * dot access. |
1095 /// * method calls. | 1094 /// * method calls. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 | 1483 |
1485 Expression expression() { | 1484 Expression expression() { |
1486 Expression expression = parseVarDeclarationOrExpression(); | 1485 Expression expression = parseVarDeclarationOrExpression(); |
1487 if (lastCategory != NONE || position != src.length) { | 1486 if (lastCategory != NONE || position != src.length) { |
1488 throw new MiniJsParserError( | 1487 throw new MiniJsParserError( |
1489 this, "Unparsed junk: ${categoryToString(lastCategory)}"); | 1488 this, "Unparsed junk: ${categoryToString(lastCategory)}"); |
1490 } | 1489 } |
1491 return expression; | 1490 return expression; |
1492 } | 1491 } |
1493 } | 1492 } |
OLD | NEW |