cljrs_reader/token.rs
1/// A single lexical token produced by the clojurust lexer.
2#[derive(Debug, Clone, PartialEq)]
3pub enum Token {
4 // ── Atoms ────────────────────────────────────────────────────────────────
5 /// The literal `nil`.
6 Nil,
7 /// `true` or `false`.
8 Bool(bool),
9 /// Decimal or radix integer that fits in `i64`.
10 Int(i64),
11 /// `N`-suffix integer or one that overflows `i64`; stores decimal digits
12 /// without any sign or suffix (sign is implicit via the original `-`).
13 BigInt(String),
14 /// IEEE-754 double.
15 Float(f64),
16 /// `M`-suffix decimal; stores the raw text without the trailing `M`.
17 BigDecimal(String),
18 /// Rational literal `3/4`; stores the full text including the slash.
19 Ratio(String),
20 /// Character literal `\a`, `\newline`, `\u0041`, …
21 Char(char),
22 /// String literal with escape sequences fully processed.
23 Str(String),
24
25 // ── Identifiers ──────────────────────────────────────────────────────────
26 /// A symbol: `foo`, `ns/name`, `/`, `..`
27 Symbol(String),
28 /// A keyword (`:foo`); the leading colon is stripped, so stores `"foo"`.
29 Keyword(String),
30 /// An auto-resolved keyword (`::foo`); stores `"foo"` (leading `::` stripped).
31 AutoKeyword(String),
32
33 // ── Delimiters ───────────────────────────────────────────────────────────
34 LParen,
35 RParen,
36 LBracket,
37 RBracket,
38 LBrace,
39 RBrace,
40
41 // ── Reader macros ────────────────────────────────────────────────────────
42 /// `'`
43 Quote,
44 /// `` ` ``
45 SyntaxQuote,
46 /// `~`
47 Unquote,
48 /// `~@`
49 UnquoteSplice,
50 /// `@`
51 Deref,
52 /// `^`
53 Meta,
54
55 // ── `#` dispatch ─────────────────────────────────────────────────────────
56 /// `#(`
57 HashFn,
58 /// `#{`
59 HashSet,
60 /// `#'`
61 HashVar,
62 /// `#_`
63 HashDiscard,
64 /// `#"…"` — raw regex pattern, no escape processing.
65 Regex(String),
66 /// `#?`
67 ReaderCond,
68 /// `#?@`
69 ReaderCondSplice,
70 /// `##Inf` / `##-Inf` / `##NaN`; stores the suffix after `##`.
71 Symbolic(String),
72 /// `#tag` — tagged literal; stores the symbol name without the leading `#`.
73 TaggedLiteral(String),
74
75 /// End-of-file sentinel.
76 Eof,
77}