| OLD | NEW |
| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 Set<String> evaluate(environment) => right.evaluate(environment) ? | 156 Set<String> evaluate(environment) => right.evaluate(environment) ? |
| 157 left.evaluate(environment) : new Set<String>(); | 157 left.evaluate(environment) : new Set<String>(); |
| 158 String toString() => "($left if $right)"; | 158 String toString() => "($left if $right)"; |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 class SetConstant implements SetExpression { | 162 class SetConstant implements SetExpression { |
| 163 String value; | 163 String value; |
| 164 | 164 |
| 165 SetConstant(this.value); | 165 SetConstant(String v) : value = v.toLowerCase(); |
| 166 | 166 |
| 167 Set<String> evaluate(environment) => new Set<String>.from([value]); | 167 Set<String> evaluate(environment) => new Set<String>.from([value]); |
| 168 String toString() => value; | 168 String toString() => value; |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 // An iterator that allows peeking at the current token. | 172 // An iterator that allows peeking at the current token. |
| 173 class Scanner { | 173 class Scanner { |
| 174 List<String> tokens; | 174 List<String> tokens; |
| 175 Iterator tokenIterator; | 175 Iterator tokenIterator; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 "Expected identifier in expression, got ${scanner.current}"); | 289 "Expected identifier in expression, got ${scanner.current}"); |
| 290 TermConstant right = new TermConstant(scanner.current); | 290 TermConstant right = new TermConstant(scanner.current); |
| 291 scanner.advance(); | 291 scanner.advance(); |
| 292 return new Comparison(left, right); | 292 return new Comparison(left, right); |
| 293 } else { | 293 } else { |
| 294 return new BooleanVariable(left); | 294 return new BooleanVariable(left); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| OLD | NEW |