pomsky_syntax/exprs/
literal.rs1use crate::Span;
2
3#[derive(Clone, PartialEq, Eq)]
4#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5pub struct Literal {
6 pub content: String,
7 pub span: Span,
8}
9
10impl Literal {
11 pub fn new(content: String, span: Span) -> Self {
12 Literal { content, span }
13 }
14
15 #[cfg(feature = "dbg")]
16 pub(super) fn pretty_print(&self, buf: &mut crate::PrettyPrinter) {
17 buf.write_debug(&self.content);
18 }
19}
20
21impl std::fmt::Debug for Literal {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 write!(f, "{:?} at {}", self.content, self.span)
24 }
25}