2024-08-07 14:03:33 +00:00
|
|
|
use std::fmt::Display;
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2024-08-04 00:23:52 +00:00
|
|
|
use crate::Identifier;
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
|
|
pub enum Token {
|
2024-08-05 01:31:18 +00:00
|
|
|
Comma,
|
2024-08-05 18:31:08 +00:00
|
|
|
Dot,
|
2024-08-04 00:23:52 +00:00
|
|
|
Eof,
|
|
|
|
Equal,
|
|
|
|
Identifier(Identifier),
|
2024-08-05 19:54:48 +00:00
|
|
|
ReservedIdentifier(ReservedIdentifier),
|
2024-08-05 00:08:43 +00:00
|
|
|
Integer(i64),
|
2024-08-04 00:23:52 +00:00
|
|
|
Plus,
|
|
|
|
Star,
|
|
|
|
LeftParenthesis,
|
|
|
|
RightParenthesis,
|
2024-08-05 01:31:18 +00:00
|
|
|
LeftSquareBrace,
|
|
|
|
RightSquareBrace,
|
2024-08-04 23:41:00 +00:00
|
|
|
Float(f64),
|
2024-08-04 00:23:52 +00:00
|
|
|
}
|
2024-08-05 19:54:48 +00:00
|
|
|
|
2024-08-07 14:03:33 +00:00
|
|
|
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
|
2024-08-05 19:54:48 +00:00
|
|
|
pub enum ReservedIdentifier {
|
|
|
|
IsEven,
|
|
|
|
IsOdd,
|
|
|
|
Length,
|
|
|
|
}
|
2024-08-07 14:03:33 +00:00
|
|
|
|
|
|
|
impl Display for ReservedIdentifier {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
ReservedIdentifier::IsEven => write!(f, "is_even"),
|
|
|
|
ReservedIdentifier::IsOdd => write!(f, "is_odd"),
|
|
|
|
ReservedIdentifier::Length => write!(f, "length"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|