Skip to main content

PrettyPrinter

Struct PrettyPrinter 

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

Pretty printer for surface expressions.

Implementations§

Source§

impl PrettyPrinter

Source

pub fn new() -> Self

Create a new pretty printer with default configuration.

Source

pub fn with_config(config: PrettyConfig) -> Self

Create a pretty printer with the given configuration.

Source

pub fn output(self) -> String

Get the output buffer.

Source

pub fn register_notation( &mut self, func_name: &str, symbol: &str, precedence: u32, is_infix: bool, )

Register a notation for notation-aware printing.

Source

pub fn try_single_line(&mut self, expr: &SurfaceExpr) -> Option<String>

Try to print an expression on a single line. Returns the string if it fits within max_width from the current column, otherwise None.

Source

pub fn print_expr_prec(&mut self, expr: &SurfaceExpr, outer_prec: u32) -> Result

Print an expression with precedence-aware parenthesization.

If the expression’s own precedence is less than outer_prec, parentheses are added.

Source

pub fn print_pattern(&mut self, pat: &Pattern) -> Result

Pretty print a pattern.

Source

pub fn print_match( &mut self, scrutinee: &SurfaceExpr, arms: &[MatchArm], ) -> Result

Pretty print a match expression with aligned arms.

Source

pub fn print_do(&mut self, actions: &[DoAction]) -> Result

Pretty print a do block with indented actions.

Source

pub fn print_inductive( &mut self, name: &str, univ_params: &[String], params: &[Binder], ty: &SurfaceExpr, ctors: &[Constructor], ) -> Result

Pretty print an inductive type declaration.

Source

pub fn print_expr(&mut self, expr: &SurfaceExpr) -> Result

Pretty print a surface expression.

Source

pub fn print_decl(&mut self, decl: &Decl) -> Result

Pretty print a declaration.

Trait Implementations§

Source§

impl Default for PrettyPrinter

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.