Static path expr
This commit is contained in:
+1
-1
@@ -118,7 +118,7 @@ pub struct ForStmt {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub enum Expression {
|
pub enum Expression {
|
||||||
Identifier(String),
|
Path(StaticPath),
|
||||||
IntLiteral(i64),
|
IntLiteral(i64),
|
||||||
FloatLiteral(f64),
|
FloatLiteral(f64),
|
||||||
BoolLiteral(bool),
|
BoolLiteral(bool),
|
||||||
|
|||||||
+1
-1
@@ -262,7 +262,7 @@ impl From<pest::iterators::Pair<'_, Rule>> for Expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rule::primary => Expression::from(pair.into_inner().next().unwrap()),
|
Rule::primary => Expression::from(pair.into_inner().next().unwrap()),
|
||||||
Rule::identifier => Expression::Identifier(pair.as_str().to_string()),
|
Rule::static_path => Expression::Path(StaticPath::from(pair)),
|
||||||
Rule::integer => {
|
Rule::integer => {
|
||||||
let value = pair.as_str().parse::<i64>().unwrap();
|
let value = pair.as_str().parse::<i64>().unwrap();
|
||||||
Expression::IntLiteral(value)
|
Expression::IntLiteral(value)
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ impl GetRust for TypeExpr {
|
|||||||
impl GetRust for Expression {
|
impl GetRust for Expression {
|
||||||
fn get_rust(&self) -> String {
|
fn get_rust(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Expression::Identifier(name) => name.clone(),
|
Expression::Path(path) => path.get_rust(),
|
||||||
Expression::IntLiteral(n) => n.to_string(),
|
Expression::IntLiteral(n) => n.to_string(),
|
||||||
Expression::FloatLiteral(n) => n.to_string(),
|
Expression::FloatLiteral(n) => n.to_string(),
|
||||||
Expression::BoolLiteral(b) => b.to_string(),
|
Expression::BoolLiteral(b) => b.to_string(),
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
i32 test() {
|
i32 test() {
|
||||||
|
std::fs::write();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user