#[non_exhaustive]pub enum LexerError {
Show 15 variants
UnexpectedCharacter,
UnterminatedString,
UnterminatedVarRef,
InvalidEscape,
InvalidNumber,
InvalidFloatNoLeading,
InvalidFloatNoTrailing,
NestingTooDeep,
UnterminatedCommandSubst,
UnterminatedArithmetic,
UnterminatedHeredoc {
delimiter: String,
},
BackticksNotSupported,
ArithmeticInVarRef,
NonAsciiName {
kind: &'static str,
text: String,
},
HashInsideWord,
}Expand description
Lexer error types.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnexpectedCharacter
UnterminatedString
UnterminatedVarRef
InvalidEscape
InvalidNumber
InvalidFloatNoLeading
InvalidFloatNoTrailing
NestingTooDeep
Nesting depth exceeded (too many nested parentheses in arithmetic).
UnterminatedCommandSubst
A $( opened inside a double-quoted string and the input ended before
its ). Reported instead of UnterminatedString because the missing
) is the error and the unterminated string is only its consequence:
echo "pre $(echo hi" is a forgotten paren, not a forgotten quote.
UnterminatedArithmetic
Arithmetic expansion $(( reached end of input without a closing )).
Silently evaluating the partial expression would mask a typo ($(( 1 + 2
would compute 3), so we surface it loudly instead.
UnterminatedHeredoc
Heredoc body ended without seeing the closing delimiter on its own line. The user almost certainly meant to type the delimiter — silently using whatever was collected up to EOF would mask missing data.
BackticksNotSupported
Backtick command substitution. Kaish drops backticks intentionally —
they’re listed in docs/LANGUAGE.md and the help system as not supported.
We surface this as a dedicated error (rather than UnexpectedCharacter)
so the message can point users at the $(cmd) replacement.
ArithmeticInVarRef
$((expr)) inside a bare ${...} reference (e.g. ${X:-$((1+2))}).
There is no representation for arithmetic inside a variable
reference — the pre-#95 pipeline silently leaked internal marker
text here — so it is a loud error instead. (Inside double-quoted
strings the same construct works via string interpolation.)
NonAsciiName
A -flag/--flag/+flag word matched but contained a non-ASCII
character. Flag names are ASCII-only; see the note on Token.
kind is always "flag" — it stays a field because the message reads
off it, and a second ASCII-only name class would use the same shape.
text is the whole matched word (sigil included).
HashInsideWord
A # that is not at the start of a word — $x#3, "abc"#3, $(f)#3.
POSIX opens a comment only at a word start, and the word classes carry
# as an ordinary character, so a # that reaches this error follows
something that cannot absorb it. Commenting from here would drop the
rest of the line, ; separators and whole commands included, at exit 0.
Trait Implementations§
Source§impl Clone for LexerError
impl Clone for LexerError
Source§fn clone(&self) -> LexerError
fn clone(&self) -> LexerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LexerError
impl Debug for LexerError
Source§impl Default for LexerError
impl Default for LexerError
Source§fn default() -> LexerError
fn default() -> LexerError
Source§impl Display for LexerError
impl Display for LexerError
Source§impl PartialEq for LexerError
impl PartialEq for LexerError
impl StructuralPartialEq for LexerError
Auto Trait Implementations§
impl Freeze for LexerError
impl RefUnwindSafe for LexerError
impl Send for LexerError
impl Sync for LexerError
impl Unpin for LexerError
impl UnsafeUnpin for LexerError
impl UnwindSafe for LexerError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.