add print builtin function

This commit is contained in:
2024-10-15 00:28:39 -04:00
parent 290393a62f
commit e0e33c868b
3 changed files with 60 additions and 15 deletions

View File

@@ -70,10 +70,13 @@ pub(crate) enum ParseTree {
Constant(Value),
// Type Casts
ToInt(Box<ParseTree>),
ToFloat(Box<ParseTree>),
ToBool(Box<ParseTree>),
ToString(Box<ParseTree>),
IntCast(Box<ParseTree>),
FloatCast(Box<ParseTree>),
BoolCast(Box<ParseTree>),
StringCast(Box<ParseTree>),
// Misc
Print(Box<ParseTree>),
}
impl ParseTree {
@@ -217,10 +220,11 @@ impl ParseTree {
Box::new(ParseTree::parse(tokens, globals, locals)?)
)),
Op::Not => Ok(ParseTree::Not(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::IntCast => Ok(ParseTree::ToInt(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::FloatCast => Ok(ParseTree::ToFloat(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::BoolCast => Ok(ParseTree::ToBool(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::StringCast => Ok(ParseTree::ToString(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::IntCast => Ok(ParseTree::IntCast(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::FloatCast => Ok(ParseTree::FloatCast(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::BoolCast => Ok(ParseTree::BoolCast(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::StringCast => Ok(ParseTree::StringCast(Box::new(ParseTree::parse(tokens, globals, locals)?))),
Op::Print => Ok(ParseTree::Print(Box::new(ParseTree::parse(tokens, globals, locals)?)))
}
}
}