mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 17:05:03 +01:00
parse more stuff
This commit is contained in:
parent
4e95bc05a3
commit
cc2a9aeca8
5 changed files with 206 additions and 40 deletions
18
src/lexer.ts
18
src/lexer.ts
|
|
@ -4,9 +4,15 @@ export type DatalessToken =
|
|||
| "function"
|
||||
| "let"
|
||||
| "in"
|
||||
| "if"
|
||||
| "then"
|
||||
| "else"
|
||||
| "("
|
||||
| ")"
|
||||
| "["
|
||||
| "]"
|
||||
| ";"
|
||||
| ":"
|
||||
| ","
|
||||
| "="
|
||||
| "+"
|
||||
|
|
@ -47,7 +53,10 @@ export type BaseToken = { kind: Token["kind"] };
|
|||
const SINGLE_PUNCT: string[] = [
|
||||
"(",
|
||||
")",
|
||||
"[",
|
||||
"]",
|
||||
";",
|
||||
":",
|
||||
",",
|
||||
"+",
|
||||
"-",
|
||||
|
|
@ -193,7 +202,14 @@ function isWhitespace(char: string): boolean {
|
|||
return char === " " || char === "\t" || char === "\n" || char === "\r";
|
||||
}
|
||||
|
||||
const keywords = new Set<string>(["function", "let", "in"]);
|
||||
const keywords = new Set<string>([
|
||||
"function",
|
||||
"let",
|
||||
"in",
|
||||
"if",
|
||||
"then",
|
||||
"else",
|
||||
]);
|
||||
function isKeyword(kw: string): DatalessToken | undefined {
|
||||
return keywords.has(kw) ? (kw as DatalessToken) : undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue