Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
660 changes: 526 additions & 134 deletions README.md

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions docs/spec/characters.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ Symbol | Use
`=` | Structurally equal
`!=` | Structurally not equal

## Binary operators

Symbol | Use
---|---
`&&` | And operator
`||` | Or operator
`!|` | Exclusive or operator
`!!` | Negation operator
`<<` | Left shift
`>>` | Right shift

## Assignment and Functions

Symbol | Use
Expand All @@ -76,8 +65,6 @@ Symbol | Use
`*=` | Multiply value with variable and assign to variable
`/=` | Divide variable by value and assign to variable
`^=` | Raise variable by value and assign to variable
`>>=` | Binary shift variable to the right by value
`<<=` | Binary shift variable to the left by value

## Context Dependent

Expand Down
4 changes: 0 additions & 4 deletions src/check/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,6 @@ pub enum NodeTy {
Sqrt {
expr: Box<ASTTy>,
},
BAnd {
left: Box<ASTTy>,
right: Box<ASTTy>,
},
BOr {
left: Box<ASTTy>,
right: Box<ASTTy>,
Expand Down
23 changes: 0 additions & 23 deletions src/check/ast/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,6 @@ impl From<(&Node, &Finished)> for NodeTy {
Node::Sqrt { expr } => NodeTy::Sqrt {
expr: Box::from(ASTTy::from((expr, finished))),
},
Node::BAnd { left, right } => NodeTy::BAnd {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
},
Node::BOr { left, right } => NodeTy::BOr {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
},
Node::BXOr { left, right } => NodeTy::BXOr {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
},
Node::BOneCmpl { expr } => NodeTy::BOneCmpl {
expr: Box::from(ASTTy::from((expr, finished))),
},
Node::BLShift { left, right } => NodeTy::BLShift {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
},
Node::BRShift { left, right } => NodeTy::BRShift {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
},
Node::Le { left, right } => NodeTy::Le {
left: Box::from(ASTTy::from((left, finished))),
right: Box::from(ASTTy::from((right, finished))),
Expand Down
8 changes: 0 additions & 8 deletions src/check/constrain/generate/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,6 @@ fn reassign_op(
left: left.clone(),
right,
},
NodeOp::BLShift => Node::BLShift {
left: left.clone(),
right,
},
NodeOp::BRShift => Node::BRShift {
left: left.clone(),
right,
},
other => {
let msg = format!("Cannot reassign using operator '{other}'");
return Err(vec![TypeErr::new(ast.pos, &msg)]);
Expand Down
4 changes: 0 additions & 4 deletions src/check/constrain/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ pub fn generate(
AddU { .. } | SubU { .. } => gen_op(ast, env, ctx, constr),
Sqrt { .. } => gen_op(ast, env, ctx, constr),

BOneCmpl { .. } => gen_op(ast, env, ctx, constr),
BAnd { .. } | BOr { .. } | BXOr { .. } => gen_op(ast, env, ctx, constr),
BLShift { .. } | BRShift { .. } => gen_op(ast, env, ctx, constr),

Is { .. } | IsN { .. } | IsA { .. } | IsNA { .. } => gen_op(ast, env, ctx, constr),
And { .. } | Or { .. } | Not { .. } => gen_op(ast, env, ctx, constr),

Expand Down
46 changes: 0 additions & 46 deletions src/check/constrain/generate/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,52 +92,6 @@ pub fn gen_op(
generate(expr, env, ctx, constr)
}

Node::BOneCmpl { expr } => {
constr.add(
"binary compliment",
&Expected::from(expr),
&Expected::any(expr.pos),
env,
);
generate(expr, env, ctx, constr)?;
Ok(env.clone())
}
Node::BAnd { left, right } | Node::BOr { left, right } | Node::BXOr { left, right } => {
constr.add(
"binary logical op",
&Expected::from(left),
&Expected::any(left.pos),
env,
);
constr.add(
"binary logical op",
&Expected::from(right),
&Expected::any(right.pos),
env,
);

bin_op(left, right, env, ctx, constr)
}
Node::BLShift { left, right } | Node::BRShift { left, right } => {
constr.add(
"binary shift",
&Expected::from(left),
&Expected::any(right.pos),
env,
);

let name = Name::from(INT);
let l_exp = Expected::from(right);
constr.add(
"binary shift",
&l_exp,
&Expected::new(right.pos, &Type { name }),
env,
);

bin_op(left, right, env, ctx, constr)
}

Node::Is { left, right } | Node::IsN { left, right } => {
let bool = Expected::new(
ast.pos,
Expand Down
37 changes: 0 additions & 37 deletions src/generate/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,43 +388,6 @@ fn to_py(core: &Core, ind: usize) -> String {
}
Core::Sqrt { expr } => format!("math.sqrt({})", to_py(expr.as_ref(), ind)),

Core::BAnd { left, right } => {
format!(
"{} & {}",
to_py(left.as_ref(), ind),
to_py(right.as_ref(), ind)
)
}
Core::BOr { left, right } => {
format!(
"{} | {}",
to_py(left.as_ref(), ind),
to_py(right.as_ref(), ind)
)
}
Core::BXOr { left, right } => {
format!(
"{} ^ {}",
to_py(left.as_ref(), ind),
to_py(right.as_ref(), ind)
)
}
Core::BOneCmpl { expr } => format!("~{}", to_py(expr, ind)),
Core::BLShift { left, right } => {
format!(
"{} << {}",
to_py(left.as_ref(), ind),
to_py(right.as_ref(), ind)
)
}
Core::BRShift { left, right } => {
format!(
"{} >> {}",
to_py(left.as_ref(), ind),
to_py(right.as_ref(), ind)
)
}

Core::Return { expr } => format!("return {}", to_py(expr.as_ref(), ind)),

Core::For { expr, col, body } => format!(
Expand Down
29 changes: 0 additions & 29 deletions src/generate/ast/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,29 +209,6 @@ pub enum Core {
Sqrt {
expr: Box<Core>,
},
BAnd {
left: Box<Core>,
right: Box<Core>,
},
BOr {
left: Box<Core>,
right: Box<Core>,
},
BXOr {
left: Box<Core>,
right: Box<Core>,
},
BOneCmpl {
expr: Box<Core>,
},
BLShift {
left: Box<Core>,
right: Box<Core>,
},
BRShift {
left: Box<Core>,
right: Box<Core>,
},
For {
expr: Box<Core>,
col: Box<Core>,
Expand Down Expand Up @@ -316,8 +293,6 @@ pub enum CoreOp {
MulAssign,
DivAssign,
PowAssign,
BLShiftAssign,
BRShiftAssign,
}

impl TryFrom<(&ASTTy, &NodeOp)> for CoreOp {
Expand All @@ -330,8 +305,6 @@ impl TryFrom<(&ASTTy, &NodeOp)> for CoreOp {
NodeOp::Mul => Ok(CoreOp::MulAssign),
NodeOp::Div => Ok(CoreOp::DivAssign),
NodeOp::Pow => Ok(CoreOp::PowAssign),
NodeOp::BLShift => Ok(CoreOp::BLShiftAssign),
NodeOp::BRShift => Ok(CoreOp::BRShiftAssign),
NodeOp::Assign => Ok(CoreOp::Assign),
op => Err(UnimplementedErr::new(ast, &format!("Reassign with {op}"))),
}
Expand Down Expand Up @@ -388,8 +361,6 @@ impl Display for CoreOp {
CoreOp::MulAssign => "*=",
CoreOp::DivAssign => "/=",
CoreOp::PowAssign => "**=",
CoreOp::BLShiftAssign => "<<=",
CoreOp::BRShiftAssign => ">>=",
}
)
}
Expand Down
24 changes: 0 additions & 24 deletions src/generate/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,6 @@ pub fn convert_node(ast: &ASTTy, imp: &mut Imports, state: &State, ctx: &Context
right: Box::from(convert_node(right, imp, state, ctx)?),
},

NodeTy::BAnd { left, right } => Core::BAnd {
left: Box::from(convert_node(left, imp, state, ctx)?),
right: Box::from(convert_node(right, imp, state, ctx)?),
},
NodeTy::BOr { left, right } => Core::BOr {
left: Box::from(convert_node(left, imp, state, ctx)?),
right: Box::from(convert_node(right, imp, state, ctx)?),
},
NodeTy::BXOr { left, right } => Core::BXOr {
left: Box::from(convert_node(left, imp, state, ctx)?),
right: Box::from(convert_node(right, imp, state, ctx)?),
},
NodeTy::BOneCmpl { expr } => Core::BOneCmpl {
expr: Box::from(convert_node(expr, imp, state, ctx)?),
},
NodeTy::BLShift { left, right } => Core::BLShift {
left: Box::from(convert_node(left, imp, state, ctx)?),
right: Box::from(convert_node(right, imp, state, ctx)?),
},
NodeTy::BRShift { left, right } => Core::BRShift {
left: Box::from(convert_node(left, imp, state, ctx)?),
right: Box::from(convert_node(right, imp, state, ctx)?),
},

NodeTy::AddU { expr } => Core::AddU {
expr: Box::from(convert_node(expr, imp, state, ctx)?),
},
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ impl From<&Arguments> for PipelineArguments {
///
/// For each mamba source, a path can optionally be given for display in error
/// messages. This path is not necessary however.
#[allow(clippy::result_large_err)]
pub fn mamba_to_python(
source: &[(String, Option<PathBuf>)],
source_dir: &PathBuf,
Expand All @@ -154,7 +153,7 @@ pub fn mamba_to_python(
.iter()
.map(|(src, path)| {
src.parse::<AST>()
.map_err(|err| err.with_source(&Some(src.clone()), &path.clone()))
.map_err(|err| Box::new(err.with_source(&Some(src.clone()), &path.clone())))
})
.partition(Result::is_ok);

Expand Down
23 changes: 0 additions & 23 deletions src/parse/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,29 +250,6 @@ pub enum Node {
Sqrt {
expr: Box<AST>,
},
BAnd {
left: Box<AST>,
right: Box<AST>,
},
BOr {
left: Box<AST>,
right: Box<AST>,
},
BXOr {
left: Box<AST>,
right: Box<AST>,
},
BOneCmpl {
expr: Box<AST>,
},
BLShift {
left: Box<AST>,
right: Box<AST>,
},
BRShift {
left: Box<AST>,
right: Box<AST>,
},
Le {
left: Box<AST>,
right: Box<AST>,
Expand Down
Loading
Loading