[][src]Struct xbasic::xbasic::XBasic

pub struct XBasic<T: 'static> {
    pub error_handler: ErrorHandler,
    // some fields omitted
}

Represents an xBASIC Interpreter.

Fields

error_handler: ErrorHandler

Keeps track of errors that have been encountered while interpreting source code. Errors are recorded as user-friendly strings so that they can be passed directly to the user.

Implementations

impl<T> XBasic<T> where
    T: BasicIO
[src]

pub fn new(stdio: T) -> Self[src]

Creates a new XBasic struct with the given BasicIO instance.

pub fn run(&mut self, source: &str) -> Result<(), ()>[src]

Runs a snippet of XBasic source code using the interpreter. Returns Ok if there are no errors. Otherwise returns Err and keeps track of errors in the error_handler field.

Arguments

  • source - The XBasic code. This should be terminated by a newline character.

pub fn clear_errors(&mut self)[src]

Clears all existing errors in the various stages of the interpreter.

pub fn call_function(
    &mut self,
    name: &str,
    arguments: &[ExprValue]
) -> Result<ExprValue, ()>
[src]

Calls an xBASIC function from Rust code.

Arguments

  • name - The name of the function to call
  • arguments - The arguments of the function to be called

pub fn get_io(&self) -> &T[src]

Gets a reference to the IO object. Useful if you are using the IO object for some kind of state.

pub fn get_io_mut(&mut self) -> &mut T[src]

Gets a mutable reference to the IO object. Useful if you are using the IO object for some kind of state.

Auto Trait Implementations

impl<T> !RefUnwindSafe for XBasic<T>[src]

impl<T> !Send for XBasic<T>[src]

impl<T> !Sync for XBasic<T>[src]

impl<T> Unpin for XBasic<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for XBasic<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.