/** * Token Definitions for the Bash Lexer * * Contains all type definitions, enums, constants, and utility functions * used by the lexer's tokenization logic. */ export declare const DEFAULT_MAX_HEREDOC_SIZE = 10485760; export interface LexerOptions { /** Maximum heredoc size in bytes (default: 10MB) */ maxHeredocSize?: number; } export declare enum TokenType { EOF = "EOF", NEWLINE = "NEWLINE", SEMICOLON = "SEMICOLON", AMP = "AMP",// & PIPE = "PIPE",// | PIPE_AMP = "PIPE_AMP",// |& AND_AND = "AND_AND",// && OR_OR = "OR_OR",// || BANG = "BANG",// ! LESS = "LESS",// < GREAT = "GREAT",// > DLESS = "DLESS",// << DGREAT = "DGREAT",// >> LESSAND = "LESSAND",// <& GREATAND = "GREATAND",// >& LESSGREAT = "LESSGREAT",// <> DLESSDASH = "DLESSDASH",// <<- CLOBBER = "CLOBBER",// >| TLESS = "TLESS",// <<< AND_GREAT = "AND_GREAT",// &> AND_DGREAT = "AND_DGREAT",// &>> LPAREN = "LPAREN",// ( RPAREN = "RPAREN",// ) LBRACE = "LBRACE",// { RBRACE = "RBRACE",// } DSEMI = "DSEMI",// ;; SEMI_AND = "SEMI_AND",// ;& SEMI_SEMI_AND = "SEMI_SEMI_AND",// ;;& DBRACK_START = "DBRACK_START",// [[ DBRACK_END = "DBRACK_END",// ]] DPAREN_START = "DPAREN_START",// (( DPAREN_END = "DPAREN_END",// )) IF = "IF", THEN = "THEN", ELSE = "ELSE", ELIF = "ELIF", FI = "FI", FOR = "FOR", WHILE = "WHILE", UNTIL = "UNTIL", DO = "DO", DONE = "DONE", CASE = "CASE", ESAC = "ESAC", IN = "IN", FUNCTION = "FUNCTION", SELECT = "SELECT", TIME = "TIME", COPROC = "COPROC", WORD = "WORD", NAME = "NAME",// Valid variable name NUMBER = "NUMBER",// For redirections like 2>&1 ASSIGNMENT_WORD = "ASSIGNMENT_WORD",// VAR=value FD_VARIABLE = "FD_VARIABLE",// {varname} before redirect operator COMMENT = "COMMENT", HEREDOC_CONTENT = "HEREDOC_CONTENT" } export interface Token { type: TokenType; value: string; /** Original position in input */ start: number; end: number; line: number; column: number; /** For WORD tokens: quote information */ quoted?: boolean; singleQuoted?: boolean; } /** * Error thrown when the lexer encounters invalid input */ export declare class LexerError extends Error { line: number; column: number; constructor(message: string, line: number, column: number); } /** * Reserved words in bash * Using Map to prevent prototype pollution (e.g., "constructor", "__proto__") */ export declare const RESERVED_WORDS: Map; /** * Check if a string is a valid assignment LHS with optional nested array subscript * Handles: VAR, a[0], a[x], a[a[0]], a[x+1], etc. */ export declare function isValidAssignmentLHS(str: string): boolean; /** * Find the index of assignment '=' or '+=' outside of brackets. * Returns the index of '=' (or '=' after '+') or -1 if not found. * For 'a[x=1]=value', returns the index of the second '='. */ export declare function findAssignmentEq(str: string): number; /** * Three-character operators (simple ones without special handling) */ export declare const THREE_CHAR_OPS: Array<[string, string, string, TokenType]>; /** * Two-character operators (simple ones without special handling) * Note: << has special handling for heredoc, not included here */ export declare const TWO_CHAR_OPS: Array<[string, string, TokenType]>; /** * Single-character operators (simple ones without special handling) * Note: {, }, ! have special handling, not included here */ export declare const SINGLE_CHAR_OPS: Map; /** * Check if a string is a valid variable name */ export declare function isValidName(s: string): boolean; /** * Check if a character is a word boundary (ends a word token) */ export declare function isWordBoundary(char: string): boolean;