Skip to content

Commit

Permalink
remove a bunch of fixme's
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Aug 20, 2024
1 parent dbbc3c8 commit 5c6c536
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 0 additions & 3 deletions adana-script/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,6 @@ pub fn to_ast(
Ok(TreeNodeValue::MultiDepthVariableAssign{root: *root, next_keys})

} else {
// FIXME for my future self. x.y.z or x[0][1] is not yet supported
// for assignment
// We need Primitive::Ref to make it happen
Err(anyhow::Error::msg(format!(
"AST ERROR: invalid variable expression {name:?} => {expr:?}",
)))
Expand Down
21 changes: 18 additions & 3 deletions adana-script/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,25 @@ fn parse_struct_expr(s: &str) -> Res<Value> {
))(s)
}
pub(super) fn parse_struct(s: &str) -> Res<Value> {
let pair_key_value = |p| {
use nom::character::complete::char as charParser;
let parse_key = |p| {
preceded(
multispace0,
terminated(
map(
preceded(
opt(charParser('"')),
terminated(parse_key_struct, opt(charParser('"'))),
),
String::from,
),
multispace0,
),
)(p)
};
let pair_key_value = move|p| {
separated_pair(
preceded(multispace0, terminated(map(preceded(opt(nom::character::complete::char('"')),terminated(parse_key_struct,
opt(nom::character::complete::char('"')))), String::from), multispace0)),
parse_key,
tag_no_space(":"),
preceded(opt(comments),parse_struct_expr))
}(p);
Expand Down
4 changes: 2 additions & 2 deletions adana-script/src/tests/test_chaining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn complex_struct_array_struct() {
m: 12,
y: ["hello", 3, struct {n: "world"}]
}
x = x.y[0] + " " + x.y[2]["n"] # FIXME HACKY
x = x.y[0] + " " + x.y[2]["n"]
"#;
let mut ctx = BTreeMap::new();
Expand Down Expand Up @@ -122,7 +122,7 @@ fn complex_struct_struct_struct_other() {
fn simple_array_two_depth() {
let expr = r#"
z = [0, 2, "hello", [3," ", "world"]]
x = (z[2] + z[3][1] + z[3][2]) # FIXME requires parenthesises
x = z[2] + z[3][1] + z[3][2]
"#;
let mut ctx = BTreeMap::new();
let res = compute(expr, &mut ctx, "N/A").unwrap();
Expand Down

0 comments on commit 5c6c536

Please sign in to comment.