Skip to content

Commit

Permalink
Make cost action unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Aug 7, 2024
1 parent e8f7ead commit 35d2186
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ where
GenericAction::Change(_ann, change, lhs, args) => match change {
Change::Delete => list!("delete", list!(lhs, ++ args)),
Change::Subsume => list!("subsume", list!(lhs, ++ args)),
Change::Cost(cost) => list!("cost", list!(lhs, ++ args), cost),
Change::Cost(cost) => list!("unstable-cost", list!(lhs, ++ args), cost),
},
GenericAction::Extract(_ann, expr, variants) => list!("extract", expr, variants),
GenericAction::Panic(_ann, msg) => list!("panic", format!("\"{}\"", msg.clone())),
Expand Down
2 changes: 1 addition & 1 deletion src/ast/parse.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ NonLetAction: Action = {
<lo:LParen> "set" LParen <f: Ident> <args:Expr*> RParen <v:Expr> <hi:RParen> => Action::Set ( Span(srcfile.clone(), lo, hi), f, args, v ),
<lo:LParen> "delete" LParen <f: Ident> <args:Expr*> RParen <hi:RParen> => Action::Change ( Span(srcfile.clone(), lo, hi), Change::Delete, f, args),
<lo:LParen> "subsume" LParen <f: Ident> <args:Expr*> RParen <hi:RParen> => Action::Change ( Span(srcfile.clone(), lo, hi), Change::Subsume, f, args),
<lo:LParen> "cost" LParen <f: Ident> <args:Expr*> RParen <cost:UNum> <hi:RParen> => Action::Change ( Span(srcfile.clone(), lo, hi), Change::Cost(cost), f, args),
<lo:LParen> "unstable-cost" LParen <f: Ident> <args:Expr*> RParen <cost:UNum> <hi:RParen> => Action::Change ( Span(srcfile.clone(), lo, hi), Change::Cost(cost), f, args),
<lo:LParen> "union" <e1:Expr> <e2:Expr> <hi:RParen> => Action::Union(Span(srcfile.clone(), lo, hi), e1, e2),
<lo:LParen> "panic" <msg:String> <hi:RParen> => Action::Panic(Span(srcfile.clone(), lo, hi), msg),
<lo:LParen> "extract" <expr:Expr> <hi:RParen> => Action::Extract(Span(srcfile.clone(), lo, hi), expr, Expr::Lit(Span(srcfile.clone(), lo, hi), Literal::Int(0))),
Expand Down
6 changes: 3 additions & 3 deletions tests/extract-costfn.egg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
(union (Foo "x") (Foo "y"))
(union (Foo "y") (Foo "z"))

(cost (Foo "x") 17)
(cost (Foo "y") 11)
(cost (Foo "z") 15)
(unstable-cost (Foo "x") 17)
(unstable-cost (Foo "y") 11)
(unstable-cost (Foo "z") 15)

(extract (Foo "y"))

0 comments on commit 35d2186

Please sign in to comment.