Skip to main content

Node

Struct Node 

Source
pub struct Node {
    pub first: u64,
    pub a: u32,
    pub b: u32,
    pub op: Op,
    pub flags: u8,
}
Expand description

One node. Twenty four bytes, and everything the matcher needs to decide what to do with it.

The FIRST set and the nullable bit live in here rather than in two arrays beside it. They used to be parallel tables, on the theory that the filter could read eight bytes of FIRST and skip the node entirely, and that theory was wrong in the case that matters. A node that survives the filter is loaded immediately afterwards, and surviving is the common case: the filter is there to cut the thirty six alternatives of Statement down, and the one that matches still has to be walked. So the old layout paid three cache lines on every node it did not reject and saved two on every node it did, and the walk visits far more of the first kind.

Fields§

§first: u64

What this node can start with, as a set of token keys. A superset, always.

§a: u32§b: u32§op: Op§flags: u8

Per op, plus NULLABLE, which every op can carry.

Implementations§

Source§

impl Node

Source

pub const RESERVED: u8

On an Identifier node: the keyword check is dropped, so any word matches.

This is the whole of ReservedIdentifierMatcher. It is worth knowing that upstream applies it to the rule named ReservedKeyword, so a grammar rule that reads ColLabel <- ReservedKeyword / ... does not test for a reserved word, it accepts any word at all. Reading the grammar text alone would get that backwards.

Source

pub const NULLABLE: u8

This node can match without consuming a token, so its FIRST set says nothing about whether it applies and the filter has to let it through.

Source

pub fn can_start(self, key: u64) -> bool

Whether a node could possibly begin with this token.

False means it cannot, and that is the only answer the caller may act on. True means try it. A nullable node always answers true.

Source

pub fn children(self) -> &'static [u32]

The children of a sequence or a choice.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

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 Copy for Node

Source§

impl Debug for Node

Source§

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

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

impl Eq for Node

Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> 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 Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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.