| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 scanner.advance(); | 260 scanner.advance(); |
| 261 BooleanExpression right = parseBooleanAtomic(); | 261 BooleanExpression right = parseBooleanAtomic(); |
| 262 left = new BooleanOperation(Token.AND, left, right); | 262 left = new BooleanOperation(Token.AND, left, right); |
| 263 } | 263 } |
| 264 return left; | 264 return left; |
| 265 } | 265 } |
| 266 | 266 |
| 267 BooleanExpression parseBooleanAtomic() { | 267 BooleanExpression parseBooleanAtomic() { |
| 268 if (scanner.current == Token.LEFT_PAREN) { | 268 if (scanner.current == Token.LEFT_PAREN) { |
| 269 scanner.advance(); | 269 scanner.advance(); |
| 270 SetExpression value = parseBooleanExpression(); | 270 BooleanExpression value = parseBooleanExpression(); |
| 271 Expect.equals(scanner.current, Token.RIGHT_PAREN, | 271 Expect.equals(scanner.current, Token.RIGHT_PAREN, |
| 272 "Missing right parenthesis in expression"); | 272 "Missing right parenthesis in expression"); |
| 273 scanner.advance(); | 273 scanner.advance(); |
| 274 return value; | 274 return value; |
| 275 } | 275 } |
| 276 | 276 |
| 277 // The only atomic booleans are of the form $variable == value or the | 277 // The only atomic booleans are of the form $variable == value or the |
| 278 // form $variable. | 278 // form $variable. |
| 279 Expect.equals(scanner.current, Token.DOLLAR_SYMBOL, | 279 Expect.equals(scanner.current, Token.DOLLAR_SYMBOL, |
| 280 "Expected \$ in expression, got ${scanner.current}"); | 280 "Expected \$ in expression, got ${scanner.current}"); |
| 281 scanner.advance(); | 281 scanner.advance(); |
| 282 Expect.isTrue(const RegExp(@"^\w+$").hasMatch(scanner.current), | 282 Expect.isTrue(const RegExp(@"^\w+$").hasMatch(scanner.current), |
| 283 "Expected identifier in expression, got ${scanner.current}"); | 283 "Expected identifier in expression, got ${scanner.current}"); |
| 284 TermVariable left = new TermVariable(scanner.current); | 284 TermVariable left = new TermVariable(scanner.current); |
| 285 scanner.advance(); | 285 scanner.advance(); |
| 286 if (scanner.current == Token.EQUALS) { | 286 if (scanner.current == Token.EQUALS) { |
| 287 scanner.advance(); | 287 scanner.advance(); |
| 288 Expect.isTrue(const RegExp(@"^\w+$").hasMatch(scanner.current), | 288 Expect.isTrue(const RegExp(@"^\w+$").hasMatch(scanner.current), |
| 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 |