mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-21 23:48:24 +00:00
fix: fix span in lalrpop
This commit is contained in:
parent
466b7687a7
commit
f71abb0b26
|
@ -85,6 +85,7 @@ pub fn lowering_error_to_report(
|
|||
.finish()
|
||||
},
|
||||
LoweringError::UnexpectedType { span, found, expected } => {
|
||||
dbg!(span);
|
||||
let mut labels = vec![
|
||||
Label::new((path.clone(), span.into()))
|
||||
.with_message(format!("Unexpected type '{}', expected '{}'", found, expected.kind))
|
||||
|
|
|
@ -479,8 +479,6 @@ fn lower_assign(builder: &mut BodyBuilder, info: &ast::AssignStmt) -> Result<(),
|
|||
kind: ty,
|
||||
};
|
||||
|
||||
dbg!("here1");
|
||||
|
||||
for _ in 0..info.deref_times {
|
||||
match &ty.kind {
|
||||
TypeKind::Ptr(is_mut, inner) => {
|
||||
|
@ -500,12 +498,8 @@ fn lower_assign(builder: &mut BodyBuilder, info: &ast::AssignStmt) -> Result<(),
|
|||
place.projection.push(PlaceElem::Deref);
|
||||
}
|
||||
|
||||
dbg!("here2");
|
||||
|
||||
let (rvalue, _ty, _span) = lower_expr(builder, &info.value, Some(&ty))?;
|
||||
|
||||
dbg!("here3");
|
||||
|
||||
builder.statements.push(Statement {
|
||||
span: Some(info.name.first.span),
|
||||
kind: StatementKind::Assign(place, rvalue),
|
||||
|
|
|
@ -348,34 +348,34 @@ pub(crate) Expression: ast::Expression = {
|
|||
}
|
||||
|
||||
pub BinaryFirstLvlOp: ast::BinaryOp = {
|
||||
<lo:@L> "==" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Eq, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "!=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::NotEq, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "<" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Lt, ast::Span::new(hi, lo)),
|
||||
<lo:@L> ">" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Gt, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "<=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::LtEq, ast::Span::new(hi, lo)),
|
||||
<lo:@L> ">=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::GtEq, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "&&" <hi:@R> => ast::BinaryOp::Logic(ast::LogicOp::And, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "||" <hi:@R> => ast::BinaryOp::Logic(ast::LogicOp::Or, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "==" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Eq, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "!=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::NotEq, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "<" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Lt, ast::Span::new(lo, hi)),
|
||||
<lo:@L> ">" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::Gt, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "<=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::LtEq, ast::Span::new(lo, hi)),
|
||||
<lo:@L> ">=" <hi:@R> => ast::BinaryOp::Compare(ast::CmpOp::GtEq, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "&&" <hi:@R> => ast::BinaryOp::Logic(ast::LogicOp::And, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "||" <hi:@R> => ast::BinaryOp::Logic(ast::LogicOp::Or, ast::Span::new(lo, hi)),
|
||||
}
|
||||
|
||||
pub BinarySecondLvlOp: ast::BinaryOp = {
|
||||
<lo:@L> "/" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Div, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "*" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Mul, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "%" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Mod, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "/" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Div, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "*" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Mul, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "%" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Mod, ast::Span::new(lo, hi)),
|
||||
}
|
||||
|
||||
pub BinaryThirdLvlOp: ast::BinaryOp = {
|
||||
<lo:@L> "+" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Add, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "-" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Sub, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "&" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::And, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "|" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::Or, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "^" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::Xor, ast::Span::new(hi, lo)),
|
||||
<lo:@L> "+" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Add, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "-" <hi:@R> => ast::BinaryOp::Arith(ast::ArithOp::Sub, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "&" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::And, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "|" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::Or, ast::Span::new(lo, hi)),
|
||||
<lo:@L> "^" <hi:@R> => ast::BinaryOp::Bitwise(ast::BitwiseOp::Xor, ast::Span::new(lo, hi)),
|
||||
}
|
||||
|
||||
pub UnaryOp: ast::UnaryOp = {
|
||||
<lo:@L> "-" <hi:@R> => ast::UnaryOp::ArithNeg(ast::Span::new(hi, lo)),
|
||||
<lo:@L> "!" <hi:@R> => ast::UnaryOp::LogicalNot(ast::Span::new(hi, lo)),
|
||||
<lo:@L> "~" <hi:@R> => ast::UnaryOp::BitwiseNot(ast::Span::new(hi, lo)),
|
||||
<lo:@L> "-" <hi:@R> => ast::UnaryOp::ArithNeg(ast::Span::new(lo, hi)),
|
||||
<lo:@L> "!" <hi:@R> => ast::UnaryOp::LogicalNot(ast::Span::new(lo, hi)),
|
||||
<lo:@L> "~" <hi:@R> => ast::UnaryOp::BitwiseNot(ast::Span::new(lo, hi)),
|
||||
}
|
||||
|
||||
pub(crate) ValueExpr: ast::ValueExpr = {
|
||||
|
|
Loading…
Reference in a new issue