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.
Implementations§
source§impl System
impl System
pub fn new() -> Self
sourcepub fn of_family<F: TryIntoFamily>(family: F) -> Result<Self>
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");sourcepub fn parse_production(&self, production: &str) -> Result<Production>
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.
sourcepub fn format<T: DisplaySystem>(&self, item: &T) -> Result<String>
pub fn format<T: DisplaySystem>(&self, item: &T) -> Result<String>
Format Token, ProductionString, Production as strings.
sourcepub fn derive_once(&self, string: ProductionString) -> Result<ProductionString>
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.
pub fn derive( &self, string: ProductionString, settings: RunSettings ) -> Result<ProductionString>
pub fn parse_prod_string(&self, string: &str) -> Result<ProductionString>
sourcepub fn production_len(&self) -> usize
pub fn production_len(&self) -> usize
Returns the number of production rules in the system.
sourcepub fn token_len(&self) -> usize
pub fn token_len(&self) -> usize
Returns the number of tokens (terminal and production tokens) registered with the system
sourcepub fn terminal_tokens_len(&self) -> usize
pub fn terminal_tokens_len(&self) -> usize
Returns the number of terminal tokens registered with the system
sourcepub fn prod_tokens_len(&self) -> usize
pub fn prod_tokens_len(&self) -> usize
Returns the number of terminal tokens registered with the system