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

Side by Side Diff: pkg/polymer_expressions/lib/parser.dart

Issue 213523004: Fix precedence of ternary operators in polymer expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months 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 | pkg/polymer_expressions/pubspec.yaml » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 polymer_expressions.parser; 5 library polymer_expressions.parser;
6 6
7 import 'tokenizer.dart'; 7 import 'tokenizer.dart';
8 import 'expression.dart'; 8 import 'expression.dart';
9 9
10 const _UNARY_OPERATORS = const ['+', '-', '!']; 10 const _UNARY_OPERATORS = const ['+', '-', '!'];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 left = _astFactory.index(left, indexExpr); 59 left = _astFactory.index(left, indexExpr);
60 } else { 60 } else {
61 break; 61 break;
62 } 62 }
63 } else if (_token.kind == DOT_TOKEN) { 63 } else if (_token.kind == DOT_TOKEN) {
64 _advance(); 64 _advance();
65 var right = _parseUnary(); 65 var right = _parseUnary();
66 left = _makeInvokeOrGetter(left, right); 66 left = _makeInvokeOrGetter(left, right);
67 } else if (_token.kind == KEYWORD_TOKEN && _token.value == 'in') { 67 } else if (_token.kind == KEYWORD_TOKEN && _token.value == 'in') {
68 left = _parseComprehension(left); 68 left = _parseComprehension(left);
69 } else if (_token.kind == OPERATOR_TOKEN && _token.value == '?') {
70 left = _parseTernary(left);
71 } else if (_token.kind == OPERATOR_TOKEN 69 } else if (_token.kind == OPERATOR_TOKEN
72 && _token.precedence >= precedence) { 70 && _token.precedence >= precedence) {
73 left = _parseBinary(left); 71 left = _token.value == '?' ? _parseTernary(left) : _parseBinary(left);
74 } else { 72 } else {
75 break; 73 break;
76 } 74 }
77 } 75 }
78 return left; 76 return left;
79 } 77 }
80 78
81 // invoke or getter 79 // invoke or getter
82 Expression _makeInvokeOrGetter(left, right) { 80 Expression _makeInvokeOrGetter(left, right) {
83 if (right is Identifier) { 81 if (right is Identifier) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return value; 292 return value;
295 } 293 }
296 294
297 Literal<double> _parseDecimal([String prefix = '']) { 295 Literal<double> _parseDecimal([String prefix = '']) {
298 var value = _astFactory.literal(double.parse('$prefix${_token.value}')); 296 var value = _astFactory.literal(double.parse('$prefix${_token.value}'));
299 _advance(); 297 _advance();
300 return value; 298 return value;
301 } 299 }
302 300
303 } 301 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer_expressions/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698