Skip to content

Commit 50ff268

Browse files
committed
Fix for Dot and Sequence operators
1 parent 03f2c2f commit 50ff268

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

takolib/src/ast/pretty_printer.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,20 @@ mod tests {
333333
Ok(())
334334
}
335335

336+
#[test]
337+
fn round_trip_dot_operator() -> Result<(), TError> {
338+
let out = setup("x.y.z")?;
339+
assert_eq!(out, "(x.y).z");
340+
Ok(())
341+
}
342+
343+
#[test]
344+
fn round_trip_dot_operator_with_calls() -> Result<(), TError> {
345+
let out = setup("x(a).y(b).z(c)")?;
346+
assert_eq!(out, "(x(a).y(b)).z(c)");
347+
Ok(())
348+
}
349+
336350
#[test]
337351
fn round_trip_lambda_with_args() -> Result<(), TError> {
338352
let out = setup("(x->x)(x=2*3)")?;

takolib/src/parser/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ fn make_tables() -> Result<ParserConfigTable, ()> {
222222
for op in MATHEMATICAL {
223223
config[*op as usize].infix();
224224
}
225+
config[Symbol::Sequence as usize].right();
225226
config[Symbol::Exp as usize].right();
226227
for op in PREFIX_BIT {
227228
config[*op as usize].prefix();
@@ -270,8 +271,9 @@ fn make_tables() -> Result<ParserConfigTable, ()> {
270271
DoubleArrow, Add, Sub, Div, Mul, Exp, Sub /*Neg*/, HasType,
271272
Eqs, NotEqs, Lt, LtEqs, Gt, GtEqs,
272273
Sigma, Lambda, Forall, Pi, Exists,
273-
CloseParen, // TODO: Add all
274-
OpenParen, NumberLit, ColorLit, StringLit, Ident,
274+
Dot,
275+
OpenParen, OpenBracket, OpenCurly, NumberLit, ColorLit, StringLit, Ident,
276+
CloseParen, CloseBracket, CloseCurly, // TODO: Add all
275277
],
276278
})
277279
}

0 commit comments

Comments
 (0)