Skip to main content

AliasResolver

Trait AliasResolver 

Source
pub trait AliasResolver {
    // Required methods
    fn lookup_alias(&self, name: &str) -> Option<AliasInfo>;
    fn lookup_suffix_alias(&self, suffix: &str) -> Option<AliasInfo>;
    fn lookup_reswd(&self, name: &str) -> Option<LexTok>;
    fn mark_in_use(&mut self, name: &str, in_use: bool);
}
Expand description

Trait the lexer uses to look up aliases and reserved words during exalias. Implementors typically delegate to the executor’s alias/reswd hash tables. Defining the trait here keeps lexer.rs free of executor-specific types — same pattern zsh uses with the hashtable.h opaque-handle approach against aliastab/reswdtab/ sufaliastab.

Required Methods§

Source

fn lookup_alias(&self, name: &str) -> Option<AliasInfo>

Look up an alias by name. Returns None if not found, or the alias body + flags otherwise.

Source

fn lookup_suffix_alias(&self, suffix: &str) -> Option<AliasInfo>

Look up a suffix alias (e.g. .txt → less) by suffix only.

Source

fn lookup_reswd(&self, name: &str) -> Option<LexTok>

Resolve a reserved word. Returns the LexTok the word should promote to (e.g. “if” → IF), or None if not a reswd.

Source

fn mark_in_use(&mut self, name: &str, in_use: bool)

Mark an alias as in-use (recursion guard). Called when an alias is about to be expanded; the matching unmark happens when the alias text has been fully consumed by the lexer.

Implementors§