Enum wagon_parser::parser::atom::Atom
source · pub enum Atom {
Ident(Ident),
Dict(Dictionary),
LitBool(bool),
LitNum(i32),
LitFloat(NotNan<f32>),
LitString(String),
Group(SpannableNode<Expression>),
}
Expand description
The base elements of each expression.
The data in here is kind of similar to [wagon_value::Value
] and TryFrom
is implemented for it as a result.
However, an Atom
includes additional syntactic data, which is not important (or even not available) for Value
(for example, an Ident
).
As a result, Atom::Ident
, Atom::Dict
and Atom::Group
can not be directly converted and manual implementation is required.
§Grammar
Atom -> Ident
| Dictionary
| bool
| i32
| f32
| String
|
"("
Expression ")"
;
Variants§
Ident(Ident)
An Ident
.
Dict(Dictionary)
A Dictionary
.
LitBool(bool)
A bool
.
LitNum(i32)
An i32
.
LitFloat(NotNan<f32>)
An f32
.
LitString(String)
A String
.
Group(SpannableNode<Expression>)
Another full Expression
. Enclosed by ()
.
Implementations§
source§impl Atom
impl Atom
sourcepub fn new_unspanned_ident(arg_0: Ident) -> Self
pub fn new_unspanned_ident(arg_0: Ident) -> Self
Construct a Self::Ident
with dummy span information.
sourcepub fn new_unspanned_dict(arg_0: Dictionary) -> Self
pub fn new_unspanned_dict(arg_0: Dictionary) -> Self
Construct a Self::Dict
with dummy span information.
sourcepub fn new_unspanned_litbool(arg_0: bool) -> Self
pub fn new_unspanned_litbool(arg_0: bool) -> Self
Construct a Self::LitBool
with dummy span information.
sourcepub fn new_unspanned_litnum(arg_0: i32) -> Self
pub fn new_unspanned_litnum(arg_0: i32) -> Self
Construct a Self::LitNum
with dummy span information.
sourcepub fn new_unspanned_litfloat(arg_0: NotNan<f32>) -> Self
pub fn new_unspanned_litfloat(arg_0: NotNan<f32>) -> Self
Construct a Self::LitFloat
with dummy span information.
sourcepub fn new_unspanned_litstring(arg_0: String) -> Self
pub fn new_unspanned_litstring(arg_0: String) -> Self
Construct a Self::LitString
with dummy span information.
sourcepub fn new_unspanned_group(arg_0: Expression) -> Self
pub fn new_unspanned_group(arg_0: Expression) -> Self
Construct a Self::Group
with dummy span information.
Trait Implementations§
source§impl Parse for Atom
impl Parse for Atom
source§fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>
fn parse(lexer: &mut LexerBridge<'_>) -> ParseResult<Self>
source§fn parse_sep(
lexer: &mut LexerBridge<'_>,
join: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
fn parse_sep(
lexer: &mut LexerBridge<'_>,
join: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
source§fn parse_sep_end(
lexer: &mut LexerBridge<'_>,
join: Tokens,
end: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
fn parse_sep_end(
lexer: &mut LexerBridge<'_>,
join: Tokens,
end: Tokens
) -> ParseResult<Vec<Self>>where
Self: Sized,
source§impl PartialEq for Atom
impl PartialEq for Atom
impl Eq for Atom
impl StructuralPartialEq for Atom
Auto Trait Implementations§
impl Freeze for Atom
impl RefUnwindSafe for Atom
impl Send for Atom
impl Sync for Atom
impl Unpin for Atom
impl UnwindSafe for Atom
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> WrapSpannable<T, SpannableNode<T>> for Twhere
T: Parse,
impl<T> WrapSpannable<T, SpannableNode<T>> for Twhere
T: Parse,
source§fn wrap_spannable(self) -> SpannableNode<T>
fn wrap_spannable(self) -> SpannableNode<T>
source§fn into_spanned(self, span: Range<usize>) -> SpannableNode<T>
fn into_spanned(self, span: Range<usize>) -> SpannableNode<T>
SpannableNode
with the specified Span
.