| OLD | NEW |
| 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 #import("../../../leg/leg.dart"); | 5 #import("../../../leg/leg.dart"); |
| 6 #import("../../../leg/scanner/scannerlib.dart"); | 6 #import("../../../leg/scanner/scannerlib.dart"); |
| 7 #import("../../../leg/elements/elements.dart"); | 7 #import("../../../leg/elements/elements.dart"); |
| 8 #import("../../../leg/tree/tree.dart"); | 8 #import("../../../leg/tree/tree.dart"); |
| 9 #import("../../../leg/util/util.dart"); | 9 #import("../../../leg/util/util.dart"); |
| 10 | 10 |
| 11 class LoggerCanceler implements Logger, Canceler { | 11 class LoggerCanceler implements Logger, Canceler { |
| 12 void cancel([String reason]) { | 12 void cancel([String reason]) { |
| 13 throw new CompilerCancelledException(reason); | 13 throw new CompilerCancelledException(reason); |
| 14 } | 14 } |
| 15 | 15 |
| 16 void log(message) { | 16 void log(message) { |
| 17 // print(message); | 17 // print(message); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 Token scan(String text) => new StringScanner(text).tokenize(); | 21 Token scan(String text) => new StringScanner(text).tokenize(); |
| 22 | 22 |
| 23 Node parseBodyCode(String text, Function parseMethod) { | 23 Node parseBodyCode(String text, Function parseMethod) { |
| 24 Token tokens = scan(text); | 24 Token tokens = scan(text); |
| 25 LoggerCanceler lc = new LoggerCanceler(); | 25 LoggerCanceler lc = new LoggerCanceler(); |
| 26 BodyListener listener = new BodyListener(lc, lc); | 26 NodeListener listener = new NodeListener(lc, lc); |
| 27 BodyParser parser = new BodyParser(listener); | 27 Parser parser = new Parser(listener); |
| 28 Token endToken = parseMethod(parser, tokens); | 28 Token endToken = parseMethod(parser, tokens); |
| 29 assert(endToken.kind == EOF_TOKEN); | 29 assert(endToken.kind == EOF_TOKEN); |
| 30 return listener.popNode(); | 30 return listener.popNode(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 Node parseStatement(String text) => | 33 Node parseStatement(String text) => |
| 34 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); | 34 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); |
| 35 | 35 |
| 36 Node parseFunction(String text, Compiler compiler) { | 36 Node parseFunction(String text, Compiler compiler) { |
| 37 Token tokens = scan(text); | 37 Token tokens = scan(text); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Expect.isTrue(nodes[1] is Send); // i (in i < 10) | 214 Expect.isTrue(nodes[1] is Send); // i (in i < 10) |
| 215 Expect.isTrue(nodes[1] is !SendSet); | 215 Expect.isTrue(nodes[1] is !SendSet); |
| 216 | 216 |
| 217 Expect.isTrue(nodes[2] is Send); // i (in i + 1) | 217 Expect.isTrue(nodes[2] is Send); // i (in i + 1) |
| 218 Expect.isTrue(nodes[2] is !SendSet); | 218 Expect.isTrue(nodes[2] is !SendSet); |
| 219 | 219 |
| 220 Expect.isTrue(nodes[3] is SendSet); // i = i + 1 | 220 Expect.isTrue(nodes[3] is SendSet); // i = i + 1 |
| 221 | 221 |
| 222 Expect.isTrue(nodes[4] is SendSet); // i = 5 | 222 Expect.isTrue(nodes[4] is SendSet); // i = 5 |
| 223 } | 223 } |
| OLD | NEW |