| 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 #library("patchparser"); | 5 #library("patchparser"); |
| 6 #import("dart:uri"); | 6 #import("dart:uri"); |
| 7 | 7 |
| 8 #import("tree/tree.dart", prefix: "tree"); | 8 #import("tree/tree.dart", prefix: "tree"); |
| 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. | 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. |
| 10 #import("apiimpl.dart"); | 10 #import("apiimpl.dart"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void endPatch(Token patch); | 88 void endPatch(Token patch); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Partial parser that extends the top-level and class grammars to allow the | 92 * Partial parser that extends the top-level and class grammars to allow the |
| 93 * word "patch" in front of some declarations. | 93 * word "patch" in front of some declarations. |
| 94 */ | 94 */ |
| 95 class PatchParser extends PartialParser { | 95 class PatchParser extends PartialParser { |
| 96 PatchParser(PatchListener listener) : super(listener); | 96 PatchParser(PatchListener listener) : super(listener); |
| 97 | 97 |
| 98 PatchListener get patchListener() => listener; | 98 PatchListener get patchListener => listener; |
| 99 | 99 |
| 100 bool isPatch(Token token) { | 100 bool isPatch(Token token) { |
| 101 return token.stringValue === null && | 101 return token.stringValue === null && |
| 102 token.slowToString() == "patch"; | 102 token.slowToString() == "patch"; |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Parse top-level declarations, and allow "patch" in front of functions | 106 * Parse top-level declarations, and allow "patch" in front of functions |
| 107 * and classes. | 107 * and classes. |
| 108 */ | 108 */ |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 void addMember(Element element) { | 282 void addMember(Element element) { |
| 283 if (isMemberPatch || (isClassPatch && element is ClassElement)) { | 283 if (isMemberPatch || (isClassPatch && element is ClassElement)) { |
| 284 element.addMetadata(popNode()); | 284 element.addMetadata(popNode()); |
| 285 } | 285 } |
| 286 super.addMember(element); | 286 super.addMember(element); |
| 287 } | 287 } |
| 288 } | 288 } |
| OLD | NEW |