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

Side by Side Diff: packages/glob/lib/src/parser.dart

Issue 3015713002: Roll to pickup pool changes
Patch Set: Created 3 years, 2 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 | « packages/glob/lib/src/list_tree.dart ('k') | packages/glob/lib/src/stream_pool.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:path/path.dart' as p; 5 import 'package:path/path.dart' as p;
6 import 'package:string_scanner/string_scanner.dart'; 6 import 'package:string_scanner/string_scanner.dart';
7 7
8 import 'ast.dart'; 8 import 'ast.dart';
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 continue; 113 continue;
114 } 114 }
115 115
116 // Allow a backslash to escape a character. 116 // Allow a backslash to escape a character.
117 _scanner.scan('\\'); 117 _scanner.scan('\\');
118 118
119 var end = readRangeChar(); 119 var end = readRangeChar();
120 120
121 if (end < char) { 121 if (end < char) {
122 _scanner.error("Range out of order.", 122 _scanner.error("Range out of order.",
123 position: start, 123 position: start, length: _scanner.position - start);
124 length: _scanner.position - start);
125 } 124 }
126 ranges.add(new Range(char, end)); 125 ranges.add(new Range(char, end));
127 } else { 126 } else {
128 ranges.add(new Range.singleton(char)); 127 ranges.add(new Range.singleton(char));
129 } 128 }
130 } 129 }
131 130
132 return new RangeNode(ranges, 131 return new RangeNode(ranges,
133 negated: negated, caseSensitive: _caseSensitive); 132 negated: negated, caseSensitive: _caseSensitive);
134 } 133 }
(...skipping 14 matching lines...) Expand all
149 if (options.length == 1) _scanner.expect(','); 148 if (options.length == 1) _scanner.expect(',');
150 _scanner.expect('}'); 149 _scanner.expect('}');
151 150
152 return new OptionsNode(options, caseSensitive: _caseSensitive); 151 return new OptionsNode(options, caseSensitive: _caseSensitive);
153 } 152 }
154 153
155 /// Parses a [LiteralNode]. 154 /// Parses a [LiteralNode].
156 AstNode _parseLiteral({bool inOptions: false}) { 155 AstNode _parseLiteral({bool inOptions: false}) {
157 // If we're in an options block, we want to stop parsing as soon as we hit a 156 // If we're in an options block, we want to stop parsing as soon as we hit a
158 // comma. Otherwise, commas are fair game for literals. 157 // comma. Otherwise, commas are fair game for literals.
159 var regExp = new RegExp( 158 var regExp =
160 inOptions ? r'[^*{[?\\}\],()]*' : r'[^*{[?\\}\]()]*'); 159 new RegExp(inOptions ? r'[^*{[?\\}\],()]*' : r'[^*{[?\\}\]()]*');
161 160
162 _scanner.scan(regExp); 161 _scanner.scan(regExp);
163 var buffer = new StringBuffer()..write(_scanner.lastMatch[0]); 162 var buffer = new StringBuffer()..write(_scanner.lastMatch[0]);
164 163
165 while (_scanner.scan('\\')) { 164 while (_scanner.scan('\\')) {
166 buffer.writeCharCode(_scanner.readChar()); 165 buffer.writeCharCode(_scanner.readChar());
167 _scanner.scan(regExp); 166 _scanner.scan(regExp);
168 buffer.write(_scanner.lastMatch[0]); 167 buffer.write(_scanner.lastMatch[0]);
169 } 168 }
170 169
171 for (var char in const [']', '(', ')']) { 170 for (var char in const [']', '(', ')']) {
172 if (_scanner.matches(char)) _scanner.error('unexpected "$char"'); 171 if (_scanner.matches(char)) _scanner.error('unexpected "$char"');
173 } 172 }
174 if (!inOptions && _scanner.matches('}')) _scanner.error('unexpected "}"'); 173 if (!inOptions && _scanner.matches('}')) _scanner.error('unexpected "}"');
175 174
176 return new LiteralNode(buffer.toString(), 175 return new LiteralNode(buffer.toString(),
177 context: _context, caseSensitive: _caseSensitive); 176 context: _context, caseSensitive: _caseSensitive);
178 } 177 }
179 } 178 }
OLDNEW
« no previous file with comments | « packages/glob/lib/src/list_tree.dart ('k') | packages/glob/lib/src/stream_pool.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698