Skip to main content

DatumKind

Enum DatumKind 

Source
pub enum DatumKind<'a> {
    List {
        delim: Delim,
        items: Vec<Datum<'a>>,
        tail: Option<Box<Datum<'a>>>,
        dot: Option<Span>,
    },
    Symbol(&'a str),
    Keyword(&'a str),
    Number(&'a str),
    Str(&'a str),
    Char(&'a str),
    Bool(bool),
    Prefixed {
        prefix: Prefix,
        notation: Notation,
        inner: Box<Datum<'a>>,
        arg: Option<Box<Datum<'a>>>,
    },
    HashLiteral {
        tag: &'a str,
        inner: Option<Box<Datum<'a>>>,
    },
    Label {
        id: &'a str,
        inner: Box<Datum<'a>>,
    },
    LabelRef {
        id: &'a str,
    },
}
Expand description

The shape of a Datum.

Variants§

§

List

A list. tail: Some(_) marks an improper/dotted list (a b . c) (ADR-0009). The delimiter is shape only; its meaning is the consumer’s per dialect.

Fields

§delim: Delim

The delimiter shape (()/[]/{}/#{}).

§items: Vec<Datum<'a>>

The list elements, in order.

§tail: Option<Box<Datum<'a>>>

The dotted tail, present only for an improper list (a . b).

§dot: Option<Span>

Byte span of the . separator, present only for an improper list. A text-based reindenter needs the dot’s column to align a tail continuation under it (the '(eval . FORM) font-lock idiom), which tail alone can’t give (ADR-0009). Some iff tail is Some; see Datum::dot_span.

§

Symbol(&'a str)

A symbol; verbatim slice, including enclosing |bars| if piped.

The Symbol/Number split is lexical-shape only, following Scheme-ish rules; the classifier never interprets a value. Anything ambiguous falls back to Symbol — e.g. Common Lisp’s 1+ and 1- are conventionally functions, not numbers, so a leading digit alone is not sufficient. Consumers that need a stricter or dialect-specific numeric grammar reclassify Symbol/Number text themselves; lispexp only records the token’s shape.

§

Keyword(&'a str)

A keyword such as :foo or #:foo.

§

Number(&'a str)

A number; raw text, value never interpreted.

Classification is lexical-shape only (see Symbol): digits, sign, radix/exactness prefixes (#x, #e, #36r...), decimal points, ratios, exponent markers, and a trailing complex i all qualify. Clojure’s symbolic values (##Inf, ##-Inf, ##NaN) classify as Number in every dialect, since they are read as numeric literals regardless of whether the dialect otherwise supports them.

§

Str(&'a str)

A string; raw slice including the surrounding quotes and escapes.

§

Char(&'a str)

A character literal; raw slice including the #\ / ? / \ lead form.

§

Bool(bool)

A boolean.

§

Prefixed

A reader macro applied to an inner datum (ADR-0002). notation distinguishes 'x (shorthand) from (quote x) (longhand).

Fields

§prefix: Prefix

The reader-macro role.

§notation: Notation

Whether it was written shorthand ('x) or longhand ((quote x)).

§inner: Box<Datum<'a>>

The datum the prefix applies to.

§arg: Option<Box<Datum<'a>>>

The auxiliary datum some prefixes carry, if any: the metadata form for Prefix::Meta (^meta target: arg is the metadata, inner the target) and the feature test for Prefix::FeatureConditional (#+sbcl form: arg is sbcl, inner the guarded form). None for every other prefix. The enclosing span covers glyph, arg, and inner.

§

HashLiteral

Any #tag-shaped form; tag is captured verbatim and unvalidated (ADR-0011). E.g. "" for #(...), "u8" for #u8(...). The tag may contain reader-macro glyphs — #`(…) (a Scheme syntax-case template) reads as a HashLiteral with tag "`", and #,(…) with tag "," — because a #tag immediately followed by an opening delimiter is always this one form. A #tag not followed by a delimiter (e.g. #`x) is instead a DatumKind::Symbol.

Fields

§tag: &'a str

The text between # and the following delimiter (may be empty).

§inner: Option<Box<Datum<'a>>>

The datum the tag applies to, if any.

§

Label

A datum label definition #n=<datum> (ADR-0011). No graph resolution.

Fields

§id: &'a str

The label id (the digits between # and =).

§inner: Box<Datum<'a>>

The labeled datum.

§

LabelRef

A datum label reference #n#.

Fields

§id: &'a str

The referenced label id.

Trait Implementations§

Source§

impl<'a> Clone for DatumKind<'a>

Source§

fn clone(&self) -> DatumKind<'a>

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<'a> Debug for DatumKind<'a>

Source§

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

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

impl<'a> Eq for DatumKind<'a>

Source§

impl<'a> PartialEq for DatumKind<'a>

Source§

fn eq(&self, other: &DatumKind<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for DatumKind<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for DatumKind<'a>

§

impl<'a> RefUnwindSafe for DatumKind<'a>

§

impl<'a> Send for DatumKind<'a>

§

impl<'a> Sync for DatumKind<'a>

§

impl<'a> Unpin for DatumKind<'a>

§

impl<'a> UnsafeUnpin for DatumKind<'a>

§

impl<'a> UnwindSafe for DatumKind<'a>

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.