(stream, state)
| 42 | }, |
| 43 | |
| 44 | token(stream, state): string | null { |
| 45 | // Inside block comment |
| 46 | if (state.inBlockComment) { |
| 47 | while (!stream.eol()) { |
| 48 | if (stream.match(";)")) { |
| 49 | state.inBlockComment = false; |
| 50 | return "blockComment"; |
| 51 | } |
| 52 | stream.next(); |
| 53 | } |
| 54 | return "blockComment"; |
| 55 | } |
| 56 | |
| 57 | // Whitespace |
| 58 | if (stream.eatSpace()) return null; |
| 59 | |
| 60 | // Block comment start |
| 61 | if (stream.match("(;")) { |
| 62 | state.inBlockComment = true; |
| 63 | while (!stream.eol()) { |
| 64 | if (stream.match(";)")) { |
| 65 | state.inBlockComment = false; |
| 66 | return "blockComment"; |
| 67 | } |
| 68 | stream.next(); |
| 69 | } |
| 70 | return "blockComment"; |
| 71 | } |
| 72 | |
| 73 | // Line comment |
| 74 | if (stream.match(";;")) { |
| 75 | stream.skipToEnd(); |
| 76 | return "lineComment"; |
| 77 | } |
| 78 | |
| 79 | // String |
| 80 | if (stream.eat('"')) { |
| 81 | while (!stream.eol()) { |
| 82 | const ch = stream.next(); |
| 83 | if (ch === '"') break; |
| 84 | if (ch === "\\") stream.next(); // skip escaped char |
| 85 | } |
| 86 | return "string"; |
| 87 | } |
| 88 | |
| 89 | // Parentheses |
| 90 | if (stream.eat("(") || stream.eat(")")) { |
| 91 | return "paren"; |
| 92 | } |
| 93 | |
| 94 | // $ identifiers |
| 95 | if (stream.eat("$")) { |
| 96 | stream.eatWhile(/[\w.]/); |
| 97 | return "variableName.definition"; |
| 98 | } |
| 99 | |
| 100 | // Words (keywords, types, instructions) |
| 101 | if (stream.match(/^[a-zA-Z_][\w.]*/)) { |
nothing calls this directly
no outgoing calls
no test coverage detected