Skip to main content

BashBackend

Struct BashBackend 

Source
pub struct BashBackend { /* private fields */ }
Expand description

Bash script code generation backend for OxiLean.

Implementations§

Source§

impl BashBackend

Source

pub fn new() -> Self

Create a new BashBackend with default settings.

Source

pub fn compact() -> Self

Create a BashBackend with 2-space indentation.

Source

pub fn emit_var_decl(&self, var: &BashVar, value: Option<&str>) -> String

Emit a BashVar as its declaration line (for declare statements).

Source

pub fn emit_var(&self, var: &BashVar) -> String

Emit a BashVar as an expansion (${name} form).

Source

pub fn emit_expr(&self, expr: &BashExpr) -> String

Emit a BashExpr as a string.

Source

pub fn emit_condition(&self, cond: &BashCondition) -> String

Emit a BashCondition as a string.

Source

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

Mangle an OxiLean name into a valid Bash identifier.

Bash function/variable names match [a-zA-Z_][a-zA-Z0-9_]*. Namespace separators (., ::) become __.

Source

pub fn emit_function(&self, func: &BashFunction) -> String

Emit a BashFunction as a shell function definition.

Source

pub fn emit_heredoc(&self, heredoc: &BashHereDoc) -> String

Emit a BashHereDoc as a string.

Source

pub fn emit_script(&self, script: &BashScript) -> String

Emit a complete BashScript as a string.

Source

pub fn emit_array_assign(&self, name: &str, elems: &[BashExpr]) -> String

Emit an array assignment: name=(elem1 elem2 ...)

Source

pub fn emit_assoc_array_assign( &self, name: &str, pairs: &[(String, String)], ) -> String

Emit an associative array assignment block.

Source

pub fn emit_if( &self, cond: &BashCondition, then: &[&str], else_: Option<&[&str]>, ) -> String

Emit an if statement.

Source

pub fn emit_for_in( &self, var: &str, items: &[BashExpr], body: &[&str], ) -> String

Emit a for-in loop.

Source

pub fn emit_while(&self, cond: &BashCondition, body: &[&str]) -> String

Emit a while loop.

Source

pub fn emit_case(&self, expr: &BashExpr, arms: &[(&str, Vec<&str>)]) -> String

Emit a case statement.

Trait Implementations§

Source§

impl Default for BashBackend

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.