pub enum TokenCategory {
Keyword,
Operator,
String,
Number,
Variable,
Comment,
Punctuation,
Command,
Path,
Flag,
Error,
}Expand description
Semantic category for syntax highlighting.
Stable enum that groups tokens by purpose. Consumers match on categories instead of individual tokens, insulating them from lexer evolution.
Not #[non_exhaustive], deliberately: this is the enum Token (which
is #[non_exhaustive]) exists to protect embedders from — it is the
small, closed vocabulary a syntax highlighter matches exhaustively so a
new Token variant never breaks it. Making this one grow too would
defeat the reason it exists.
Variants§
Keyword
Keywords: if, then, else, for, while, function, return, etc.
Operator
Operators: |, &&, ||, >, >>, 2>&1, =, ==, etc.
String
String literals: “…”, ‘…’, heredocs
Number
Numeric literals: 123, 3.14, arithmetic expressions
Variable
Variable references: $foo, ${bar}, $1, $@, $#, $?, $$
Comment
Comments: # …
Punctuation
Punctuation: ; , . ( ) { } [ ]
Command
Identifiers in command position
Path
Absolute paths: /foo/bar
Flag
Flags: –long, -s, +x
Error
Invalid tokens
Trait Implementations§
Source§impl Clone for TokenCategory
impl Clone for TokenCategory
Source§fn clone(&self) -> TokenCategory
fn clone(&self) -> TokenCategory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TokenCategory
Source§impl Debug for TokenCategory
impl Debug for TokenCategory
impl Eq for TokenCategory
Source§impl Hash for TokenCategory
impl Hash for TokenCategory
Source§impl PartialEq for TokenCategory
impl PartialEq for TokenCategory
impl StructuralPartialEq for TokenCategory
Auto Trait Implementations§
impl Freeze for TokenCategory
impl RefUnwindSafe for TokenCategory
impl Send for TokenCategory
impl Sync for TokenCategory
impl Unpin for TokenCategory
impl UnsafeUnpin for TokenCategory
impl UnwindSafe for TokenCategory
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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.