Skip to main content

GraphParser

Struct GraphParser 

Source
pub struct GraphParser<'a> {
    pub tokens: &'a [Token],
    pub at: usize,
}
Expand description

A self-contained recursive-descent parser for the nodes = {...} and branches = {...} bodies, operating directly on a token slice.

Fields§

§tokens: &'a [Token]

The full token stream being parsed.

§at: usize

Current cursor position into tokens.

Implementations§

Source§

impl<'a> GraphParser<'a>

Source

pub fn node_graph(&mut self) -> Result<(NodeGraph, usize), SpecError>

{ name = { field* }; ... } — the whole nodes = {...} body.

Returns the parsed graph together with the token position just past its closing }spec.rs’s Parser (a separate struct walking the same token slice, Task 3) needs that position to resume parsing the rest of the spec {...} body afterward, since it can’t see GraphParser’s internal cursor otherwise.

Source

pub fn branches(&mut self) -> Result<(Branches, usize), SpecError>

{ node_name = { "label" -> target; ... }; ... } — the whole branches = {...} body. Returns (Branches, new_at), same handoff convention as Self::node_graph.

Auto Trait Implementations§

§

impl<'a> Freeze for GraphParser<'a>

§

impl<'a> RefUnwindSafe for GraphParser<'a>

§

impl<'a> Send for GraphParser<'a>

§

impl<'a> Sync for GraphParser<'a>

§

impl<'a> Unpin for GraphParser<'a>

§

impl<'a> UnsafeUnpin for GraphParser<'a>

§

impl<'a> UnwindSafe for GraphParser<'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> 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, 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.