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

Side by Side Diff: tools/testing/dart/status_expression.dart

Issue 11312203: "Reverting 14829-14832" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | tools/testing/dart/status_file_parser.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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("status_expression"); 5 #library("status_expression");
6 6
7 /** 7 /**
8 * Parse and evaluate expressions in a .status file for Dart and V8. 8 * Parse and evaluate expressions in a .status file for Dart and V8.
9 * There are set expressions and Boolean expressions in a .status file. 9 * There are set expressions and Boolean expressions in a .status file.
10 * The grammar is: 10 * The grammar is:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 44
45 class Tokenizer { 45 class Tokenizer {
46 String expression; 46 String expression;
47 List<String> tokens; 47 List<String> tokens;
48 48
49 Tokenizer(String this.expression) 49 Tokenizer(String this.expression)
50 : tokens = new List<String>(); 50 : tokens = new List<String>();
51 51
52 // Tokens are : "(", ")", "$", ",", "&&", "||", "==", and (maximal) \w+. 52 // Tokens are : "(", ")", "$", ",", "&&", "||", "==", and (maximal) \w+.
53 static final testRegexp = 53 static const testRegexp =
54 new RegExp(r"^([()$\w\s,]|(\&\&)|(\|\|)|(\=\=))+$"); 54 const RegExp(r"^([()$\w\s,]|(\&\&)|(\|\|)|(\=\=))+$");
55 static final regexp = new RegExp(r"[()$,]|(\&\&)|(\|\|)|(\=\=)|\w+"); 55 static const regexp = const RegExp(r"[()$,]|(\&\&)|(\|\|)|(\=\=)|\w+");
56 56
57 List<String> tokenize() { 57 List<String> tokenize() {
58 if (!testRegexp.hasMatch(expression)) { 58 if (!testRegexp.hasMatch(expression)) {
59 throw new ExpectException("Syntax error in '$expression'"); 59 throw new ExpectException("Syntax error in '$expression'");
60 } 60 }
61 for (Match match in regexp.allMatches(expression)) tokens.add(match[0]); 61 for (Match match in regexp.allMatches(expression)) tokens.add(match[0]);
62 return tokens; 62 return tokens;
63 } 63 }
64 } 64 }
65 65
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 SetExpression parseSetAtomic() { 228 SetExpression parseSetAtomic() {
229 if (scanner.current == Token.LEFT_PAREN) { 229 if (scanner.current == Token.LEFT_PAREN) {
230 scanner.advance(); 230 scanner.advance();
231 SetExpression value = parseSetExpression(); 231 SetExpression value = parseSetExpression();
232 Expect.equals(scanner.current, Token.RIGHT_PAREN, 232 Expect.equals(scanner.current, Token.RIGHT_PAREN,
233 "Missing right parenthesis in expression"); 233 "Missing right parenthesis in expression");
234 scanner.advance(); 234 scanner.advance();
235 return value; 235 return value;
236 } 236 }
237 Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current), 237 Expect.isTrue(const RegExp(r"^\w+$").hasMatch(scanner.current),
238 "Expected identifier in expression, got ${scanner.current}"); 238 "Expected identifier in expression, got ${scanner.current}");
239 SetExpression value = new SetConstant(scanner.current); 239 SetExpression value = new SetConstant(scanner.current);
240 scanner.advance(); 240 scanner.advance();
241 return value; 241 return value;
242 } 242 }
243 243
244 BooleanExpression parseBooleanExpression() => parseBooleanOr(); 244 BooleanExpression parseBooleanExpression() => parseBooleanOr();
245 245
246 BooleanExpression parseBooleanOr() { 246 BooleanExpression parseBooleanOr() {
247 BooleanExpression left = parseBooleanAnd(); 247 BooleanExpression left = parseBooleanAnd();
(...skipping 23 matching lines...) Expand all
271 "Missing right parenthesis in expression"); 271 "Missing right parenthesis in expression");
272 scanner.advance(); 272 scanner.advance();
273 return value; 273 return value;
274 } 274 }
275 275
276 // The only atomic booleans are of the form $variable == value or the 276 // The only atomic booleans are of the form $variable == value or the
277 // form $variable. 277 // form $variable.
278 Expect.equals(scanner.current, Token.DOLLAR_SYMBOL, 278 Expect.equals(scanner.current, Token.DOLLAR_SYMBOL,
279 "Expected \$ in expression, got ${scanner.current}"); 279 "Expected \$ in expression, got ${scanner.current}");
280 scanner.advance(); 280 scanner.advance();
281 Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current), 281 Expect.isTrue(const RegExp(r"^\w+$").hasMatch(scanner.current),
282 "Expected identifier in expression, got ${scanner.current}"); 282 "Expected identifier in expression, got ${scanner.current}");
283 TermVariable left = new TermVariable(scanner.current); 283 TermVariable left = new TermVariable(scanner.current);
284 scanner.advance(); 284 scanner.advance();
285 if (scanner.current == Token.EQUALS) { 285 if (scanner.current == Token.EQUALS) {
286 scanner.advance(); 286 scanner.advance();
287 Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current), 287 Expect.isTrue(const RegExp(r"^\w+$").hasMatch(scanner.current),
288 "Expected identifier in expression, got ${scanner.current}"); 288 "Expected identifier in expression, got ${scanner.current}");
289 TermConstant right = new TermConstant(scanner.current); 289 TermConstant right = new TermConstant(scanner.current);
290 scanner.advance(); 290 scanner.advance();
291 return new Comparison(left, right); 291 return new Comparison(left, right);
292 } else { 292 } else {
293 return new BooleanVariable(left); 293 return new BooleanVariable(left);
294 } 294 }
295 } 295 }
296 } 296 }
297 297
OLDNEW
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | tools/testing/dart/status_file_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698