diff options
author | 2017-02-16 13:58:15 +0000 | |
---|---|---|
committer | 2017-02-16 16:56:55 +0000 | |
commit | 6279efd256dd853614097701ff145dff41ff430b (patch) | |
tree | 1444fd4733fd4373cddcfe3cd35446e234ce7145 /src/main/java/com/google/devtools | |
parent | 7f0cd62e3f7c896ace34997c330517e3c557ca64 (diff) |
Minor code cleanup
Inlining the function makes the code more readable.
--
PiperOrigin-RevId: 147711468
MOS_MIGRATED_REVID=147711468
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/Lexer.java | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java b/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java index 0ace1f2bcf..b5cbc92aef 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java @@ -535,9 +535,21 @@ public final class Lexer { keywordMap.put("yield", TokenKind.YIELD); } - private TokenKind getTokenKindForIdentfier(String id) { + /** + * Scans an identifier or keyword. + * + * <p>ON ENTRY: 'pos' is 1 + the index of the first char in the identifier. + * ON EXIT: 'pos' is 1 + the index of the last char in the identifier. + * + * @return the identifier or keyword token. + */ + private Token identifierOrKeyword() { + int oldPos = pos - 1; + String id = scanIdentifier(); TokenKind kind = keywordMap.get(id); - return kind == null ? TokenKind.IDENTIFIER : kind; + return (kind == null) + ? new Token(TokenKind.IDENTIFIER, oldPos, pos, id) + : new Token(kind, oldPos, pos, null); } private String scanIdentifier() { @@ -566,22 +578,6 @@ public final class Lexer { return bufferSlice(oldPos, pos); } - /** - * Scans an identifier or keyword. - * - * <p>ON ENTRY: 'pos' is 1 + the index of the first char in the identifier. - * ON EXIT: 'pos' is 1 + the index of the last char in the identifier. - * - * @return the identifier or keyword token. - */ - private Token identifierOrKeyword() { - int oldPos = pos - 1; - String id = scanIdentifier(); - TokenKind kind = getTokenKindForIdentfier(id); - return new Token(kind, oldPos, pos, - (kind == TokenKind.IDENTIFIER) ? id : null); - } - private String scanInteger() { int oldPos = pos - 1; while (pos < buffer.length) { |