Skip to content
Snippets Groups Projects

Scheduler additions

Merged Aaron Councilman requested to merge scheduler-additions into main
1 file
+ 13
4
Compare changes
  • Side-by-side
  • Inline
+ 35
9
@@ -6,6 +6,9 @@
%left '\\'
%left '|'
%left '&'
%left '||'
%left '&&'
%right '!'
%left '.' '@'
%%
@@ -27,14 +30,23 @@ Stmt -> Stmt
{ Stmt::ExprStmt { span: $span, exp: $1 } }
| 'fixpoint' FixpointLimit '{' Schedule '}'
{ Stmt::Fixpoint { span: $span, limit: $2, body: Box::new($4) } }
| 'if' Expr '{' Schedule '}'
{ Stmt::IfThenElse { span: $span, cond: $2, thn: Box::new($4), els: None } }
| 'if' Expr '{' Schedule '}' 'else' '{' Schedule '}'
{ Stmt::IfThenElse { span: $span, cond: $2, thn: Box::new($4), els: Some(Box::new($8)) } }
| 'if' Expr '{' Schedule '}' ElseStmt
{ Stmt::IfThenElse { span: $span, cond: $2, thn: Box::new($4), els: $6 } }
| MacroDecl
{ Stmt::MacroDecl { span: $span, def: $1 } }
;
ElseStmt -> Option<Box<OperationList>>
: { None }
| 'else' '{' Schedule '}'
{ Some(Box::new($3)) }
| 'else' 'if' Expr '{' Schedule '}' ElseStmt
{ Some(Box::new(OperationList::ConsStmt(
Stmt::IfThenElse { span: $span, cond: $3, thn: Box::new($5), els: $7 },
Box::new(OperationList::NilStmt()),
))) }
;
FixpointLimit -> FixpointLimit
: { FixpointLimit::NoLimit { span: $span } }
| 'stop_after' 'INT'
@@ -75,11 +87,17 @@ Expr -> Expr
| '<' Fields '>'
{ Expr::Record { span: $span, fields: rev($2) } }
| Expr '\\' Expr
{ Expr::SetOp { span: $span, op: SetOp::Difference, lhs: Box::new($1), rhs: Box::new($3) } }
{ Expr::BinaryOp { span: $span, op: BinaryOp::Difference, lhs: Box::new($1), rhs: Box::new($3) } }
| Expr '|' Expr
{ Expr::SetOp { span: $span, op: SetOp::Union, lhs: Box::new($1), rhs: Box::new($3) } }
{ Expr::BinaryOp { span: $span, op: BinaryOp::Union, lhs: Box::new($1), rhs: Box::new($3) } }
| Expr '&' Expr
{ Expr::SetOp { span: $span, op: SetOp::Intersection, lhs: Box::new($1), rhs: Box::new($3) } }
{ Expr::BinaryOp { span: $span, op: BinaryOp::Intersection, lhs: Box::new($1), rhs: Box::new($3) } }
| '!' Expr
{ Expr::UnaryOp { span: $span, op: UnaryOp::Not, exp: Box::new($2) } }
| Expr '||' Expr
{ Expr::BinaryOp { span: $span, op: BinaryOp::Or, lhs: Box::new($1), rhs: Box::new($3) } }
| Expr '&&' Expr
{ Expr::BinaryOp { span: $span, op: BinaryOp::And, lhs: Box::new($1), rhs: Box::new($3) } }
;
Args -> Vec<Expr>
@@ -179,10 +197,17 @@ pub enum FixpointLimit {
}
#[derive(Copy, Clone, Debug)]
pub enum SetOp {
pub enum UnaryOp {
Not,
}
#[derive(Copy, Clone, Debug)]
pub enum BinaryOp {
Difference,
Union,
Intersection,
Or,
And,
}
pub enum Expr {
@@ -195,7 +220,8 @@ pub enum Expr {
Field { span: Span, lhs: Box<Expr>, field: Span },
BlockExpr { span: Span, body: Box<OperationList> },
Record { span: Span, fields: Vec<(Span, Expr)> },
SetOp { span: Span, op: SetOp, lhs: Box<Expr>, rhs: Box<Expr> },
UnaryOp { span: Span, op: UnaryOp, exp: Box<Expr> },
BinaryOp { span: Span, op: BinaryOp, lhs: Box<Expr>, rhs: Box<Expr> },
Tuple { span: Span, exps: Vec<Expr> },
TupleField { span: Span, lhs: Box<Expr>, field: Span },
}
Loading