Skip to main content

Op

Enum Op 

Source
#[repr(u8)]
pub enum Op {
Show 13 variants Keyword = 0, Symbol = 1, Rule = 2, Sequence = 3, Choice = 4, Optional = 5, Repeat = 6, Identifier = 7, Number = 8, String = 9, Operator = 10, EndOfInput = 11, KeywordClass = 12,
}
Expand description

What a node is.

The discriminants are written into generated::rules as Op::Name, so they are not load bearing on their own, but xtask’s copy of this enum has to have the same variants in the same order for the generator to be able to name them. the_ops_match_the_generator is that check.

Variants§

§

Keyword = 0

A word. a indexes generated::keywords::KEYWORDS, and the comparison is an index compare because the tokenizer already resolved the token’s word to the same table.

§

Symbol = 1

Punctuation or an operator. a indexes SYMBOLS and the comparison is on text.

§

Rule = 2

A reference to a rule. a is the rule index.

§

Sequence = 3

a is a start index into CHILDREN, b is how many. All of them, in order.

§

Choice = 4

Same layout. Ordered choice, first success wins, no backtracking into a taken alternative.

§

Optional = 5

a is the child node. Matches it or matches nothing.

§

Repeat = 6

a is the child node. One or more. X* is Optional(Repeat(X)) in the table, because that is what upstream builds and a separate zero or more node would be a second thing to keep in step for no gain.

§

Identifier = 7

An identifier matcher. a is a Suggestion, flags bit 0 is RESERVED.

§

Number = 8

A numeric literal.

§

String = 9

A string literal, including its adjacent continuations.

§

Operator = 10

An operator token, subject to the exclusions in OperatorMatcher.

§

EndOfInput = 11

The end of the input.

§

KeywordClass = 12

A word in one of the five keyword classes. a is the class mask.

The grammar spells these as an ordered choice of two hundred literals, because a PEG has no way to say “a word in this set”. Upstream compiles that to two hundred KeywordMatcher objects and tries them in turn. The words in a list are distinct and a KeywordMatcher is a case insensitive text compare, so membership in the list is exactly a mask test on the class the tokenizer already resolved, and the two are the same predicate.

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Op

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 Op

Source§

impl Debug for Op

Source§

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

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

impl Eq for Op

Source§

impl PartialEq for Op

Source§

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

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

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.