ItemId on statement
This commit is contained in:
parent
8dc8833eb3
commit
c12cb99b24
@ -83,8 +83,11 @@ pub struct AST {
|
|||||||
pub statements: Vec<Meta<Statement>>
|
pub statements: Vec<Meta<Statement>>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Derivative, Debug, Clone)]
|
||||||
|
#[derivative(PartialEq)]
|
||||||
pub struct Statement {
|
pub struct Statement {
|
||||||
|
#[derivative(PartialEq="ignore")]
|
||||||
|
pub id: ItemId,
|
||||||
pub kind: StatementKind,
|
pub kind: StatementKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ impl Parser {
|
|||||||
Keyword(Impl) => self.impl_declaration().map(|decl| StatementKind::Declaration(decl)),
|
Keyword(Impl) => self.impl_declaration().map(|decl| StatementKind::Declaration(decl)),
|
||||||
_ => self.expression().map(|expr| { StatementKind::Expression(expr.into()) } ),
|
_ => self.expression().map(|expr| { StatementKind::Expression(expr.into()) } ),
|
||||||
}?;
|
}?;
|
||||||
Ok(Statement { kind })
|
Ok(Statement { kind, id: self.id_store.fresh() })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[recursive_descent_method]
|
#[recursive_descent_method]
|
||||||
@ -1063,7 +1063,7 @@ impl Parser {
|
|||||||
LCurlyBrace => self.block(),
|
LCurlyBrace => self.block(),
|
||||||
_ => {
|
_ => {
|
||||||
let expr = self.expression()?;
|
let expr = self.expression()?;
|
||||||
let s = Statement { kind: StatementKind::Expression(expr.into()) };
|
let s = Statement { id: self.id_store.fresh(), kind: StatementKind::Expression(expr.into()) };
|
||||||
Ok(vec![Meta::new(s)])
|
Ok(vec![Meta::new(s)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ macro_rules! tys {
|
|||||||
|
|
||||||
macro_rules! decl {
|
macro_rules! decl {
|
||||||
($expr_type:expr) => {
|
($expr_type:expr) => {
|
||||||
Statement { kind: StatementKind::Declaration($expr_type) }
|
Statement { id: ItemIdStore::new_id(), kind: StatementKind::Declaration($expr_type) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +70,10 @@ macro_rules! prefexp {
|
|||||||
($op:expr, $lhs:expr) => { PrefixExp(PrefixOp::from_str($op).unwrap(), bx!(Expression::new($lhs).into())) }
|
($op:expr, $lhs:expr) => { PrefixExp(PrefixOp::from_str($op).unwrap(), bx!(Expression::new($lhs).into())) }
|
||||||
}
|
}
|
||||||
macro_rules! exst {
|
macro_rules! exst {
|
||||||
($expr_type:expr) => { Meta::new(Statement { kind: StatementKind::Expression(Expression::new($expr_type).into())}) };
|
($expr_type:expr) => { Meta::new(Statement { id: ItemIdStore::new_id(), kind: StatementKind::Expression(Expression::new($expr_type).into())}) };
|
||||||
($expr_type:expr, $type_anno:expr) => { Meta::new(Statement { kind: StatementKind::Expression(Expression::with_anno($expr_type, $type_anno).into())}) };
|
($expr_type:expr, $type_anno:expr) => { Meta::new(Statement { id: ItemIdStore::new_id(), kind: StatementKind::Expression(Expression::with_anno($expr_type, $type_anno).into())}) };
|
||||||
($op:expr, $lhs:expr, $rhs:expr) => { Meta::new(
|
($op:expr, $lhs:expr, $rhs:expr) => { Meta::new(
|
||||||
Statement { kind: StatementKind::Expression(ex!(binexp!($op, $lhs, $rhs)))}
|
Statement { id: ItemIdStore::new_id(), ,kind: StatementKind::Expression(ex!(binexp!($op, $lhs, $rhs)))}
|
||||||
)};
|
)};
|
||||||
(s $statement_text:expr) => {
|
(s $statement_text:expr) => {
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user