pub struct Parser<'a> { /* private fields */ }Expand description
Recursive-descent parser for bash syntax. Produces an AST of Cmd nodes.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new(input: &'a str) -> Self
pub fn new(input: &'a str) -> Self
Create a parser for the given bash input.
§Examples
use reef::parser::Parser;
let parser = Parser::new("echo hello && echo world");
let cmds = parser.parse().unwrap();
assert_eq!(cmds.len(), 1); // one and-or listSourcepub fn parse(self) -> Result<Vec<Cmd<'a>>, ParseError>
pub fn parse(self) -> Result<Vec<Cmd<'a>>, ParseError>
Parse the input into a list of commands.
Returns a Vec<Cmd> representing the top-level command list. Each
command borrows from the input string — no copying occurs.
§Errors
Returns ParseError when the input contains invalid or unsupported
bash syntax — for example, unmatched delimiters, unexpected tokens,
or unterminated strings.
§Panics
Panics (via internal .expect()) if the parser’s own invariants are
violated — for example, consuming a single-element Vec that was
just checked to have exactly one item. These are logic errors, not
input-dependent, so well-formed callers will never trigger them.
§Examples
use reef::parser::Parser;
let cmds = Parser::new("echo hello").parse().unwrap();
assert_eq!(cmds.len(), 1);Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnsafeUnpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more