/** * Token Types for MEL Lexer * Based on MEL SPEC v0.3.3 Section 3 */ import type { SourceLocation } from "./source-location.js"; /** * All token kinds in MEL */ export type TokenKind = "DOMAIN" | "STATE" | "COMPUTED" | "ACTION" | "EFFECT" | "WHEN" | "ONCE" | "PATCH" | "UNSET" | "MERGE" | "TRUE" | "FALSE" | "NULL" | "AS" | "AVAILABLE" | "DISPATCHABLE" | "FAIL" | "STOP" | "WITH" | "TYPE" | "IMPORT" | "FROM" | "EXPORT" | "PLUS" | "MINUS" | "STAR" | "SLASH" | "PERCENT" | "EQ_EQ" | "BANG_EQ" | "LT" | "LT_EQ" | "GT" | "GT_EQ" | "AMP_AMP" | "PIPE_PIPE" | "BANG" | "QUESTION_QUESTION" | "QUESTION" | "COLON" | "EQ" | "AT" | "LPAREN" | "RPAREN" | "LBRACE" | "RBRACE" | "LBRACKET" | "RBRACKET" | "COMMA" | "SEMICOLON" | "DOT" | "ELLIPSIS" | "PIPE" | "NUMBER" | "STRING" | "IDENTIFIER" | "SYSTEM_IDENT" | "ITEM" | "EOF" | "ERROR"; /** * A token produced by the lexer */ export interface Token { kind: TokenKind; /** The raw text of the token */ lexeme: string; /** Parsed value for literals */ value?: unknown; /** Location in source */ location: SourceLocation; } /** * Keywords lookup table */ export declare const KEYWORDS: Record; /** * Reserved keywords (JS keywords that are forbidden in MEL) */ export declare const RESERVED_KEYWORDS: Set; /** * Check if a token is a keyword */ export declare function isKeyword(lexeme: string): boolean; /** * Check if a token is a reserved word */ export declare function isReserved(lexeme: string): boolean; /** * Get keyword token kind, or undefined if not a keyword * Note: Uses Object.hasOwn to avoid prototype pollution (e.g., "toString") */ export declare function getKeywordKind(lexeme: string): TokenKind | undefined; /** * Create a token */ export declare function createToken(kind: TokenKind, lexeme: string, location: SourceLocation, value?: unknown): Token;