UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

109 lines 3 kB
/** * @fileoverview OrdoJS Lexer - Refactored modular implementation * @author OrdoJS Framework Team */ import { LexicalContext, LexicalError, TokenType, type Token, type TokenStream } from '../types/index.js'; /** * Lexer configuration options */ export interface LexerOptions { /** Enable source map generation */ generateSourceMaps?: boolean; /** Enable error recovery mode */ enableRecovery?: boolean; /** Maximum number of errors before stopping */ maxErrors?: number; /** Enable context-aware tokenization */ contextAware?: boolean; /** Custom token processors */ tokenProcessors?: TokenProcessor[]; } /** * Token processor interface for plugin-based token processing */ export interface TokenProcessor { /** Processor name */ name: string; /** Token types this processor handles */ handles: TokenType[]; /** Process token and return modified token or null to skip */ process(token: Token, context: LexicalContext): Token | null; } /** * Lexer state for error recovery and debugging */ export interface LexerState { source: string; current: number; line: number; column: number; filename: string; contextStack: LexicalContext[]; errors: LexicalError[]; } /** * Enhanced OrdoJS Lexer with modular architecture */ export declare class OrdoJSLexer { private state; private options; private contextManager; private tokens; constructor(options?: LexerOptions); /** * Tokenize source code into token stream */ tokenize(source: string, filename?: string): TokenStream; /** * Get lexer state for debugging */ getState(): Readonly<LexerState>; /** * Get all errors encountered during tokenization */ getErrors(): LexicalError[]; /** * Add custom token processor */ addTokenProcessor(processor: TokenProcessor): void; /** * Remove token processor by name */ removeTokenProcessor(name: string): boolean; private createInitialState; private initializeState; private scanToken; private handleBrace; private handleOperators; private handleComments; private scanSingleLineComment; private scanMultiLineComment; private scanString; private scanEscapeSequence; private scanHexEscape; private scanUnicodeEscape; private scanNumber; private scanDecimalNumber; private scanHexNumber; private scanBinaryNumber; private scanOctalNumber; private scanIdentifier; private scanHTMLTag; private handleUnexpectedCharacter; private processTokens; private createTokenStream; private createEOFToken; private match; private advance; private peek; private peekNext; private isAtEnd; private addToken; private getPosition; private throwError; } /** * Default token processors */ export declare const defaultTokenProcessors: TokenProcessor[]; //# sourceMappingURL=lexer-refactored.d.ts.map