@ordojs/core
Version:
Core compiler and runtime for OrdoJS framework
88 lines • 3.01 kB
TypeScript
/**
* @fileoverview OrdoJS Parser Fixes - Improvements for type safety and error handling
*/
import type { ASTNode, ComponentNode, ExpressionNode, HTMLElementNode, ReactiveVariableNode, SourcePosition, SourceRange, Token, TokenStream, TypeAnnotation } from '../types/index.js';
import { SyntaxError, TokenType } from '../types/index.js';
/**
* Improved parser error handling and type safety
*/
export declare class ParserErrorHandler {
/**
* Create a properly typed syntax error with improved suggestions
*/
static createError(message: string, expected: string[], actual: string, position: SourcePosition, filename?: string): SyntaxError;
/**
* Generate helpful suggestions based on error context
*/
private static generateSuggestions;
/**
* Validate component structure
*/
static validateComponentStructure(component: ComponentNode): SyntaxError[];
/**
* Validate HTML structure
*/
static validateHTMLStructure(element: HTMLElementNode): SyntaxError[];
}
/**
* Null/undefined safety utilities for parser
*/
export declare class ParserSafetyUtils {
/**
* Safely access token value with null checking
*/
static safeTokenValue(token: Token | null | undefined): string;
/**
* Safely create a source range with null checking
*/
static safeCreateRange(start: SourcePosition | null | undefined, end: SourcePosition | null | undefined): SourceRange;
/**
* Safely handle optional children
*/
static safeChildren(nodes: (ASTNode | null | undefined)[]): ASTNode[];
/**
* Safely handle optional expressions
*/
static safeExpression(expr: ExpressionNode | null | undefined): ExpressionNode;
/**
* Safely handle optional type annotations
*/
static safeTypeAnnotation(type: TypeAnnotation | null | undefined): TypeAnnotation;
}
/**
* Enhanced error recovery for parser
*/
export declare class ParserRecovery {
/**
* Synchronize parser state after error
* @param tokens Token stream
* @param synchronizationPoints Token types to synchronize on
*/
static synchronize(tokens: TokenStream, synchronizationPoints?: TokenType[]): void;
/**
* Attempt to recover from HTML parsing errors
*/
static recoverFromHTMLError(tokens: TokenStream, tagName: string): void;
/**
* Attempt to recover from block parsing errors
*/
static recoverFromBlockError(tokens: TokenStream): void;
}
/**
* Enhanced validation for parser
*/
export declare class ParserValidation {
/**
* Validate HTML element structure
*/
static validateHTMLElement(element: HTMLElementNode): SyntaxError[];
/**
* Validate directive usage
*/
static validateDirectives(element: HTMLElementNode): SyntaxError[];
/**
* Validate reactive variable declarations
*/
static validateReactiveVariables(variables: ReactiveVariableNode[]): SyntaxError[];
}
//# sourceMappingURL=parser-fixes.d.ts.map