Struct rusty_systems::system::System

source ·
pub struct System { /* private fields */ }
Expand description

Represents an L-system. This is the base for running the production rules.

This struct is convenient for defining and storing tokens and productions without having to create your own collections.

See the system namespace to for information more broadly.

  • Productions can be parsed via strings.
  • Productions can be programmatically created.

This is thread safe, and is Sync and Send.

Implementations§

source§

impl System

source

pub fn new() -> Self

source

pub fn of_family<F: TryIntoFamily>(family: F) -> Result<Self>

Given a previously defined family, this returns a new system using the defined tokens / alphabet / words of that family of systems.

use rusty_systems::system::{family, System};
use rusty_systems::system::family::abop;

family::register(abop::abop_family()).expect("Unable to register the family");
let system = System::of_family("ABOP").expect("Unable to find system");
source

pub fn parse_production(&self, production: &str) -> Result<Production>

Parse a string as a production and add it to the system.

  • Empty bodies are allowed. This is how to write productions that lead to the empty string.
source

pub fn format<T: DisplaySystem>(&self, item: &T) -> Result<String>

Format Token, ProductionString, Production as strings.

source

pub fn derive_once(&self, string: ProductionString) -> Result<ProductionString>

Run a single iteration of the productions on the given string. Returns None if an empty string is produced.

source

pub fn derive( &self, string: ProductionString, settings: RunSettings ) -> Result<ProductionString>

source

pub fn parse_prod_string(&self, string: &str) -> Result<ProductionString>

source

pub fn production_len(&self) -> usize

Returns the number of production rules in the system.

source

pub fn token_len(&self) -> usize

Returns the number of tokens (terminal and production tokens) registered with the system

source

pub fn terminal_tokens_len(&self) -> usize

Returns the number of terminal tokens registered with the system

source

pub fn prod_tokens_len(&self) -> usize

Returns the number of terminal tokens registered with the system

Trait Implementations§

source§

impl Debug for System

source§

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

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

impl Default for System

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl ProductionStore for System

source§

impl TokenStore for System

source§

fn get_token(&self, name: &str) -> Option<Token>

Return the token that represents the given term, if it exists.

Note that this does not create any new tokens to the system.

source§

fn add_token(&self, name: &str, kind: TokenKind) -> Result<Token>

Auto Trait Implementations§

§

impl !Freeze for System

§

impl RefUnwindSafe for System

§

impl Send for System

§

impl Sync for System

§

impl Unpin for System

§

impl UnwindSafe for System

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>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V