diff --git a/parser/src/lib.rs b/parser/src/lib.rs index a5fda42..036e8cc 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -293,22 +293,10 @@ impl From> 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::().unwrap(); - Expression::IntLiteral(value) - } - Rule::float => { - let value = pair.as_str().parse::().unwrap(); - Expression::FloatLiteral(value) - } - Rule::boolean => { - let value = pair.as_str().parse::().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::().unwrap()), + Rule::float => Expression::FloatLiteral(pair.as_str().parse::().unwrap()), + Rule::boolean => Expression::BoolLiteral(pair.as_str().parse::().unwrap()), + Rule::string_lit => Expression::StringLiteral(inner.as_str().to_string()), Rule::tuple => Expression::TupleLiteral(inner.map(Expression::from).collect()), _ => unimplemented!("{rule:#?}"), } diff --git a/src/codegen.rs b/src/codegen.rs index a288066..db79b79 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -112,7 +112,7 @@ impl GetRust for Expression { Expression::IntLiteral(n) => n.to_string(), Expression::FloatLiteral(n) => n.to_string(), Expression::BoolLiteral(b) => b.to_string(), - Expression::StringLiteral(s) => format!("\"{}\".to_string()", s), + Expression::StringLiteral(s) => format!("\"{s}\""), Expression::TupleLiteral(t) => { format!( "({})", diff --git a/test/src/main.mist b/test/src/main.mist index 6ae3431..f5c3828 100644 --- a/test/src/main.mist +++ b/test/src/main.mist @@ -1,3 +1,3 @@ void main() { - (i32, i32) = (10, 20); + (i32, i32, str*) my_tuple = (10, 20, "hello, world"); } \ No newline at end of file