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

Side by Side Diff: lib/src/line_scanner.dart

Issue 2056933002: Add breaking changes and release 1.0.0. (Closed) Base URL: git@github.com:dart-lang/string_scanner@master
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span_scanner.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 'package:charcode/ascii.dart'; 5 import 'package:charcode/ascii.dart';
6 6
7 import 'string_scanner.dart'; 7 import 'string_scanner.dart';
8 8
9 // Note that much of this code is duplicated in eager_span_scanner.dart. 9 // Note that much of this code is duplicated in eager_span_scanner.dart.
10 10
11 /// A regular expression matching newlines across platforms. 11 /// A regular expression matching newlines across platforms.
12 final _newlineRegExp = new RegExp(r"\r\n?|\n"); 12 final _newlineRegExp = new RegExp(r"\r\n?|\n");
13 13
14 /// A subclass of [StringScanner] that tracks line and column information. 14 /// A subclass of [StringScanner] that tracks line and column information.
15 class LineScanner extends StringScanner { 15 class LineScanner extends StringScanner {
16 /// The scanner's current (zero-based) line number. 16 /// The scanner's current (zero-based) line number.
17 int get line => _line; 17 int get line => _line;
18 int _line = 0; 18 int _line = 0;
19 19
20 /// The scanner's current (zero-based) column number. 20 /// The scanner's current (zero-based) column number.
21 int get column => _column; 21 int get column => _column;
22 int _column = 0; 22 int _column = 0;
23 23
24 /// The scanner's state, including line and column information. 24 /// The scanner's state, including line and column information.
25 /// 25 ///
26 /// This can be used to efficiently save and restore the state of the scanner 26 /// This can be used to efficiently save and restore the state of the scanner
27 /// when backtracking. A given [LineScannerState] is only valid for the 27 /// when backtracking. A given [LineScannerState] is only valid for the
28 /// [LineScanner] that created it. 28 /// [LineScanner] that created it.
29 ///
30 /// This does not include the scanner's match information.
29 LineScannerState get state => 31 LineScannerState get state =>
30 new LineScannerState._(this, position, line, column); 32 new LineScannerState._(this, position, line, column);
31 33
32 /// Whether the current position is between a CR character and an LF 34 /// Whether the current position is between a CR character and an LF
33 /// charactet. 35 /// charactet.
34 bool get _betweenCRLF => peekChar(-1) == $cr && peekChar() == $lf; 36 bool get _betweenCRLF => peekChar(-1) == $cr && peekChar() == $lf;
35 37
36 set state(LineScannerState state) { 38 set state(LineScannerState state) {
37 if (!identical(state._scanner, this)) { 39 if (!identical(state._scanner, this)) {
38 throw new ArgumentError("The given LineScannerState was not returned by " 40 throw new ArgumentError("The given LineScannerState was not returned by "
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 final int position; 129 final int position;
128 130
129 /// The zero-based line number of the scanner in this state. 131 /// The zero-based line number of the scanner in this state.
130 final int line; 132 final int line;
131 133
132 /// The zero-based column number of the scanner in this state. 134 /// The zero-based column number of the scanner in this state.
133 final int column; 135 final int column;
134 136
135 LineScannerState._(this._scanner, this.position, this.line, this.column); 137 LineScannerState._(this._scanner, this.position, this.line, this.column);
136 } 138 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698