Skip to main content

Language

Struct Language 

Source
pub struct Language {
Show 33 fields pub name: String, pub abi_version: u32, pub symbol_count: u32, pub alias_count: u32, pub token_count: u32, pub external_token_count: u32, pub state_count: u32, pub large_state_count: u32, pub production_id_count: u32, pub field_count: u32, pub max_alias_sequence_length: u32, pub keyword_capture_token: u16, pub symbol_names: Vec<String>, pub public_symbol_map: Vec<u16>, pub symbol_metadata: Vec<u8>, pub field_names: Vec<String>, pub field_map_slices: Vec<(u16, u16)>, pub field_map_entries: Vec<(u16, u8, bool)>, pub alias_sequences: Vec<u16>, pub non_terminal_alias_map: Vec<u16>, pub primary_state_ids: Vec<u16>, pub lex_modes: Vec<u16>, pub reserved_set: Vec<u8>, pub reserved_words: Vec<u16>, pub max_reserved: u32, pub state_start: Vec<u32>, pub entries: Vec<u32>, pub actions: Vec<Action>, pub lex: LexTable, pub keyword_lex: LexTable, pub lex_ext: Vec<u16>, pub ext_symbol_map: Vec<u16>, pub ext_valid: Vec<bool>,
}

Fields§

§name: String§abi_version: u32§symbol_count: u32§alias_count: u32§token_count: u32§external_token_count: u32§state_count: u32§large_state_count: u32§production_id_count: u32§field_count: u32§max_alias_sequence_length: u32§keyword_capture_token: u16§symbol_names: Vec<String>§public_symbol_map: Vec<u16>§symbol_metadata: Vec<u8>

位 0 可见,位 1 具名,位 2 supertype。

§field_names: Vec<String>§field_map_slices: Vec<(u16, u16)>

每个 production 的字段映射切片 (index, length)。

§field_map_entries: Vec<(u16, u8, bool)>

(字段 id, 子节点序号, 是否继承)

§alias_sequences: Vec<u16>§non_terminal_alias_map: Vec<u16>§primary_state_ids: Vec<u16>§lex_modes: Vec<u16>

每个解析状态的词法状态。

§reserved_set: Vec<u8>

每个解析状态使用的保留字集合编号(0 表示没有)。

§reserved_words: Vec<u16>

保留字集合,按 max_reserved 个一行展平,行内遇到 0 结束。

§max_reserved: u32§state_start: Vec<u32>§entries: Vec<u32>

高 16 位符号,低 16 位值,同一状态内按符号升序。

§actions: Vec<Action>§lex: LexTable§keyword_lex: LexTable§lex_ext: Vec<u16>

每个解析状态的外部词法状态(0 表示没有外部记号可用)。

§ext_symbol_map: Vec<u16>

外部记号序号到符号的映射。

§ext_valid: Vec<bool>

外部词法状态的有效记号表:按 一行展平,第 0 行全假(行宽为外部记号数)。

Implementations§

Source§

impl Language

Source

pub fn lookup(&self, state: u16, symbol: u16) -> u16

对应官方 ts_language_lookup:终结符得到动作下标,非终结符得到后继状态。

Source

pub fn has_actions(&self, state: u16, symbol: u16) -> bool

Source

pub fn actions_for(&self, state: u16, symbol: u16) -> &[Action]

官方 ts_language_table_entry:错误符号没有动作。

Source

pub fn has_reduce_action(&self, state: u16, symbol: u16) -> bool

Source

pub fn next_state(&self, state: u16, symbol: u16) -> u16

Source

pub fn is_reserved(&self, state: u16, sym: u16) -> bool

官方 ts_language_is_reserved_word。

Source

pub fn ext_state(&self, parse_state: u16) -> u16

解析状态对应的外部词法状态(没有外部记号返回 0)。

Source

pub fn ext_valid_row(&self, ext_state: u16) -> &[bool]

某个外部词法状态下各外部记号是否有效。

Source

pub fn visible(&self, sym: u16) -> bool

Source

pub fn named(&self, sym: u16) -> bool

Source

pub fn symbol_name(&self, sym: u16) -> &str

Source

pub fn public_symbol(&self, sym: u16) -> u16

Source

pub fn field_name(&self, id: u16) -> &str

Source

pub fn alias_sequence(&self, prod: u16) -> Option<&[u16]>

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Source

pub fn from_bytes(b: &[u8]) -> Result<Language, String>

Trait Implementations§

Source§

impl Clone for Language

Source§

fn clone(&self) -> Self

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 Language

Source§

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

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

impl Default for Language

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Language

Source§

impl PartialEq for Language

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Language

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.