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

Side by Side Diff: pkg/string_scanner/lib/src/utils.dart

Issue 299973002: Add LineScanner and SpanScanner classes to string_scanner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: analyzer fixes Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library string_scanner.utils;
6
7 /// Validates the arguments passed to [StringScanner.error].
8 void validateErrorArgs(String string, Match match, int position, int length) {
9 if (match != null && (position != null || length != null)) {
10 throw new ArgumentError("Can't pass both match and position/length.");
11 }
12
13 if (position != null) {
14 if (position < 0) {
15 throw new RangeError("position must be greater than or equal to 0.");
16 } else if (position > string.length) {
17 throw new RangeError("position must be less than or equal to the "
18 "string length.");
19 }
20 }
21
22 if (length != null && length < 0) {
23 throw new RangeError("length must be greater than or equal to 0.");
24 }
Bob Nystrom 2014/05/28 21:28:57 Check for position + length going past the end?
nweiz 2014/05/28 23:56:34 Done.
25 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698