forked from Orchid/orchid
Lexer test mode works
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
use orchid_api::tree::{Placeholder, PlaceholderKind};
|
||||
use std::fmt::Display;
|
||||
|
||||
use orchid_api::tree::{Paren, Placeholder, PlaceholderKind};
|
||||
|
||||
use crate::interner::{deintern, Tok};
|
||||
|
||||
pub const PARENS: &[(char, char, Paren)] =
|
||||
&[('(', ')', Paren::Round), ('[', ']', Paren::Square), ('{', '}', Paren::Curly)];
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OwnedPh {
|
||||
pub name: Tok<String>,
|
||||
@@ -13,3 +18,16 @@ impl OwnedPh {
|
||||
}
|
||||
pub fn from_api(ph: Placeholder) -> Self { Self { name: deintern(ph.name), kind: ph.kind } }
|
||||
}
|
||||
|
||||
impl Display for OwnedPh {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.kind {
|
||||
PlaceholderKind::Name => write!(f, "$_{}", self.name),
|
||||
PlaceholderKind::Scalar => write!(f, "${}", self.name),
|
||||
PlaceholderKind::Vector { nz: false, prio: 0 } => write!(f, "..${}", self.name),
|
||||
PlaceholderKind::Vector { nz: true, prio: 0 } => write!(f, "...${}", self.name),
|
||||
PlaceholderKind::Vector { nz: false, prio } => write!(f, "..${}:{prio}", self.name),
|
||||
PlaceholderKind::Vector { nz: true, prio } => write!(f, "...${}:{prio}", self.name),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user