diff --git a/src/lexer/highlighter.ts b/src/lexer/highlighter.ts index 8f5f91d..efcdba7 100644 --- a/src/lexer/highlighter.ts +++ b/src/lexer/highlighter.ts @@ -5,7 +5,7 @@ import type { LexError, SyntaxError, Token, TokenizeResult, TokenType } from "./ const error_classes = "underline underline-offset-4 decoration-wavy decoration-red-500"; -export async function native_highlighter(code: string, level = HighlightLevel.Lexic): Promise<[string, string, string | null]> { +export async function native_highlighter(code: string, level = HighlightLevel.Syntactic): Promise<[string, string, string | null]> { let formatted_code = leftTrimDedent(code).join("\n"); try { @@ -193,7 +193,7 @@ function process_token_value_and_end(value: string, token_type: TokenType, first function translate_token_type(tt: TokenType, value: string): string { const keywords = ["throws", "extends", "constructor", "case", "static", "const", "enum", "union", "loop", "use", "break", "catch", "continue", "as", "do", - "else", "finally", "for", "fun", "if", "in", "fn", "nil", "return", "throw", + "finally", "for", "fun", "in", "fn", "nil", "return", "throw", "try", "while", "type", "match", "with", "of", "abstract", "class", "interface", "private", "protected", "pub", "override", "open", "init", "val", "var", "mut", "clone"]; @@ -220,6 +220,8 @@ function translate_token_type(tt: TokenType, value: string): string { case "VAL": case "VAR": case "FUN": + case "IF": + case "ELSE": return "keyword"; default: return tt; diff --git a/src/lexer/types.ts b/src/lexer/types.ts index d4cb53f..7837b5c 100644 --- a/src/lexer/types.ts +++ b/src/lexer/types.ts @@ -32,7 +32,9 @@ export type TokenType = "VAL" | "VAR" | "EOF" | - "FUN"; + "FUN" | + "IF" | + "ELSE"; export interface Err { Lex?: LexError @@ -72,4 +74,4 @@ export enum HighlightLevel { Lexic = 0, Syntactic = 1, Semantic = 2, -} \ No newline at end of file +}