xshade_parser/ast/expressions/
literal_expression.rs

1use ::ast::*;
2
3#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
4pub struct LiteralExpression {
5    pub span: Span,
6    pub value: String,
7    pub literal_expression_type: LiteralType,
8}
9
10impl Spanned for LiteralExpression {
11    fn get_span(&self) -> Span {
12        self.span
13    }
14}
15
16impl Execute for LiteralExpression {
17    fn execute(&self) -> Option<i32> {
18        match self.literal_expression_type {
19            LiteralType::Int => Some(self.value.parse::<i32>().unwrap()),
20            _ => None,
21        }
22    }
23}