OLD | NEW |
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 library string_scanner.line_scanner; | 5 library string_scanner.line_scanner; |
6 | 6 |
7 import 'package:charcode/ascii.dart'; | 7 import 'package:charcode/ascii.dart'; |
8 | 8 |
9 import 'string_scanner.dart'; | 9 import 'string_scanner.dart'; |
10 | 10 |
| 11 // Note that much of this code is duplicated in eager_span_scanner.dart. |
| 12 |
11 /// A regular expression matching newlines across platforms. | 13 /// A regular expression matching newlines across platforms. |
12 final _newlineRegExp = new RegExp(r"\r\n?|\n"); | 14 final _newlineRegExp = new RegExp(r"\r\n?|\n"); |
13 | 15 |
14 /// A subclass of [StringScanner] that tracks line and column information. | 16 /// A subclass of [StringScanner] that tracks line and column information. |
15 class LineScanner extends StringScanner { | 17 class LineScanner extends StringScanner { |
16 /// The scanner's current (zero-based) line number. | 18 /// The scanner's current (zero-based) line number. |
17 int get line => _line; | 19 int get line => _line; |
18 int _line = 0; | 20 int _line = 0; |
19 | 21 |
20 /// The scanner's current (zero-based) column number. | 22 /// The scanner's current (zero-based) column number. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 final int position; | 118 final int position; |
117 | 119 |
118 /// The zero-based line number of the scanner in this state. | 120 /// The zero-based line number of the scanner in this state. |
119 final int line; | 121 final int line; |
120 | 122 |
121 /// The zero-based column number of the scanner in this state. | 123 /// The zero-based column number of the scanner in this state. |
122 final int column; | 124 final int column; |
123 | 125 |
124 LineScannerState._(this._scanner, this.position, this.line, this.column); | 126 LineScannerState._(this._scanner, this.position, this.line, this.column); |
125 } | 127 } |
OLD | NEW |