Skip to main content

AST

Struct AST 

Source
pub struct AST {
    pub version: f32,
    pub globals: RwLock<HashMap<String, String>>,
    pub vars: RwLock<HashMap<String, String>>,
    pub subs: HashMap<String, String>,
    pub person: HashMap<String, String>,
    pub arrays: HashMap<String, Vec<String>>,
    pub topics: HashMap<String, Topic>,
    pub objects: HashMap<String, Object>,
}
Expand description

Root of the “abstract syntax tree” representing a RiveScript source document and its useful contents.

Fields§

§version: f32§globals: RwLock<HashMap<String, String>>§vars: RwLock<HashMap<String, String>>§subs: HashMap<String, String>§person: HashMap<String, String>§arrays: HashMap<String, Vec<String>>§topics: HashMap<String, Topic>§objects: HashMap<String, Object>

Implementations§

Source§

impl AST

Source

pub fn new() -> Self

Initialize a new AST object ready for populating.

Source

pub fn extend(&mut self, other: AST)

Merge the current AST with the contents of the other.

This is used during parsing when e.g. loading a whole directory of files. All parsed files add to the loaded AST for the root RiveScript instance.

Source

pub fn init_topic(&mut self, name: &String)

Initialize the data structure for a new topic, if it wasn’t already there.

Source

pub fn has_begin_block(&self) -> bool

Returns true if a >begin section exists.

Source

pub fn has_topic(&self, name: &str) -> bool

Returns true if the topic exists.

Source

pub fn get_global(&self, name: &str) -> String

Get a global variable. Returns “undefined” if not set.

Source

pub fn set_global(&self, name: &str, value: &str)

Set a global variable.

Source

pub fn get_bot_var(&self, name: &str) -> String

Get a bot variable. Returns “undefined” if not set.

Source

pub fn set_bot_var(&self, name: &str, value: &str)

Set a bot variable.

Trait Implementations§

Source§

impl Debug for AST

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for AST

§

impl RefUnwindSafe for AST

§

impl Send for AST

§

impl Sync for AST

§

impl Unpin for AST

§

impl UnsafeUnpin for AST

§

impl UnwindSafe for AST

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.