MCPcopy Index your code
hub / github.com/bazelbuild/bazel / tokenize

Method tokenize

src/main/java/net/starlark/java/syntax/Lexer.java:696–895  ·  view source on GitHub ↗

Scans for one token starting at the current position in the character buffer of file contents provided to the constructor. Updates the current token, and sets #pos to the next scanning position.

()

Source from the content-addressed store, hash-verified

694 * scanning position.
695 */
696 private void tokenize() {
697 if (checkIndentation) {
698 checkIndentation = false;
699 computeIndentation();
700 }
701
702 // Return saved indentation tokens.
703 if (dents != 0) {
704 if (dents < 0) {
705 dents++;
706 setToken(TokenKind.OUTDENT, pos - 1, pos);
707 } else {
708 dents--;
709 setToken(TokenKind.INDENT, pos - 1, pos);
710 }
711 return;
712 }
713
714 // TODO(adonovan): cleanup: replace break after setToken with return,
715 // and eliminate null-check of this.kind.
716 kind = null;
717 while (pos < buffer.length) {
718 if (tokenizeTwoChars()) {
719 pos += 2;
720 return;
721 }
722 char c = buffer[pos];
723 pos++;
724 switch (c) {
725 case '{':
726 setToken(TokenKind.LBRACE, pos - 1, pos);
727 openParenStackDepth++;
728 break;
729 case '}':
730 setToken(TokenKind.RBRACE, pos - 1, pos);
731 popParen();
732 break;
733 case '(':
734 setToken(TokenKind.LPAREN, pos - 1, pos);
735 openParenStackDepth++;
736 break;
737 case ')':
738 setToken(TokenKind.RPAREN, pos - 1, pos);
739 popParen();
740 break;
741 case '[':
742 setToken(TokenKind.LBRACKET, pos - 1, pos);
743 openParenStackDepth++;
744 break;
745 case ']':
746 setToken(TokenKind.RBRACKET, pos - 1, pos);
747 popParen();
748 break;
749 case '>':
750 if (peek(0) == '>' && peek(1) == '=') {
751 setToken(TokenKind.GREATER_GREATER_EQUALS, pos - 1, pos + 2);
752 pos += 2;
753 } else if (peek(0) == '>') {

Callers 1

nextTokenMethod · 0.95

Calls 15

computeIndentationMethod · 0.95
setTokenMethod · 0.95
tokenizeTwoCharsMethod · 0.95
popParenMethod · 0.95
peekMethod · 0.95
setValueMethod · 0.95
newlineMethod · 0.95
scanToNewlineMethod · 0.95
addCommentMethod · 0.95
hasDocCommentPrefixMethod · 0.95
docCommentsMethod · 0.95
stringLiteralMethod · 0.95

Tested by

no test coverage detected