use num_rational::Ratio;
use crate::diag::Span;
#[derive(Debug, Clone, PartialEq)]
pub struct SpannedToken {
pub token: Token,
pub span: Span,
pub preceded_by_ws: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Eof,
Number {
text: String,
value: Ratio<i128>,
},
Ident(String),
Feet {
inches: Ratio<i128>,
},
Inches {
inches: Ratio<i128>,
},
FtIn {
inches: Ratio<i128>,
},
Plus,
Minus,
Star,
Slash,
Caret,
LParen,
RParen,
Comma,
Eq,
Dot,
UnitMul,
ColonColon,
Colon,
Gte,
Lte,
Gt,
Lt,
EqEq,
}
impl Token {
pub fn is_length_literal(&self) -> bool {
matches!(self, Self::Feet { .. } | Self::Inches { .. } | Self::FtIn { .. })
}
}