Enum yash_syntax::parser::Rec
source · [−]pub enum Rec<T> {
AliasSubstituted,
Parsed(T),
}
Expand description
Modifier that makes a result of parsing optional in order to trigger the parser to restart parsing after alias substitution.
Rec
stands for “recursion”, as it is used to make the parser work recursively.
This enum type has two variants: AliasSubstituted
and Parsed
. The former contains no
meaningful value and is returned from a parsing function that has performed alias substitution
without consuming any tokens. In this case, the caller of the parsing function must inspect the
new source code produced by the substitution so that the syntax is correctly recognized in the
new code.
Assume we have an alias definition untrue='! true'
, for example. When the word untrue
is
recognized as an alias name during parse of a simple command, the simple command parser
function must stop parsing and return AliasSubstituted
. This allows the caller, the pipeline
parser function, to recognize the !
reserved word token as negation.
When a parser function successfully parses something, it returns the result in the Parsed
variant. The caller then continues the remaining parse.
Variants
AliasSubstituted
Result of alias substitution.
Parsed(T)
Successful parse result.
Implementations
sourceimpl<T> Rec<T>
impl<T> Rec<T>
sourcepub fn is_alias_substituted(&self) -> bool
pub fn is_alias_substituted(&self) -> bool
Tests if self
is AliasSubstituted
.
Trait Implementations
impl<T: Copy> Copy for Rec<T>
impl<T: Eq> Eq for Rec<T>
impl<T> StructuralEq for Rec<T>
impl<T> StructuralPartialEq for Rec<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Rec<T> where
T: RefUnwindSafe,
impl<T> Send for Rec<T> where
T: Send,
impl<T> Sync for Rec<T> where
T: Sync,
impl<T> Unpin for Rec<T> where
T: Unpin,
impl<T> UnwindSafe for Rec<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more