///|
/// Logical negation operator in a parsed plural expression.
/// Example: `@plural.parse_expr("!n")`.
#derive(Eq, @debug.Debug)
pub enum UnaryOp {
  LogicalNot
}

///|
/// Syntax tree for a GNU integer plural expression over n.
/// Example: `@plural.parse_expr("n != 1")`.
#derive(Eq, @debug.Debug)
pub enum PluralExpr {
  VarN
  Literal(UInt64)
  Unary(UnaryOp, PluralExpr)
  Binary(BinaryOp, PluralExpr, PluralExpr)
  Ternary(PluralExpr, PluralExpr, PluralExpr)
}

///|
/// Compiled expression, its source and the declared number of translation forms.
/// Example: `cat.plural_rule().nplurals`.
#derive(Eq, @debug.Debug)
pub struct PluralRule {
  nplurals : Int32
  expr : PluralExpr
  source : String
}

///|
/// Write the diagnostic representation of UnaryOp to a logger.
/// Example: `value.to_string()`.
pub impl Show for UnaryOp with fn output(self, logger) {
  logger.write_string(@debug.to_string(self))
}

///|
/// Write the diagnostic representation of PluralExpr to a logger.
/// Example: `value.to_string()`.
pub impl Show for PluralExpr with fn output(self, logger) {
  logger.write_string(@debug.to_string(self))
}

///|
/// Write the diagnostic representation of PluralRule to a logger.
/// Example: `value.to_string()`.
pub impl Show for PluralRule with fn output(self, logger) {
  logger.write_string(@debug.to_string(self))
}