OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.parser; | 8 library engine.parser; |
9 | 9 |
10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); | 1690 reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); |
1691 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE
mpty) { | 1691 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE
mpty) { |
1692 // | 1692 // |
1693 // We appear to have found an incomplete declaration at the end of the c
lass. At this point | 1693 // We appear to have found an incomplete declaration at the end of the c
lass. At this point |
1694 // it consists of a metadata, which we don't want to loose, so we'll tre
at it as a method | 1694 // it consists of a metadata, which we don't want to loose, so we'll tre
at it as a method |
1695 // declaration with a missing name, parameters and empty body. | 1695 // declaration with a missing name, parameters and empty body. |
1696 // | 1696 // |
1697 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad
ata.metadata, null, null, null, null, null, createSyntheticIdentifier(), new For
malParameterList(null, new List<FormalParameter>(), null, null, null), new Empty
FunctionBody(createSyntheticToken(TokenType.SEMICOLON))); | 1697 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad
ata.metadata, null, null, null, null, null, createSyntheticIdentifier(), new For
malParameterList(null, new List<FormalParameter>(), null, null, null), new Empty
FunctionBody(createSyntheticToken(TokenType.SEMICOLON))); |
1698 } | 1698 } |
1699 return null; | 1699 return null; |
1700 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatchesIdentifier(
peek2(2)) && tokenMatches(peek2(3), TokenType.OPEN_PAREN)) { | 1700 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatchesIdentifier(
peekAt(2)) && tokenMatches(peekAt(3), TokenType.OPEN_PAREN)) { |
1701 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); | 1701 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); |
1702 } else if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 1702 } else if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { |
1703 SimpleIdentifier methodName = parseSimpleIdentifier(); | 1703 SimpleIdentifier methodName = parseSimpleIdentifier(); |
1704 FormalParameterList parameters = parseFormalParameterList(); | 1704 FormalParameterList parameters = parseFormalParameterList(); |
1705 if (matches(TokenType.COLON) || modifiers.factoryKeyword != null || method
Name.name == className) { | 1705 if (matches(TokenType.COLON) || modifiers.factoryKeyword != null || method
Name.name == className) { |
1706 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | 1706 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); |
1707 } | 1707 } |
1708 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1708 validateModifiersForGetterOrSetterOrMethod(modifiers); |
1709 validateFormalParameterList(parameters); | 1709 validateFormalParameterList(parameters); |
1710 return parseMethodDeclarationAfterParameters(commentAndMetadata, modifiers
.externalKeyword, modifiers.staticKeyword, null, methodName, parameters); | 1710 return parseMethodDeclarationAfterParameters(commentAndMetadata, modifiers
.externalKeyword, modifiers.staticKeyword, null, methodName, parameters); |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 | 2889 |
2890 /** | 2890 /** |
2891 * Return `true` if the current token is the first token of a return type that
is followed | 2891 * Return `true` if the current token is the first token of a return type that
is followed |
2892 * by an identifier, possibly followed by a list of type parameters, followed
by a | 2892 * by an identifier, possibly followed by a list of type parameters, followed
by a |
2893 * left-parenthesis. This is used by parseTypeAlias to determine whether or no
t to parse a return | 2893 * left-parenthesis. This is used by parseTypeAlias to determine whether or no
t to parse a return |
2894 * type. | 2894 * type. |
2895 * | 2895 * |
2896 * @return `true` if we can successfully parse the rest of a type alias if we
first parse a | 2896 * @return `true` if we can successfully parse the rest of a type alias if we
first parse a |
2897 * return type. | 2897 * return type. |
2898 */ | 2898 */ |
2899 bool hasReturnTypeInTypeAlias() { | 2899 bool get hasReturnTypeInTypeAlias { |
2900 Token next = skipReturnType(_currentToken); | 2900 Token next = skipReturnType(_currentToken); |
2901 if (next == null) { | 2901 if (next == null) { |
2902 return false; | 2902 return false; |
2903 } | 2903 } |
2904 return tokenMatchesIdentifier(next); | 2904 return tokenMatchesIdentifier(next); |
2905 } | 2905 } |
2906 | 2906 |
2907 /** | 2907 /** |
2908 * Inject the given token into the token stream immediately before the current
token. | 2908 * Inject the given token into the token stream immediately before the current
token. |
2909 * | 2909 * |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4068 Token separator = null; | 4068 Token separator = null; |
4069 List<ConstructorInitializer> initializers = null; | 4069 List<ConstructorInitializer> initializers = null; |
4070 if (matches(TokenType.COLON)) { | 4070 if (matches(TokenType.COLON)) { |
4071 separator = andAdvance; | 4071 separator = andAdvance; |
4072 initializers = new List<ConstructorInitializer>(); | 4072 initializers = new List<ConstructorInitializer>(); |
4073 do { | 4073 do { |
4074 if (matchesKeyword(Keyword.THIS)) { | 4074 if (matchesKeyword(Keyword.THIS)) { |
4075 if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 4075 if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { |
4076 bodyAllowed = false; | 4076 bodyAllowed = false; |
4077 initializers.add(parseRedirectingConstructorInvocation()); | 4077 initializers.add(parseRedirectingConstructorInvocation()); |
4078 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatches(peek
2(3), TokenType.OPEN_PAREN)) { | 4078 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatches(peek
At(3), TokenType.OPEN_PAREN)) { |
4079 bodyAllowed = false; | 4079 bodyAllowed = false; |
4080 initializers.add(parseRedirectingConstructorInvocation()); | 4080 initializers.add(parseRedirectingConstructorInvocation()); |
4081 } else { | 4081 } else { |
4082 initializers.add(parseConstructorFieldInitializer()); | 4082 initializers.add(parseConstructorFieldInitializer()); |
4083 } | 4083 } |
4084 } else if (matchesKeyword(Keyword.SUPER)) { | 4084 } else if (matchesKeyword(Keyword.SUPER)) { |
4085 initializers.add(parseSuperConstructorInvocation()); | 4085 initializers.add(parseSuperConstructorInvocation()); |
4086 } else { | 4086 } else { |
4087 initializers.add(parseConstructorFieldInitializer()); | 4087 initializers.add(parseConstructorFieldInitializer()); |
4088 } | 4088 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4235 commentTokens.add(commentToken); | 4235 commentTokens.add(commentToken); |
4236 } | 4236 } |
4237 } | 4237 } |
4238 commentToken = commentToken.next; | 4238 commentToken = commentToken.next; |
4239 } | 4239 } |
4240 if (commentTokens.isEmpty) { | 4240 if (commentTokens.isEmpty) { |
4241 return null; | 4241 return null; |
4242 } | 4242 } |
4243 List<Token> tokens = new List.from(commentTokens); | 4243 List<Token> tokens = new List.from(commentTokens); |
4244 List<CommentReference> references = parseCommentReferences(tokens); | 4244 List<CommentReference> references = parseCommentReferences(tokens); |
4245 return Comment.createDocumentationComment2(tokens, references); | 4245 return Comment.createDocumentationCommentWithReferences(tokens, references); |
4246 } | 4246 } |
4247 | 4247 |
4248 /** | 4248 /** |
4249 * Parse a do statement. | 4249 * Parse a do statement. |
4250 * | 4250 * |
4251 * <pre> | 4251 * <pre> |
4252 * doStatement ::= | 4252 * doStatement ::= |
4253 * 'do' statement 'while' '(' expression ')' ';' | 4253 * 'do' statement 'while' '(' expression ')' ';' |
4254 * </pre> | 4254 * </pre> |
4255 * | 4255 * |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 * functionPrefix ::= | 4689 * functionPrefix ::= |
4690 * returnType? name | 4690 * returnType? name |
4691 * </pre> | 4691 * </pre> |
4692 * | 4692 * |
4693 * @param commentAndMetadata the metadata to be associated with the member | 4693 * @param commentAndMetadata the metadata to be associated with the member |
4694 * @param keyword the token representing the 'typedef' keyword | 4694 * @param keyword the token representing the 'typedef' keyword |
4695 * @return the function type alias that was parsed | 4695 * @return the function type alias that was parsed |
4696 */ | 4696 */ |
4697 FunctionTypeAlias parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata
, Token keyword) { | 4697 FunctionTypeAlias parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata
, Token keyword) { |
4698 TypeName returnType = null; | 4698 TypeName returnType = null; |
4699 if (hasReturnTypeInTypeAlias()) { | 4699 if (hasReturnTypeInTypeAlias) { |
4700 returnType = parseReturnType(); | 4700 returnType = parseReturnType(); |
4701 } | 4701 } |
4702 SimpleIdentifier name = parseSimpleIdentifier(); | 4702 SimpleIdentifier name = parseSimpleIdentifier(); |
4703 TypeParameterList typeParameters = null; | 4703 TypeParameterList typeParameters = null; |
4704 if (matches(TokenType.LT)) { | 4704 if (matches(TokenType.LT)) { |
4705 typeParameters = parseTypeParameterList(); | 4705 typeParameters = parseTypeParameterList(); |
4706 } | 4706 } |
4707 if (matches(TokenType.SEMICOLON) || matches(TokenType.EOF)) { | 4707 if (matches(TokenType.SEMICOLON) || matches(TokenType.EOF)) { |
4708 reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, [])
; | 4708 reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, [])
; |
4709 FormalParameterList parameters = new FormalParameterList(createSyntheticTo
ken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken(TokenType.CLOS
E_PAREN)); | 4709 FormalParameterList parameters = new FormalParameterList(createSyntheticTo
ken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken(TokenType.CLOS
E_PAREN)); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5403 /** | 5403 /** |
5404 * Parse a return type if one is given, otherwise return `null` without advanc
ing. | 5404 * Parse a return type if one is given, otherwise return `null` without advanc
ing. |
5405 * | 5405 * |
5406 * @return the return type that was parsed | 5406 * @return the return type that was parsed |
5407 */ | 5407 */ |
5408 TypeName parseOptionalReturnType() { | 5408 TypeName parseOptionalReturnType() { |
5409 if (matchesKeyword(Keyword.VOID)) { | 5409 if (matchesKeyword(Keyword.VOID)) { |
5410 return parseReturnType(); | 5410 return parseReturnType(); |
5411 } else if (matchesIdentifier() && !matchesKeyword(Keyword.GET) && !matchesKe
yword(Keyword.SET) && !matchesKeyword(Keyword.OPERATOR) && (tokenMatchesIdentifi
er(peek()) || tokenMatches(peek(), TokenType.LT))) { | 5411 } else if (matchesIdentifier() && !matchesKeyword(Keyword.GET) && !matchesKe
yword(Keyword.SET) && !matchesKeyword(Keyword.OPERATOR) && (tokenMatchesIdentifi
er(peek()) || tokenMatches(peek(), TokenType.LT))) { |
5412 return parseReturnType(); | 5412 return parseReturnType(); |
5413 } else if (matchesIdentifier() && tokenMatches(peek(), TokenType.PERIOD) &&
tokenMatchesIdentifier(peek2(2)) && (tokenMatchesIdentifier(peek2(3)) || tokenMa
tches(peek2(3), TokenType.LT))) { | 5413 } else if (matchesIdentifier() && tokenMatches(peek(), TokenType.PERIOD) &&
tokenMatchesIdentifier(peekAt(2)) && (tokenMatchesIdentifier(peekAt(3)) || token
Matches(peekAt(3), TokenType.LT))) { |
5414 return parseReturnType(); | 5414 return parseReturnType(); |
5415 } | 5415 } |
5416 return null; | 5416 return null; |
5417 } | 5417 } |
5418 | 5418 |
5419 /** | 5419 /** |
5420 * Parse a part or part-of directive. | 5420 * Parse a part or part-of directive. |
5421 * | 5421 * |
5422 * <pre> | 5422 * <pre> |
5423 * partDirective ::= | 5423 * partDirective ::= |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 6272 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); |
6273 Statement body = parseStatement2(); | 6273 Statement body = parseStatement2(); |
6274 return new WhileStatement(keyword, leftParenthesis, condition, rightParent
hesis, body); | 6274 return new WhileStatement(keyword, leftParenthesis, condition, rightParent
hesis, body); |
6275 } finally { | 6275 } finally { |
6276 _inLoop = wasInLoop; | 6276 _inLoop = wasInLoop; |
6277 } | 6277 } |
6278 } | 6278 } |
6279 | 6279 |
6280 /** | 6280 /** |
6281 * Return the token that is immediately after the current token. This is equiv
alent to | 6281 * Return the token that is immediately after the current token. This is equiv
alent to |
6282 * [peek]. | 6282 * [peekAt]. |
6283 * | 6283 * |
6284 * @return the token that is immediately after the current token | 6284 * @return the token that is immediately after the current token |
6285 */ | 6285 */ |
6286 Token peek() => _currentToken.next; | 6286 Token peek() => _currentToken.next; |
6287 | 6287 |
6288 /** | 6288 /** |
6289 * Return the token that is the given distance after the current token. | 6289 * Return the token that is the given distance after the current token. |
6290 * | 6290 * |
6291 * @param distance the number of tokens to look ahead, where `0` is the curren
t token, | 6291 * @param distance the number of tokens to look ahead, where `0` is the curren
t token, |
6292 * `1` is the next token, etc. | 6292 * `1` is the next token, etc. |
6293 * @return the token that is the given distance after the current token | 6293 * @return the token that is the given distance after the current token |
6294 */ | 6294 */ |
6295 Token peek2(int distance) { | 6295 Token peekAt(int distance) { |
6296 Token token = _currentToken; | 6296 Token token = _currentToken; |
6297 for (int i = 0; i < distance; i++) { | 6297 for (int i = 0; i < distance; i++) { |
6298 token = token.next; | 6298 token = token.next; |
6299 } | 6299 } |
6300 return token; | 6300 return token; |
6301 } | 6301 } |
6302 | 6302 |
6303 /** | 6303 /** |
6304 * Report the given [AnalysisError]. | 6304 * Report the given [AnalysisError]. |
6305 * | 6305 * |
(...skipping 3321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9627 * @param suffix the suffix to be printed if there is a node to visit | 9627 * @param suffix the suffix to be printed if there is a node to visit |
9628 * @param node the node to be visited | 9628 * @param node the node to be visited |
9629 */ | 9629 */ |
9630 void visitTokenWithSuffix(Token token, String suffix) { | 9630 void visitTokenWithSuffix(Token token, String suffix) { |
9631 if (token != null) { | 9631 if (token != null) { |
9632 _writer.print(token.lexeme); | 9632 _writer.print(token.lexeme); |
9633 _writer.print(suffix); | 9633 _writer.print(suffix); |
9634 } | 9634 } |
9635 } | 9635 } |
9636 } | 9636 } |
OLD | NEW |