use thiserror::Error;

#[derive(Debug, Clone, PartialEq, Error)]
pub enum ParseError {
    #[error("invalid bang suffix at position {position}: {token:?} (use ! / !! / !!! as a trailing suffix, not a standalone token)")]
    InvalidBang { token: String, position: usize },

    #[error("digits not allowed in command name at position {position}: {token:?} (only /test-family commands may contain digits)")]
    InvalidDigits { token: String, position: usize },

    #[error("missing operator at position {position}: {token:?} (two commands in sequence require | / |& / && / ||)")]
    MissingOperator { token: String, position: usize },

    #[error("invalid redirection at position {position}: {token:?}")]
    InvalidRedirection { token: String, position: usize },

    /// Malformed builder-chain syntax (e.g. unmatched parentheses).
    #[error("malformed builder chain at position {position}: {token:?} (check for unmatched parentheses)")]
    MalformedChain { token: String, position: usize },

    /// Invalid suffix combination (e.g. `??`).
    #[error("invalid suffix at position {position}: {token:?} (double ?? is not allowed)")]
    InvalidSuffix { token: String, position: usize },
}
