leo_input/types/
signed_integer_type.rs1use crate::ast::Rule;
18
19use pest_ast::FromPest;
20use std::fmt;
21
22#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
23#[pest_ast(rule(Rule::type_integer_signed))]
24pub enum SignedIntegerType {
25 I8Type(I8Type),
26 I16Type(I16Type),
27 I32Type(I32Type),
28 I64Type(I64Type),
29 I128Type(I128Type),
30}
31
32#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
33#[pest_ast(rule(Rule::type_i8))]
34pub struct I8Type {}
35
36#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
37#[pest_ast(rule(Rule::type_i16))]
38pub struct I16Type {}
39
40#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
41#[pest_ast(rule(Rule::type_i32))]
42pub struct I32Type {}
43
44#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
45#[pest_ast(rule(Rule::type_i64))]
46pub struct I64Type {}
47
48#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
49#[pest_ast(rule(Rule::type_i128))]
50pub struct I128Type {}
51
52impl fmt::Display for SignedIntegerType {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 match self {
55 SignedIntegerType::I8Type(_) => write!(f, "i8"),
56 SignedIntegerType::I16Type(_) => write!(f, "i16"),
57 SignedIntegerType::I32Type(_) => write!(f, "i32"),
58 SignedIntegerType::I64Type(_) => write!(f, "i64"),
59 SignedIntegerType::I128Type(_) => write!(f, "i128"),
60 }
61 }
62}