forked from Orchid/orchid
Formatter introduced
This commit is contained in:
@@ -4,7 +4,8 @@ use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
|
||||
use crate::{
|
||||
ExprTicket, Expression, ExtHostReq, HostExtNotif, HostExtReq, OrcResult, SysId, TStrv,
|
||||
ExprTicket, Expression, ExtHostReq, FormattingUnit, HostExtNotif, HostExtReq, OrcResult, SysId,
|
||||
TStrv,
|
||||
};
|
||||
|
||||
pub type AtomData = Vec<u8>;
|
||||
@@ -117,14 +118,14 @@ pub struct AtomDrop(pub SysId, pub AtomId);
|
||||
#[extends(AtomReq, HostExtReq)]
|
||||
pub struct AtomPrint(pub Atom);
|
||||
impl Request for AtomPrint {
|
||||
type Response = String;
|
||||
type Response = FormattingUnit;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, Coding, Hierarchy)]
|
||||
#[extends(ExtHostReq)]
|
||||
pub struct ExtAtomPrint(pub Atom);
|
||||
impl Request for ExtAtomPrint {
|
||||
type Response = String;
|
||||
type Response = FormattingUnit;
|
||||
}
|
||||
|
||||
/// Requests that apply to an existing atom instance
|
||||
|
||||
20
orchid-api/src/format.rs
Normal file
20
orchid-api/src/format.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use orchid_api_derive::Coding;
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, Coding)]
|
||||
pub struct FormattingUnit {
|
||||
pub subs: Vec<FormattingUnit>,
|
||||
pub variants: Vec<FormattingVariant>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, Coding)]
|
||||
pub struct FormattingVariant {
|
||||
pub bounded: bool,
|
||||
pub elements: Vec<FormattingElement>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, Coding)]
|
||||
pub enum FormattingElement {
|
||||
Sub { slot: u32, bounded: Option<bool> },
|
||||
String(String),
|
||||
Indent(Vec<FormattingElement>),
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
mod lexer;
|
||||
pub use lexer::*;
|
||||
mod format;
|
||||
pub use format::*;
|
||||
mod macros;
|
||||
pub use macros::*;
|
||||
mod atom;
|
||||
|
||||
Reference in New Issue
Block a user