pub struct Parser<'a> { /* private fields */ }Expand description
Parser for bash scripts.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn parse(self) -> ParseResult
pub fn parse(self) -> ParseResult
Parse the input and return the AST, recovery diagnostics, and syntax facts.
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn with_dialect(input: &'a str, dialect: ShellDialect) -> Self
pub fn with_dialect(input: &'a str, dialect: ShellDialect) -> Self
Create a new parser for the given input and shell dialect.
Sourcepub fn with_profile(input: &'a str, shell_profile: ShellProfile) -> Self
pub fn with_profile(input: &'a str, shell_profile: ShellProfile) -> Self
Create a new parser for the given input and full shell profile.
Sourcepub fn with_max_depth(input: &'a str, max_depth: usize) -> Self
pub fn with_max_depth(input: &'a str, max_depth: usize) -> Self
Create a new parser with a custom maximum AST depth.
Sourcepub fn with_fuel(input: &'a str, max_fuel: usize) -> Self
pub fn with_fuel(input: &'a str, max_fuel: usize) -> Self
Create a new parser with a custom fuel limit.
Sourcepub fn with_limits(input: &'a str, max_depth: usize, max_fuel: usize) -> Self
pub fn with_limits(input: &'a str, max_depth: usize, max_fuel: usize) -> Self
Create a new parser with custom depth and fuel limits.
max_depth is clamped to HARD_MAX_AST_DEPTH (500)
to prevent stack overflow from misconfiguration. Even if the caller passes
max_depth = 1_000_000, the parser will cap it at 500.
Sourcepub fn with_limits_and_dialect(
input: &'a str,
max_depth: usize,
max_fuel: usize,
dialect: ShellDialect,
) -> Self
pub fn with_limits_and_dialect( input: &'a str, max_depth: usize, max_fuel: usize, dialect: ShellDialect, ) -> Self
Create a new parser with custom depth, fuel, and dialect settings.
Sourcepub fn with_limits_and_profile(
input: &'a str,
max_depth: usize,
max_fuel: usize,
shell_profile: ShellProfile,
) -> Self
pub fn with_limits_and_profile( input: &'a str, max_depth: usize, max_fuel: usize, shell_profile: ShellProfile, ) -> Self
Create a new parser with custom depth, fuel, and shell-profile settings.
Sourcepub fn dialect(&self) -> ShellDialect
pub fn dialect(&self) -> ShellDialect
Return the dialect associated with this parser.
Sourcepub fn shell_profile(&self) -> &ShellProfile
pub fn shell_profile(&self) -> &ShellProfile
Borrow the full shell profile associated with this parser.
Sourcepub fn current_span(&self) -> Span
pub fn current_span(&self) -> Span
Get the current token’s span.
Sourcepub fn parse_word_string(input: &str) -> Word
pub fn parse_word_string(input: &str) -> Word
Parse a string as a word (handling $var, $((expr)), ${…}, etc.). Used by the interpreter to expand operands in parameter expansions lazily.
Sourcepub fn parse_word_string_with_limits(
input: &str,
max_depth: usize,
max_fuel: usize,
) -> Word
pub fn parse_word_string_with_limits( input: &str, max_depth: usize, max_fuel: usize, ) -> Word
Parse a word string with caller-configured limits. Prevents bypass of parser limits in parameter expansion contexts.
Sourcepub fn parse_word_string_with_limits_and_dialect(
input: &str,
max_depth: usize,
max_fuel: usize,
dialect: ShellDialect,
) -> Word
pub fn parse_word_string_with_limits_and_dialect( input: &str, max_depth: usize, max_fuel: usize, dialect: ShellDialect, ) -> Word
Parse a word string with caller-configured limits and shell dialect.