Skip to content

Commit

Permalink
add rule to postprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopedraza committed Apr 12, 2024
1 parent d458e8f commit fc8bf5b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn postprocess(node: ASTNode) -> ASTNode {
match node {
ASTNode::Infix(InfixOperator::Correspondence, params, proc) => function(*params, *proc),
ASTNode::Infix(InfixOperator::Call, called, args) => call(*called, *args),
ASTNode::Infix(op, lhs, rhs) => infix(op, lhs, rhs),
ASTNode::For(ident, iter, proc) => {
ASTNode::For(ident, postprocessed_box(iter), postprocessed_vec(proc))
}
Expand All @@ -39,6 +40,10 @@ pub fn postprocess(node: ASTNode) -> ASTNode {
}
}

fn infix(op: InfixOperator, lhs: Box<ASTNode>, rhs: Box<ASTNode>) -> ASTNode {
ASTNode::Infix(op, postprocessed_box(lhs), postprocessed_box(rhs))
}

fn call(called_node: ASTNode, args_node: ASTNode) -> ASTNode {
let called = postprocess(called_node);
let args = match postprocess(args_node) {
Expand Down

0 comments on commit fc8bf5b

Please sign in to comment.