E-graph implementation in MoonBit
pub(all) suberror ParseError {
UnexpectedEof
UnexpectedChar(Int, Char)
ExpectedRParen(Int)
}impl Show for ParseErrorpub struct ExplainStep {
iter : Int
rewrite : String
root_before : Int
rhs_id : Int
subst : Map[String, Int]
}impl Show for ExplainSteppub enum Instruction {
Bind(NodeOp, Int, Int, Int)
Compare(Int, Int)
Lookup(Array[ENodeOrReg], Int)
Scan(Int)
}type NodeKeypub enum NodeOp {
Name(String)
Symbol(String)
Number(Float)
}pub struct Program {
instructions : Array[Instruction]
subst : Map[String, Int]
var_if : Map[String, (Int) -> Bool]
}fn Rewrite::apply_all_stats(self : Rewrite, egraph : EGraph, on_applied? : (Match, Int) -> Unit) -> RewriteStats raisepub struct RunConfig {
iter_limit : Int
node_limit : Int?
match_limit : Int?
worklist : Worklist
allow_ematching_cycles : Bool
}pub struct RunResult {
egraph : EGraph
root : Int
iterations : Int
stop_reason : StopReason
applied : Map[String, Int]
total_applied : Int
reports : Array[IterationReport]
explanation : Explanation
}pub enum StopReason {
Saturated
IterationLimit
NodeLimit
MatchLimit
}type TodoKeypub(all) enum Value {
Num(Float)
Bool(Bool)
}pub(all) enum Worklist {
All
Queue
Backoff
Greedy
Recent
}E-graph implementation in MoonBit