| 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 // TODO(jimhug): Error recovery needs major work! | 5 // TODO(jimhug): Error recovery needs major work! |
| 6 /** | 6 /** |
| 7 * A simple recursive descent parser for the dart language. | 7 * A simple recursive descent parser for the dart language. |
| 8 * | 8 * |
| 9 * This parser is designed to be more permissive than the official | 9 * This parser is designed to be more permissive than the official |
| 10 * Dart grammar. It is expected that many grammar errors would be | 10 * Dart grammar. It is expected that many grammar errors would be |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 startQuote = endQuote = text[0]; | 1087 startQuote = endQuote = text[0]; |
| 1088 } | 1088 } |
| 1089 text = text.substring(0, text.length-1) + endQuote; // fix trailing $ | 1089 text = text.substring(0, text.length-1) + endQuote; // fix trailing $ |
| 1090 } else { | 1090 } else { |
| 1091 text = startQuote + text.substring(0, text.length-1) + endQuote; | 1091 text = startQuote + text.substring(0, text.length-1) + endQuote; |
| 1092 } | 1092 } |
| 1093 lits.add(makeStringLiteral(text, token.span)); | 1093 lits.add(makeStringLiteral(text, token.span)); |
| 1094 if (_maybeEat(TokenKind.LBRACE)) { | 1094 if (_maybeEat(TokenKind.LBRACE)) { |
| 1095 lits.add(expression()); | 1095 lits.add(expression()); |
| 1096 _eat(TokenKind.RBRACE); | 1096 _eat(TokenKind.RBRACE); |
| 1097 } else if (_maybeEat(TokenKind.THIS)) { |
| 1098 lits.add(new ThisExpression(_previousToken.span)); |
| 1097 } else { | 1099 } else { |
| 1098 var id = identifier(); | 1100 var id = identifier(); |
| 1099 lits.add(new VarExpression(id, id.span)); | 1101 lits.add(new VarExpression(id, id.span)); |
| 1100 } | 1102 } |
| 1101 } | 1103 } |
| 1102 var tok = _next(); | 1104 var tok = _next(); |
| 1103 if (tok.kind != TokenKind.STRING) { | 1105 if (tok.kind != TokenKind.STRING) { |
| 1104 _errorExpected('interpolated string'); | 1106 _errorExpected('interpolated string'); |
| 1105 } | 1107 } |
| 1106 var text = startQuote + tok.text; | 1108 var text = startQuote + tok.text; |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 class IncompleteSourceException implements Exception { | 1679 class IncompleteSourceException implements Exception { |
| 1678 final Token token; | 1680 final Token token; |
| 1679 | 1681 |
| 1680 IncompleteSourceException(this.token); | 1682 IncompleteSourceException(this.token); |
| 1681 | 1683 |
| 1682 String toString() { | 1684 String toString() { |
| 1683 if (token.span == null) return 'Unexpected $token'; | 1685 if (token.span == null) return 'Unexpected $token'; |
| 1684 return token.span.toMessageString('Unexpected $token'); | 1686 return token.span.toMessageString('Unexpected $token'); |
| 1685 } | 1687 } |
| 1686 } | 1688 } |
| OLD | NEW |