pub enum Token {
Keyword(&'static str),
Ident(String),
Num(f64),
BigIntLit(String),
Str(String),
Template(Vec<TemplatePart>),
Sym(&'static str),
Regex(Box<(String, String)>),
LazyBody(u32, u32, bool),
Eof,
}Expand description
【2026-10-17】メモリ削減: 予約語と記号は固定表の &'static str、正規表現リテラルは
箱詰めにして 1 トークン 56 → 32 バイト。従来は記号(全トークンの約半分)まで 1 個ずつ
String を確保しており、YouTube の base.js(2.97MB)のトークン列が約 101MB あった。
Variants§
Keyword(&'static str)
Ident(String)
Num(f64)
BigIntLit(String)
BigInt リテラルの数値部分(接尾辞 n を除く。0x/0o/0b 接頭辞は保持)。
Str(String)
Template(Vec<TemplatePart>)
テンプレートリテラル: quasi(リテラル部)と補間式の生ソースが交互に並ぶ。
常に quasi で始まり quasi で終わる(Quasi("") を含む場合もある)。
Sym(&'static str)
記号(演算子・区切り)。例: “===”, “=>”, “(”, “;”。
Regex(Box<(String, String)>)
正規表現リテラル /pattern/flags(パターン, フラグ)。
LazyBody(u32, u32, bool)
遅延解析で読み飛ばした大きな関数本体({ と } の間)。字句解析器は出さず、
パーサが組み立て時に置く。(開始, 終了)は文字単位の位置、bool は先頭に
"use strict" 指令があったか。
Eof
Trait Implementations§
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
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
Mutably borrows from an owned value. Read more