MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / scan

Method scan

src/main/java/wyc/io/WhileyFileLexer.java:62–87  ·  view source on GitHub ↗

Scan all characters from the input stream and generate a corresponding list of tokens, whilst discarding all whitespace and comments. @return

()

Source from the content-addressed store, hash-verified

60 * @return
61 */
62 public List<Token> scan() {
63 ArrayList<Token> tokens = new ArrayList<>();
64 pos = 0;
65
66 while (pos < input.length()) {
67 char c = input.charAt(pos);
68
69 if (isDigit(c)) {
70 tokens.add(scanNumericLiteral());
71 } else if (c == '"') {
72 tokens.add(scanStringLiteral());
73 } else if (c == '\'') {
74 tokens.add(scanCharacterLiteral());
75 } else if (isOperatorStart(c)) {
76 tokens.add(scanOperator());
77 } else if (isLetter(c) || c == '_') {
78 tokens.add(scanIdentifier());
79 } else if (Character.isWhitespace(c)) {
80 scanWhiteSpace(tokens);
81 } else {
82 tokens.add(new Token(Token.Kind.Unknown, "" + c, pos++));
83 }
84 }
85
86 return tokens;
87 }
88
89 /**
90 * Scan a numeric constant. That is a sequence of digits which constitutes an

Callers 1

WhileyFileMethod · 0.80

Calls 11

isDigitMethod · 0.95
scanNumericLiteralMethod · 0.95
scanStringLiteralMethod · 0.95
scanCharacterLiteralMethod · 0.95
isOperatorStartMethod · 0.95
scanOperatorMethod · 0.95
isLetterMethod · 0.95
scanIdentifierMethod · 0.95
scanWhiteSpaceMethod · 0.95
lengthMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected