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

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

Issue 78723002: Make sure variable names used in status files are available in the environment (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | no next file » | 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 12 matching lines...) Expand all
23 * 23 *
24 * Values and variableNames are non-empty strings of word characters, matching 24 * Values and variableNames are non-empty strings of word characters, matching
25 * the RegExp \w+. 25 * the RegExp \w+.
26 * 26 *
27 * Expressions evaluate as expected, with values of variables found in 27 * Expressions evaluate as expected, with values of variables found in
28 * an environment passed to the evaluator. The SetExpression "value" 28 * an environment passed to the evaluator. The SetExpression "value"
29 * evaluates to a singleton set containing that value. "A if B" evaluates 29 * evaluates to a singleton set containing that value. "A if B" evaluates
30 * to A if B is true, and to the empty set if B is false. 30 * to A if B is true, and to the empty set if B is false.
31 */ 31 */
32 32
33 class ExprEvaluationException {
34 String error;
35
36 ExprEvaluationException(this.error);
37
38 toString() => error;
39 }
33 40
34 class Token { 41 class Token {
35 static const String LEFT_PAREN = "("; 42 static const String LEFT_PAREN = "(";
36 static const String RIGHT_PAREN = ")"; 43 static const String RIGHT_PAREN = ")";
37 static const String DOLLAR_SYMBOL = r"$"; 44 static const String DOLLAR_SYMBOL = r"$";
38 static const String UNION = ","; 45 static const String UNION = ",";
39 static const String EQUALS = "=="; 46 static const String EQUALS = "==";
40 static const String NOT_EQUALS = "!="; 47 static const String NOT_EQUALS = "!=";
41 static const String AND = "&&"; 48 static const String AND = "&&";
42 static const String OR = "||"; 49 static const String OR = "||";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 String toString() => 97 String toString() =>
91 "(\$${left.name} ${negate ? '!=' : '=='} ${right.value})"; 98 "(\$${left.name} ${negate ? '!=' : '=='} ${right.value})";
92 } 99 }
93 100
94 101
95 class TermVariable { 102 class TermVariable {
96 String name; 103 String name;
97 104
98 TermVariable(this.name); 105 TermVariable(this.name);
99 106
100 String termValue(environment) => environment[name].toString(); 107 String termValue(environment) {
108 var value = environment[name];
109 if (value == null) {
110 throw new ExprEvaluationException(
111 "Could not find '$name' in environment "
112 "while evaluating status file expression.");
113 }
114 return value.toString();
115 }
101 } 116 }
102 117
103 118
104 class TermConstant { 119 class TermConstant {
105 String value; 120 String value;
106 121
107 TermConstant(String this.value); 122 TermConstant(String this.value);
108 123
109 String termValue(environment) => value; 124 String termValue(environment) => value;
110 } 125 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 321 }
307 TermConstant right = new TermConstant(scanner.current); 322 TermConstant right = new TermConstant(scanner.current);
308 scanner.advance(); 323 scanner.advance();
309 return new Comparison(left, right, negate); 324 return new Comparison(left, right, negate);
310 } else { 325 } else {
311 return new BooleanVariable(left); 326 return new BooleanVariable(left);
312 } 327 }
313 } 328 }
314 } 329 }
315 330
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698