Skip to main content

TokenKind

Enum TokenKind 

Source
pub enum TokenKind {
Show 135 variants IntLit(i64), UIntLit(u64), FloatLit(f64), CharLit(u8), WideCharLit(u32), StringLit(Vec<u8>), WideStringLit(Vec<u32>), Ident(InternedStr), KwAuto, KwExtern, KwRegister, KwStatic, KwTypedef, KwChar, KwDouble, KwFloat, KwInt, KwLong, KwShort, KwSigned, KwUnsigned, KwVoid, KwConst, KwVolatile, KwRestrict, KwStruct, KwUnion, KwEnum, KwBreak, KwCase, KwContinue, KwDefault, KwDo, KwElse, KwFor, KwGoto, KwIf, KwReturn, KwSwitch, KwWhile, KwInline, KwSizeof, KwBool, KwComplex, KwImaginary, KwAlignas, KwAlignof, KwAtomic, KwGeneric, KwNoreturn, KwStaticAssert, KwThreadLocal, KwFloat16, KwFloat32, KwFloat64, KwFloat128, KwFloat32x, KwFloat64x, KwInt128, KwInline2, KwInline3, KwSigned2, KwConst2, KwConst3, KwVolatile2, KwVolatile3, KwRestrict2, KwRestrict3, KwBool2, KwAlignof2, KwAlignof3, KwTypeof, KwTypeof2, KwTypeof3, KwAttribute, KwAttribute2, KwAsm, KwAsm2, KwAsm3, KwExtension, KwThread, Plus, Minus, Star, Slash, Percent, Amp, Pipe, Caret, Tilde, LtLt, GtGt, Bang, AmpAmp, PipePipe, Lt, Gt, LtEq, GtEq, EqEq, BangEq, Eq, PlusEq, MinusEq, StarEq, SlashEq, PercentEq, AmpEq, PipeEq, CaretEq, LtLtEq, GtGtEq, PlusPlus, MinusMinus, Question, Colon, Arrow, Dot, Ellipsis, Comma, Semi, LParen, RParen, LBracket, RBracket, LBrace, RBrace, Hash, HashHash, Backslash, Eof, Newline, Space, MacroBegin(Box<MacroBeginInfo>), MacroEnd(MacroEndInfo),
}
Expand description

トークン種別

Variants§

§

IntLit(i64)

整数リテラル

§

UIntLit(u64)

符号なし整数リテラル

§

FloatLit(f64)

浮動小数点リテラル

§

CharLit(u8)

文字リテラル

§

WideCharLit(u32)

ワイド文字リテラル

§

StringLit(Vec<u8>)

文字列リテラル

§

WideStringLit(Vec<u32>)

ワイド文字列リテラル

§

Ident(InternedStr)

§

KwAuto

§

KwExtern

§

KwRegister

§

KwStatic

§

KwTypedef

§

KwChar

§

KwDouble

§

KwFloat

§

KwInt

§

KwLong

§

KwShort

§

KwSigned

§

KwUnsigned

§

KwVoid

§

KwConst

§

KwVolatile

§

KwRestrict

§

KwStruct

§

KwUnion

§

KwEnum

§

KwBreak

§

KwCase

§

KwContinue

§

KwDefault

§

KwDo

§

KwElse

§

KwFor

§

KwGoto

§

KwIf

§

KwReturn

§

KwSwitch

§

KwWhile

§

KwInline

§

KwSizeof

§

KwBool

§

KwComplex

§

KwImaginary

§

KwAlignas

§

KwAlignof

§

KwAtomic

§

KwGeneric

§

KwNoreturn

§

KwStaticAssert

§

KwThreadLocal

§

KwFloat16

§

KwFloat32

§

KwFloat64

§

KwFloat128

§

KwFloat32x

§

KwFloat64x

§

KwInt128

§

KwInline2

§

KwInline3

§

KwSigned2

§

KwConst2

§

KwConst3

§

KwVolatile2

§

KwVolatile3

§

KwRestrict2

§

KwRestrict3

§

KwBool2

§

KwAlignof2

§

KwAlignof3

§

KwTypeof

§

KwTypeof2

§

KwTypeof3

§

KwAttribute

§

KwAttribute2

§

KwAsm

§

KwAsm2

§

KwAsm3

§

KwExtension

§

KwThread

§

Plus

§

Minus

§

Star

§

Slash

§

Percent

§

Amp

§

Pipe

§

Caret

§

Tilde

§

LtLt

§

GtGt

§

Bang

§

AmpAmp

§

PipePipe

§

Lt

§

Gt

§

LtEq

§

GtEq

§

EqEq

§

BangEq

§

Eq

§

PlusEq

§

MinusEq

§

StarEq

§

SlashEq

§

PercentEq

§

AmpEq

§

PipeEq

§

CaretEq

§

LtLtEq

§

GtGtEq

§

PlusPlus

§

MinusMinus

§

Question

§

Colon

§

Arrow

§

Dot

§

Ellipsis

§

Comma

§

Semi

§

LParen

§

RParen

§

LBracket

§

RBracket

§

LBrace

§

RBrace

§

Hash

§

HashHash

§

Backslash

§

Eof

ファイル終端

§

Newline

改行(プリプロセッサ用)

§

Space

空白(スペース/タブ)- PARSE_FLAG_SPACES モード用

§

MacroBegin(Box<MacroBeginInfo>)

マクロ展開開始マーカー

プリプロセッサがマクロ展開時に挿入し、パーサーが透過的に処理する。 AST構築時にマクロ展開情報を付与するために使用。

§

MacroEnd(MacroEndInfo)

マクロ展開終了マーカー

対応する MacroBegin と対を形成する。

Implementations§

Source§

impl TokenKind

Source

pub fn from_keyword(s: &str) -> Option<TokenKind>

キーワード文字列からTokenKindへの変換

Source

pub fn is_keyword(&self) -> bool

キーワードトークンかどうかを判定

Source

pub fn keyword_str(&self) -> Option<&'static str>

キーワードトークン (Kw*) ならその表記文字列を &'static str で返す。 それ以外(Ident, リテラル, 記号)は None。

プリプロセッサで #define bool _Bool のような「キーワードに見える名前を マクロ名として使う」ケースを受理するために、Ident と同等の扱いができるよう 識別子文字列を取り出す共通ヘルパ。TinyCC の統一トークン namespace に相当 する役割を、こちら側では lexer の出口で「キーワードと識別子を別バリアントに 分けてしまっている」ためここで吸収する。

Source

pub fn format(&self, interner: &StringInterner) -> String

トークンを文字列に変換

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> TokenKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &TokenKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.