mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
Change let
This commit is contained in:
parent
40543b501c
commit
7c2faaecb8
9 changed files with 200 additions and 100 deletions
18
src/lexer.ts
18
src/lexer.ts
|
|
@ -3,7 +3,6 @@ import { CompilerError, Span } from "./error";
|
|||
export type DatalessToken =
|
||||
| "function"
|
||||
| "let"
|
||||
| "in"
|
||||
| "if"
|
||||
| "then"
|
||||
| "else"
|
||||
|
|
@ -79,6 +78,14 @@ export function tokenize(input: string): Token[] {
|
|||
const next = input[i];
|
||||
const span: Span = { start: i, end: i + 1 };
|
||||
|
||||
if (next === "/" && input[i + 1] === "/") {
|
||||
while (input[i] !== "\n") {
|
||||
i++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SINGLE_PUNCT.includes(next)) {
|
||||
tokens.push({ kind: next as DatalessToken, span });
|
||||
} else {
|
||||
|
|
@ -207,15 +214,16 @@ function isWhitespace(char: string): boolean {
|
|||
return char === " " || char === "\t" || char === "\n" || char === "\r";
|
||||
}
|
||||
|
||||
const keywords = new Set<string>([
|
||||
const KEYOWRDS: DatalessToken[] = [
|
||||
"function",
|
||||
"let",
|
||||
"in",
|
||||
"if",
|
||||
"then",
|
||||
"else",
|
||||
"type",
|
||||
]);
|
||||
];
|
||||
|
||||
const KEYWORD_SET = new Set<string>(KEYOWRDS);
|
||||
function isKeyword(kw: string): DatalessToken | undefined {
|
||||
return keywords.has(kw) ? (kw as DatalessToken) : undefined;
|
||||
return KEYWORD_SET.has(kw) ? (kw as DatalessToken) : undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue