pomsky_syntax/exprs/
negation.rs

1use crate::Span;
2
3use super::Rule;
4
5#[derive(Debug, Clone)]
6#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7pub struct Negation {
8    pub rule: Rule,
9    pub not_span: Span,
10}
11
12impl Negation {
13    #[cfg(feature = "dbg")]
14    pub(super) fn pretty_print(&self, buf: &mut crate::PrettyPrinter, needs_parens: bool) {
15        buf.push('!');
16        if needs_parens {
17            buf.start_indentation("(");
18        }
19
20        self.rule.pretty_print(buf, false);
21
22        if needs_parens {
23            buf.end_indentation(")");
24        }
25    }
26}