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

Unified Diff: lib/src/scanner.dart

Issue 1329763002: Don't use regular expressions in Loader. (Closed) Base URL: git@github.com:dart-lang/yaml@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/loader.dart ('k') | lib/src/yaml_node.dart » ('j') | pubspec.yaml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/scanner.dart
diff --git a/lib/src/scanner.dart b/lib/src/scanner.dart
index 2e02a8f7de8097b36fa0d261a4f0454b1ac37f1b..512d72e8afd596b29b5253b0037693285bc4a5c4 100644
--- a/lib/src/scanner.dart
+++ b/lib/src/scanner.dart
@@ -292,7 +292,7 @@ class Scanner {
///
/// [sourceUrl] can be a String or a [Uri].
Scanner(String source, {sourceUrl})
- : _scanner = new SpanScanner.eager(source, sourceUrl: sourceUrl);
+ : _scanner = new SpanScanner(source, sourceUrl: sourceUrl);
Bob Nystrom 2015/09/02 23:13:14 Do you need to merge in that previous change?
nweiz 2015/09/02 23:37:59 Oops!
/// Consumes and returns the next token.
Token scan() {
@@ -485,7 +485,7 @@ class Scanner {
// everything but multiline simple keys in a block context.
if (!_inBlockContext) continue;
- if (key.line == _scanner.line) continue;
+ if (key.location.line == _scanner.line) continue;
if (key.required) {
throw new YamlException("Expected ':'.", _scanner.emptySpan);
@@ -513,8 +513,6 @@ class Scanner {
_removeSimpleKey();
_simpleKeys[_simpleKeys.length - 1] = new _SimpleKey(
_tokensParsed + _tokens.length,
- _scanner.line,
- _scanner.column,
_scanner.location,
required: required);
}
@@ -662,7 +660,7 @@ class Scanner {
_rollIndent(
_scanner.column,
TokenType.BLOCK_SEQUENCE_START,
- _scanner.location);
+ _scanner.emptySpan.start);
} else {
// It is an error for the '-' indicator to occur in the flow context, but
// we let the Parser detect and report it because it's able to point to
@@ -685,7 +683,7 @@ class Scanner {
_rollIndent(
_scanner.column,
TokenType.BLOCK_MAPPING_START,
- _scanner.location);
+ _scanner.emptySpan.start);
}
// Simple keys are allowed after `?` in a block context.
@@ -705,7 +703,7 @@ class Scanner {
// In the block context, we may need to add the
// [TokenType.BLOCK_MAPPING_START] token.
_rollIndent(
- simpleKey.column,
+ simpleKey.location.column,
TokenType.BLOCK_MAPPING_START,
simpleKey.location,
tokenNumber: simpleKey.tokenNumber);
@@ -1641,23 +1639,10 @@ class _SimpleKey {
/// no longer on the current line.
final SourceLocation location;
- /// The line on which the key appears.
- ///
- /// We could get this from [location], but that requires a binary search
- /// whereas this is O(1).
- final int line;
-
- /// The column on which the key appears.
- ///
- /// We could get this from [location], but that requires a binary search
- /// whereas this is O(1).
- final int column;
-
/// Whether this key must exist for the document to be scanned.
final bool required;
- _SimpleKey(this.tokenNumber, this.line, this.column, this.location,
- {bool required})
+ _SimpleKey(this.tokenNumber, this.location, {bool required})
: required = required;
}
« no previous file with comments | « lib/src/loader.dart ('k') | lib/src/yaml_node.dart » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698