| OLD | NEW |
| 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.tokenizer; | 5 library polymer_expressions.tokenizer; |
| 6 | 6 |
| 7 const int _TAB = 9; | 7 const int _TAB = 9; |
| 8 const int _LF = 10; | 8 const int _LF = 10; |
| 9 const int _VTAB = 11; | 9 const int _VTAB = 11; |
| 10 const int _FF = 12; | 10 const int _FF = 12; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool isQuote(int next) => next == _DQ || next == _SQ; | 125 bool isQuote(int next) => next == _DQ || next == _SQ; |
| 126 | 126 |
| 127 bool isNumber(int next) => _0 <= next && next <= _9; | 127 bool isNumber(int next) => _0 <= next && next <= _9; |
| 128 | 128 |
| 129 bool isOperator(int next) => _OPERATORS.contains(next); | 129 bool isOperator(int next) => _OPERATORS.contains(next); |
| 130 | 130 |
| 131 bool isGrouper(int next) => _GROUPERS.contains(next); | 131 bool isGrouper(int next) => _GROUPERS.contains(next); |
| 132 | 132 |
| 133 int escape(int c) { | 133 int escape(int c) { |
| 134 switch (c) { | 134 switch (c) { |
| 135 case _f: return _FF; break; | 135 case _f: return _FF; |
| 136 case _n: return _LF; break; | 136 case _n: return _LF; |
| 137 case _r: return _CR; break; | 137 case _r: return _CR; |
| 138 case _t: return _TAB; break; | 138 case _t: return _TAB; |
| 139 case _v: return _VTAB; break; | 139 case _v: return _VTAB; |
| 140 default: return c; | 140 default: return c; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 class Token { | 144 class Token { |
| 145 final int kind; | 145 final int kind; |
| 146 final String value; | 146 final String value; |
| 147 final int precedence; | 147 final int precedence; |
| 148 | 148 |
| 149 Token(this.kind, this.value, [this.precedence = 0]); | 149 Token(this.kind, this.value, [this.precedence = 0]); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 _tokens.add(new Token(GROUPER_TOKEN, value, _PRECEDENCE[value])); | 291 _tokens.add(new Token(GROUPER_TOKEN, value, _PRECEDENCE[value])); |
| 292 _advance(); | 292 _advance(); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 class ParseException implements Exception { | 296 class ParseException implements Exception { |
| 297 final String message; | 297 final String message; |
| 298 ParseException(this.message); | 298 ParseException(this.message); |
| 299 String toString() => "ParseException: $message"; | 299 String toString() => "ParseException: $message"; |
| 300 } | 300 } |
| OLD | NEW |