Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 return nextChar == '['; 1927 return nextChar == '[';
1928 } 1928 }
1929 1929
1930 /** 1930 /**
1931 * Return {@code true} if the given token appears to be the beginning of an op erator declaration. 1931 * Return {@code true} if the given token appears to be the beginning of an op erator declaration.
1932 * 1932 *
1933 * @param startToken the token that might be the start of an operator declarat ion 1933 * @param startToken the token that might be the start of an operator declarat ion
1934 * @return {@code true} if the given token appears to be the beginning of an o perator declaration 1934 * @return {@code true} if the given token appears to be the beginning of an o perator declaration
1935 */ 1935 */
1936 private boolean isOperator(Token startToken) { 1936 private boolean isOperator(Token startToken) {
1937 if (startToken.isOperator()) { 1937 // Accept any operator here, even if it is not user definable.
1938 Token token = startToken.getNext(); 1938 if (!startToken.isOperator()) {
1939 while (token.isOperator()) { 1939 return false;
1940 token = token.getNext();
1941 }
1942 return matches(token, TokenType.OPEN_PAREN);
1943 } 1940 }
1944 return false; 1941 // Token "=" means that it is actually field initializer.
1942 if (startToken.getType() == TokenType.EQ) {
1943 return false;
1944 }
1945 // Consume all operator tokens.
1946 Token token = startToken.getNext();
1947 while (token.isOperator()) {
1948 token = token.getNext();
1949 }
1950 // Formal parameter list is expect now.
1951 return matches(token, TokenType.OPEN_PAREN);
1945 } 1952 }
1946 1953
1947 /** 1954 /**
1948 * Return {@code true} if the current token appears to be the beginning of a s witch member. 1955 * Return {@code true} if the current token appears to be the beginning of a s witch member.
1949 * 1956 *
1950 * @return {@code true} if the current token appears to be the beginning of a switch member 1957 * @return {@code true} if the current token appears to be the beginning of a switch member
1951 */ 1958 */
1952 private boolean isSwitchMember() { 1959 private boolean isSwitchMember() {
1953 Token token = currentToken; 1960 Token token = currentToken;
1954 while (matches(token, TokenType.IDENTIFIER) && matches(token.getNext(), Toke nType.COLON)) { 1961 while (matches(token, TokenType.IDENTIFIER) && matches(token.getNext(), Toke nType.COLON)) {
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after
5685 * | 'var' 5692 * | 'var'
5686 * | type 5693 * | type
5687 * </pre> 5694 * </pre>
5688 * 5695 *
5689 * @param startToken the token at which parsing is to begin 5696 * @param startToken the token at which parsing is to begin
5690 * @return the token following the type that was parsed 5697 * @return the token following the type that was parsed
5691 */ 5698 */
5692 private Token skipFinalConstVarOrType(Token startToken) { 5699 private Token skipFinalConstVarOrType(Token startToken) {
5693 if (matches(startToken, Keyword.FINAL) || matches(startToken, Keyword.CONST) ) { 5700 if (matches(startToken, Keyword.FINAL) || matches(startToken, Keyword.CONST) ) {
5694 Token next = startToken.getNext(); 5701 Token next = startToken.getNext();
5695 if (matchesIdentifier(next.getNext()) || matches(next.getNext(), TokenType .LT) 5702 if (matchesIdentifier(next)) {
5696 || matches(next.getNext(), Keyword.THIS)) { 5703 Token next2 = next.getNext();
5697 return skipTypeName(next); 5704 // "Type parameter" or "Type<" or "prefix.Type"
5705 if (matchesIdentifier(next2) || matches(next2, TokenType.LT)
5706 || matches(next2, TokenType.PERIOD)) {
5707 return skipTypeName(next);
5708 }
5709 // "parameter"
5710 return next;
5698 } 5711 }
5699 } else if (matches(startToken, Keyword.VAR)) { 5712 } else if (matches(startToken, Keyword.VAR)) {
5700 return startToken.getNext(); 5713 return startToken.getNext();
5701 } else if (matchesIdentifier(startToken)) { 5714 } else if (matchesIdentifier(startToken)) {
5702 Token next = startToken.getNext(); 5715 Token next = startToken.getNext();
5703 if (matchesIdentifier(next) 5716 if (matchesIdentifier(next)
5704 || matches(next, TokenType.LT) 5717 || matches(next, TokenType.LT)
5705 || matches(next, Keyword.THIS) 5718 || matches(next, Keyword.THIS)
5706 || (matches(next, TokenType.PERIOD) && matchesIdentifier(next.getNext( )) && (matchesIdentifier(next.getNext().getNext()) 5719 || (matches(next, TokenType.PERIOD) && matchesIdentifier(next.getNext( )) && (matchesIdentifier(next.getNext().getNext())
5707 || matches(next.getNext().getNext(), TokenType.LT) || matches( 5720 || matches(next.getNext().getNext(), TokenType.LT) || matches(
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
6516 reportError(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.getExternalKeyword ()); 6529 reportError(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.getExternalKeyword ());
6517 } 6530 }
6518 if (modifiers.getFinalKeyword() != null) { 6531 if (modifiers.getFinalKeyword() != null) {
6519 reportError(ParserErrorCode.FINAL_TYPEDEF, modifiers.getFinalKeyword()); 6532 reportError(ParserErrorCode.FINAL_TYPEDEF, modifiers.getFinalKeyword());
6520 } 6533 }
6521 if (modifiers.getVarKeyword() != null) { 6534 if (modifiers.getVarKeyword() != null) {
6522 reportError(ParserErrorCode.VAR_TYPEDEF, modifiers.getVarKeyword()); 6535 reportError(ParserErrorCode.VAR_TYPEDEF, modifiers.getVarKeyword());
6523 } 6536 }
6524 } 6537 }
6525 } 6538 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698