Interpreter

Struct Interpreter 

Source
pub struct Interpreter<'a> { /* private fields */ }
Expand description

The AWK interpreter runtime

Implementations§

Source§

impl<'a> Interpreter<'a>

Source

pub fn call_function<W: Write>( &mut self, name: &str, args: &[Expr], location: SourceLocation, output: &mut W, ) -> Result<Value>

Call a function with special handling for builtins that need AST access

Source§

impl<'a> Interpreter<'a>

Source

pub fn eval_expr(&mut self, expr: &Expr) -> Result<Value>

Evaluate an expression (for contexts where we don’t have output, like condition checking)

Source

pub fn eval_expr_with_output<W: Write>( &mut self, expr: &Expr, output: &mut W, ) -> Result<Value>

Evaluate an expression with a writer for function calls that produce output

Source

pub fn assign_to_lvalue(&mut self, target: &Expr, value: Value) -> Result<()>

Source§

impl<'a> Interpreter<'a>

Source

pub fn execute_block<W: Write>( &mut self, block: &Block, output: &mut W, ) -> Result<StmtResult>

Source

pub fn execute_stmt<W: Write>( &mut self, stmt: &Stmt, output: &mut W, ) -> Result<StmtResult>

Source§

impl<'a> Interpreter<'a>

Source

pub fn new(program: &'a Program) -> Self

Source

pub fn set_args(&mut self, args: Vec<String>)

Set command line arguments (ARGC and ARGV)

Source

pub fn set_fs(&mut self, fs: &str)

Set the field separator

Source

pub fn set_posix_mode(&mut self, enabled: bool)

Set POSIX strict mode

Source

pub fn set_traditional_mode(&mut self, enabled: bool)

Set traditional AWK mode (no gawk extensions)

Source

pub fn set_variable(&mut self, name: &str, value: &str)

Set a variable before execution

Source

pub fn set_filename(&mut self, filename: &str)

Set the current filename (FILENAME)

Source

pub fn run<R: BufRead, W: Write>( &mut self, inputs: Vec<R>, output: &mut W, ) -> Result<i32>

Run the AWK program with given input

Auto Trait Implementations§

§

impl<'a> Freeze for Interpreter<'a>

§

impl<'a> RefUnwindSafe for Interpreter<'a>

§

impl<'a> Send for Interpreter<'a>

§

impl<'a> Sync for Interpreter<'a>

§

impl<'a> Unpin for Interpreter<'a>

§

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