if (token == TokenNameAND) {
getNextToken();
}
- if (token == TokenNameIdentifier) {
- methodDecl.sourceStart = scanner.getCurrentTokenStartPosition();
- methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
+ methodDecl.sourceStart = scanner.getCurrentTokenStartPosition();
+ methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
+ if (Scanner.isIdentifierOrKeyword(token)) {
methodDecl.selector = scanner.getCurrentIdentifierSource();
+ if (token > TokenNameKEYWORD) {
+ reportSyntaxWarning("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].",
+ scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
+// throwSyntaxError("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].");
+ }
getNextToken();
if (token == TokenNameLPAREN) {
getNextToken();
getNextToken();
}
} else {
- if (token > TokenNameKEYWORD) {
- throwSyntaxError("Don't use keyword for function declaration [" + token + "].");
- }
+ methodDecl.selector = "<undefined>".toCharArray();
throwSyntaxError("Function name expected after keyword 'function'.");
}
}
public char[] getSource() {
return this.source;
}
+ public static boolean isIdentifierOrKeyword(int token) {
+ return (token == TokenNameIdentifier) || (token > TokenNameKEYWORD);
+ }
final char[] optimizedCurrentTokenSource1() {
//return always the same char[] build only once
//optimization at no speed cost of 99.5 % of the singleCharIdentifier