| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (scanner.current == Token.LEFT_PAREN) { | 291 if (scanner.current == Token.LEFT_PAREN) { |
| 292 scanner.advance(); | 292 scanner.advance(); |
| 293 BooleanExpression value = parseBooleanExpression(); | 293 BooleanExpression value = parseBooleanExpression(); |
| 294 if (scanner.current != Token.RIGHT_PAREN) { | 294 if (scanner.current != Token.RIGHT_PAREN) { |
| 295 throw new FormatException("Missing right parenthesis in expression"); | 295 throw new FormatException("Missing right parenthesis in expression"); |
| 296 } | 296 } |
| 297 scanner.advance(); | 297 scanner.advance(); |
| 298 return value; | 298 return value; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // The only atomic booleans are of the form $variable == value or the | 301 // The only atomic booleans are of the form $variable == value or |
| 302 // form $variable. | 302 // of the form $variable. |
| 303 if (scanner.current != Token.DOLLAR_SYMBOL) { | 303 if (scanner.current != Token.DOLLAR_SYMBOL) { |
| 304 throw new FormatException( | 304 throw new FormatException( |
| 305 "Expected \$ in expression, got ${scanner.current}"); | 305 "Expected \$ in expression, got ${scanner.current}"); |
| 306 } | 306 } |
| 307 scanner.advance(); | 307 scanner.advance(); |
| 308 if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) { | 308 if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) { |
| 309 throw new FormatException( | 309 throw new FormatException( |
| 310 "Expected identifier in expression, got ${scanner.current}"); | 310 "Expected identifier in expression, got ${scanner.current}"); |
| 311 } | 311 } |
| 312 TermVariable left = new TermVariable(scanner.current); | 312 TermVariable left = new TermVariable(scanner.current); |
| 313 scanner.advance(); | 313 scanner.advance(); |
| 314 if (scanner.current == Token.EQUALS || | 314 if (scanner.current == Token.EQUALS || |
| 315 scanner.current == Token.NOT_EQUALS) { | 315 scanner.current == Token.NOT_EQUALS) { |
| 316 bool negate = scanner.current == Token.NOT_EQUALS; | 316 bool negate = scanner.current == Token.NOT_EQUALS; |
| 317 scanner.advance(); | 317 scanner.advance(); |
| 318 if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) { | 318 if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) { |
| 319 throw new FormatException( | 319 throw new FormatException( |
| 320 "Expected identifier in expression, got ${scanner.current}"); | 320 "Expected value in expression, got ${scanner.current}"); |
| 321 } | 321 } |
| 322 TermConstant right = new TermConstant(scanner.current); | 322 TermConstant right = new TermConstant(scanner.current); |
| 323 scanner.advance(); | 323 scanner.advance(); |
| 324 return new Comparison(left, right, negate); | 324 return new Comparison(left, right, negate); |
| 325 } else { | 325 } else { |
| 326 return new BooleanVariable(left); | 326 return new BooleanVariable(left); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| OLD | NEW |