mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FIX: Grouped Expressions store their position properly now.
This commit is contained in:
parent
561b277b24
commit
df8834dddc
@ -639,8 +639,7 @@ pub enum Expression {
|
|||||||
// Complex Expressions
|
// Complex Expressions
|
||||||
Copy(CopyDef),
|
Copy(CopyDef),
|
||||||
Range(RangeDef),
|
Range(RangeDef),
|
||||||
// TODO(jwall): This should really store it's position :-(
|
Grouped(Box<Expression>, Position),
|
||||||
Grouped(Box<Expression>),
|
|
||||||
Format(FormatDef),
|
Format(FormatDef),
|
||||||
Include(IncludeDef),
|
Include(IncludeDef),
|
||||||
Import(ImportDef),
|
Import(ImportDef),
|
||||||
@ -662,7 +661,7 @@ impl Expression {
|
|||||||
&Expression::Binary(ref def) => &def.pos,
|
&Expression::Binary(ref def) => &def.pos,
|
||||||
&Expression::Copy(ref def) => &def.pos,
|
&Expression::Copy(ref def) => &def.pos,
|
||||||
&Expression::Range(ref def) => &def.pos,
|
&Expression::Range(ref def) => &def.pos,
|
||||||
&Expression::Grouped(ref expr) => expr.pos(),
|
&Expression::Grouped(_, ref pos) => pos,
|
||||||
&Expression::Format(ref def) => &def.pos,
|
&Expression::Format(ref def) => &def.pos,
|
||||||
&Expression::Call(ref def) => &def.pos,
|
&Expression::Call(ref def) => &def.pos,
|
||||||
&Expression::Func(ref def) => &def.pos,
|
&Expression::Func(ref def) => &def.pos,
|
||||||
@ -695,7 +694,7 @@ impl fmt::Display for Expression {
|
|||||||
&Expression::Range(_) => {
|
&Expression::Range(_) => {
|
||||||
write!(w, "<Range>")?;
|
write!(w, "<Range>")?;
|
||||||
}
|
}
|
||||||
&Expression::Grouped(_) => {
|
&Expression::Grouped(_, _) => {
|
||||||
write!(w, "(<Expr>)")?;
|
write!(w, "(<Expr>)")?;
|
||||||
}
|
}
|
||||||
&Expression::Format(_) => {
|
&Expression::Format(_) => {
|
||||||
|
@ -91,7 +91,7 @@ impl<'a> AstWalker<'a> {
|
|||||||
self.walk_expression(def.left.as_mut());
|
self.walk_expression(def.left.as_mut());
|
||||||
self.walk_expression(def.right.as_mut());
|
self.walk_expression(def.right.as_mut());
|
||||||
}
|
}
|
||||||
Expression::Grouped(ref mut expr) => {
|
Expression::Grouped(ref mut expr, _) => {
|
||||||
self.walk_expression(expr);
|
self.walk_expression(expr);
|
||||||
}
|
}
|
||||||
Expression::Func(ref mut def) => self.walk_expression(def.fields.as_mut()),
|
Expression::Func(ref mut def) => self.walk_expression(def.fields.as_mut()),
|
||||||
|
@ -1905,7 +1905,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
&Expression::Binary(ref def) => self.eval_binary(def, scope),
|
&Expression::Binary(ref def) => self.eval_binary(def, scope),
|
||||||
&Expression::Copy(ref def) => self.eval_copy(def, scope),
|
&Expression::Copy(ref def) => self.eval_copy(def, scope),
|
||||||
&Expression::Range(ref def) => self.eval_range(def, scope),
|
&Expression::Range(ref def) => self.eval_range(def, scope),
|
||||||
&Expression::Grouped(ref expr) => self.eval_expr(expr, scope),
|
&Expression::Grouped(ref expr, _) => self.eval_expr(expr, scope),
|
||||||
&Expression::Format(ref def) => self.eval_format(def, scope),
|
&Expression::Format(ref def) => self.eval_format(def, scope),
|
||||||
&Expression::Call(ref def) => self.eval_call(def, scope),
|
&Expression::Call(ref def) => self.eval_call(def, scope),
|
||||||
&Expression::Func(ref def) => {
|
&Expression::Func(ref def) => {
|
||||||
|
@ -299,20 +299,21 @@ make_fn!(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
fn expression_to_grouped_expression(e: Expression) -> Expression {
|
fn expression_to_grouped_expression(e: Expression, pos: Position) -> Expression {
|
||||||
Expression::Grouped(Box::new(e))
|
Expression::Grouped(Box::new(e), pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
make_fn!(
|
make_fn!(
|
||||||
grouped_expression<SliceIter<Token>, Expression>,
|
grouped_expression<SliceIter<Token>, Expression>,
|
||||||
do_each!(
|
do_each!(
|
||||||
|
pos => pos,
|
||||||
_ => punct!("("),
|
_ => punct!("("),
|
||||||
expr => do_each!(
|
expr => do_each!(
|
||||||
expr => trace_parse!(expression),
|
expr => trace_parse!(expression),
|
||||||
_ => must!(punct!(")")),
|
_ => must!(punct!(")")),
|
||||||
(expr)
|
(expr)
|
||||||
),
|
),
|
||||||
(expression_to_grouped_expression(expr))
|
(expression_to_grouped_expression(expr, pos))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user