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

Side by Side Diff: samples/markdown/inline_parser.dart

Issue 11266050: Rename regexp methods to getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and update status files with co19 issue number. Created 8 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 | « runtime/lib/string_base.dart ('k') | samples/third_party/dromaeo/common/BenchUtil.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 // 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 /// Maintains the internal state needed to parse inline span elements in 5 /// Maintains the internal state needed to parse inline span elements in
6 /// markdown. 6 /// markdown.
7 class InlineParser { 7 class InlineParser {
8 static List<InlineSyntax> get syntaxes { 8 static List<InlineSyntax> get syntaxes {
9 // Lazy initialize. 9 // Lazy initialize.
10 if (_syntaxes == null) { 10 if (_syntaxes == null) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 /// Represents one kind of markdown tag that can be parsed. 138 /// Represents one kind of markdown tag that can be parsed.
139 class InlineSyntax { 139 class InlineSyntax {
140 final RegExp pattern; 140 final RegExp pattern;
141 141
142 InlineSyntax(String pattern) 142 InlineSyntax(String pattern)
143 : pattern = new RegExp(pattern, multiLine: true); 143 : pattern = new RegExp(pattern, multiLine: true);
144 144
145 bool tryMatch(InlineParser parser) { 145 bool tryMatch(InlineParser parser) {
146 final startMatch = pattern.firstMatch(parser.currentSource); 146 final startMatch = pattern.firstMatch(parser.currentSource);
147 if ((startMatch != null) && (startMatch.start() == 0)) { 147 if ((startMatch != null) && (startMatch.start == 0)) {
148 // Write any existing plain text up to this point. 148 // Write any existing plain text up to this point.
149 parser.writeText(); 149 parser.writeText();
150 150
151 if (onMatch(parser, startMatch)) { 151 if (onMatch(parser, startMatch)) {
152 parser.consume(startMatch[0].length); 152 parser.consume(startMatch[0].length);
153 } 153 }
154 return true; 154 return true;
155 } 155 }
156 return false; 156 return false;
157 } 157 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 /// The children of this node. Will be `null` for text nodes. 335 /// The children of this node. Will be `null` for text nodes.
336 final List<Node> children; 336 final List<Node> children;
337 337
338 TagState(this.startPos, this.endPos, this.syntax) 338 TagState(this.startPos, this.endPos, this.syntax)
339 : children = <Node>[]; 339 : children = <Node>[];
340 340
341 /// Attempts to close this tag by matching the current text against its end 341 /// Attempts to close this tag by matching the current text against its end
342 /// pattern. 342 /// pattern.
343 bool tryMatch(InlineParser parser) { 343 bool tryMatch(InlineParser parser) {
344 Match endMatch = syntax.endPattern.firstMatch(parser.currentSource); 344 Match endMatch = syntax.endPattern.firstMatch(parser.currentSource);
345 if ((endMatch != null) && (endMatch.start() == 0)) { 345 if ((endMatch != null) && (endMatch.start == 0)) {
346 // Close the tag. 346 // Close the tag.
347 close(parser, endMatch); 347 close(parser, endMatch);
348 return true; 348 return true;
349 } 349 }
350 350
351 return false; 351 return false;
352 } 352 }
353 353
354 /// Pops this tag off the stack, completes it, and adds it to the output. 354 /// Pops this tag off the stack, completes it, and adds it to the output.
355 /// Will discard any unmatched tags that happen to be above it on the stack. 355 /// Will discard any unmatched tags that happen to be above it on the stack.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 parser.consume(endMatch[0].length); 387 parser.consume(endMatch[0].length);
388 } else { 388 } else {
389 // Didn't close correctly so revert to text. 389 // Didn't close correctly so revert to text.
390 parser.start = startPos; 390 parser.start = startPos;
391 parser.advanceBy(endMatch[0].length); 391 parser.advanceBy(endMatch[0].length);
392 } 392 }
393 393
394 return null; 394 return null;
395 } 395 }
396 } 396 }
OLDNEW
« no previous file with comments | « runtime/lib/string_base.dart ('k') | samples/third_party/dromaeo/common/BenchUtil.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698