Small refactors
This commit is contained in:
+4
-16
@@ -293,22 +293,10 @@ impl From<pest::iterators::Pair<'_, Rule>> for Expression {
|
||||
}
|
||||
Rule::primary => Expression::from(inner.next().unwrap()),
|
||||
Rule::static_path => Expression::Path(StaticPath::from(pair)),
|
||||
Rule::integer => {
|
||||
let value = pair.as_str().parse::<i64>().unwrap();
|
||||
Expression::IntLiteral(value)
|
||||
}
|
||||
Rule::float => {
|
||||
let value = pair.as_str().parse::<f64>().unwrap();
|
||||
Expression::FloatLiteral(value)
|
||||
}
|
||||
Rule::boolean => {
|
||||
let value = pair.as_str().parse::<bool>().unwrap();
|
||||
Expression::BoolLiteral(value)
|
||||
}
|
||||
Rule::string_lit => {
|
||||
let inner_str = pair.into_inner().next().unwrap().as_str();
|
||||
Expression::StringLiteral(inner_str.to_string())
|
||||
}
|
||||
Rule::integer => Expression::IntLiteral(pair.as_str().parse::<i64>().unwrap()),
|
||||
Rule::float => Expression::FloatLiteral(pair.as_str().parse::<f64>().unwrap()),
|
||||
Rule::boolean => Expression::BoolLiteral(pair.as_str().parse::<bool>().unwrap()),
|
||||
Rule::string_lit => Expression::StringLiteral(inner.as_str().to_string()),
|
||||
Rule::tuple => Expression::TupleLiteral(inner.map(Expression::from).collect()),
|
||||
_ => unimplemented!("{rule:#?}"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user