| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An event generating parser of Dart programs. This parser expects | 8 * An event generating parser of Dart programs. This parser expects |
| 9 * all tokens in a linked list (aka a token stream). | 9 * all tokens in a linked list (aka a token stream). |
| 10 * | 10 * |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 return token; | 45 return token; |
| 46 } | 46 } |
| 47 | 47 |
| 48 Token parseTopLevelDeclaration(Token token) { | 48 Token parseTopLevelDeclaration(Token token) { |
| 49 token = parseMetadataStar(token); | 49 token = parseMetadataStar(token); |
| 50 final String value = token.stringValue; | 50 final String value = token.stringValue; |
| 51 if ((identical(value, 'abstract')) || (identical(value, 'class'))) { | 51 if ((identical(value, 'abstract')) || (identical(value, 'class'))) { |
| 52 return parseClass(token); | 52 return parseClass(token); |
| 53 } else if (identical(value, 'typedef')) { | 53 } else if (identical(value, 'typedef')) { |
| 54 return parseTypedef(token); | 54 return parseTypedef(token); |
| 55 } else if (identical(value, '#')) { | |
| 56 return parseScriptTags(token); | |
| 57 } else if (identical(value, 'library')) { | 55 } else if (identical(value, 'library')) { |
| 58 return parseLibraryName(token); | 56 return parseLibraryName(token); |
| 59 } else if (identical(value, 'import')) { | 57 } else if (identical(value, 'import')) { |
| 60 return parseImport(token); | 58 return parseImport(token); |
| 61 } else if (identical(value, 'export')) { | 59 } else if (identical(value, 'export')) { |
| 62 return parseExport(token); | 60 return parseExport(token); |
| 63 } else if (identical(value, 'part')) { | 61 } else if (identical(value, 'part')) { |
| 64 return parsePartOrPartOf(token); | 62 return parsePartOrPartOf(token); |
| 65 } else { | 63 } else { |
| 66 return parseTopLevelMember(token); | 64 return parseTopLevelMember(token); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 mayParseFunctionExpressions = false; | 738 mayParseFunctionExpressions = false; |
| 741 do { | 739 do { |
| 742 token = parseExpression(token.next); | 740 token = parseExpression(token.next); |
| 743 ++count; | 741 ++count; |
| 744 } while (optional(',', token)); | 742 } while (optional(',', token)); |
| 745 mayParseFunctionExpressions = old; | 743 mayParseFunctionExpressions = old; |
| 746 listener.endInitializers(count, begin, token); | 744 listener.endInitializers(count, begin, token); |
| 747 return token; | 745 return token; |
| 748 } | 746 } |
| 749 | 747 |
| 750 Token parseScriptTags(Token token) { | |
| 751 Token begin = token; | |
| 752 listener.beginScriptTag(token); | |
| 753 token = parseIdentifier(token.next); | |
| 754 token = expect('(', token); | |
| 755 token = parseLiteralStringOrRecoverExpression(token); | |
| 756 bool hasPrefix = false; | |
| 757 if (optional(',', token)) { | |
| 758 hasPrefix = true; | |
| 759 token = parseIdentifier(token.next); | |
| 760 token = expect(':', token); | |
| 761 token = parseLiteralStringOrRecoverExpression(token); | |
| 762 } | |
| 763 token = expect(')', token); | |
| 764 listener.endScriptTag(hasPrefix, begin, token); | |
| 765 return expectSemicolon(token); | |
| 766 } | |
| 767 | |
| 768 Token parseLiteralStringOrRecoverExpression(Token token) { | 748 Token parseLiteralStringOrRecoverExpression(Token token) { |
| 769 if (identical(token.kind, STRING_TOKEN)) { | 749 if (identical(token.kind, STRING_TOKEN)) { |
| 770 return parseLiteralString(token); | 750 return parseLiteralString(token); |
| 771 } else { | 751 } else { |
| 772 listener.recoverableError("unexpected", token: token); | 752 listener.recoverableError("unexpected", token: token); |
| 773 return parseExpression(token); | 753 return parseExpression(token); |
| 774 } | 754 } |
| 775 } | 755 } |
| 776 | 756 |
| 777 Token expectSemicolon(Token token) { | 757 Token expectSemicolon(Token token) { |
| (...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 } | 2167 } |
| 2188 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2168 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2189 return expectSemicolon(token); | 2169 return expectSemicolon(token); |
| 2190 } | 2170 } |
| 2191 | 2171 |
| 2192 Token parseEmptyStatement(Token token) { | 2172 Token parseEmptyStatement(Token token) { |
| 2193 listener.handleEmptyStatement(token); | 2173 listener.handleEmptyStatement(token); |
| 2194 return expectSemicolon(token); | 2174 return expectSemicolon(token); |
| 2195 } | 2175 } |
| 2196 } | 2176 } |
| OLD | NEW |