1#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
5#[cfg_attr(feature = "serde", derive(rserde::Serialize))]
6#[cfg_attr(feature = "serde", serde(crate = "rserde"))]
7pub struct TokenDescriptor {
8 pub variant_name: &'static str,
10
11 pub parser_token: &'static str,
13
14 pub kinds: &'static [&'static str],
16}
17
18impl TokenDescriptor {
19 pub const fn new(
21 variant_name: &'static str,
22 parser_token: &'static str,
23 kinds: &'static [&'static str],
24 ) -> Self {
25 Self {
26 variant_name,
27 parser_token,
28 kinds,
29 }
30 }
31}
32
33pub trait Token: std::fmt::Display {
35 fn variant_name(&self) -> &'static str;
37
38 fn parser_token(&self) -> &'static str;
40
41 fn kinds(&self) -> &'static [&'static str];
43
44 fn all_tokens() -> &'static [TokenDescriptor];
46}