| 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 // Utilities for building JS ASTs at runtime. Contains a builder class | 5 // Utilities for building JS ASTs at runtime. Contains a builder class |
| 6 // and a parser that parses part of the language. | 6 // and a parser that parses part of the language. |
| 7 | 7 |
| 8 part of js; | 8 part of js; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 return parseObjectInitializer(); | 672 return parseObjectInitializer(); |
| 673 } else if (acceptCategory(LSQUARE)) { | 673 } else if (acceptCategory(LSQUARE)) { |
| 674 var values = <ArrayElement>[]; | 674 var values = <ArrayElement>[]; |
| 675 if (!acceptCategory(RSQUARE)) { | 675 if (!acceptCategory(RSQUARE)) { |
| 676 do { | 676 do { |
| 677 values.add(new ArrayElement(values.length, parseAssignment())); | 677 values.add(new ArrayElement(values.length, parseAssignment())); |
| 678 } while (acceptCategory(COMMA)); | 678 } while (acceptCategory(COMMA)); |
| 679 expectCategory(RSQUARE); | 679 expectCategory(RSQUARE); |
| 680 } | 680 } |
| 681 return new ArrayInitializer(values.length, values); | 681 return new ArrayInitializer(values.length, values); |
| 682 } else if (last.startsWith("/")) { | 682 } else if (last != null && last.startsWith("/")) { |
| 683 String regexp = getDelimited(lastPosition); | 683 String regexp = getDelimited(lastPosition); |
| 684 getToken(); | 684 getToken(); |
| 685 String flags = lastToken; | 685 String flags = lastToken; |
| 686 if (!acceptCategory(ALPHA)) flags = ""; | 686 if (!acceptCategory(ALPHA)) flags = ""; |
| 687 Expression expression = new RegExpLiteral(regexp + flags); | 687 Expression expression = new RegExpLiteral(regexp + flags); |
| 688 return expression; | 688 return expression; |
| 689 } else if (acceptCategory(HASH)) { | 689 } else if (acceptCategory(HASH)) { |
| 690 InterpolatedExpression expression = | 690 InterpolatedExpression expression = |
| 691 new InterpolatedExpression(interpolatedValues.length); | 691 new InterpolatedExpression(interpolatedValues.length); |
| 692 interpolatedValues.add(expression); | 692 interpolatedValues.add(expression); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 Catch parseCatch() { | 1172 Catch parseCatch() { |
| 1173 expectCategory(LPAREN); | 1173 expectCategory(LPAREN); |
| 1174 String identifier = lastToken; | 1174 String identifier = lastToken; |
| 1175 expectCategory(ALPHA); | 1175 expectCategory(ALPHA); |
| 1176 expectCategory(RPAREN); | 1176 expectCategory(RPAREN); |
| 1177 expectCategory(LBRACE); | 1177 expectCategory(LBRACE); |
| 1178 Block body = parseBlock(); | 1178 Block body = parseBlock(); |
| 1179 return new Catch(new VariableDeclaration(identifier), body); | 1179 return new Catch(new VariableDeclaration(identifier), body); |
| 1180 } | 1180 } |
| 1181 } | 1181 } |
| OLD | NEW |