Skip to content

Commit

Permalink
Merge pull request #90 from NLnetLabs/let-bindings
Browse files Browse the repository at this point in the history
Replace define & apply with let bindings
  • Loading branch information
tertsdiepraam authored Jan 17, 2025
2 parents fd1c1cb + acc2c5a commit b7fdbb4
Show file tree
Hide file tree
Showing 14 changed files with 473 additions and 617 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roto"
version.workspace = true
version.workspace = true
edition.workspace = true
authors.workspace = true
rust-version.workspace = true
Expand Down Expand Up @@ -38,6 +38,7 @@ rev = "1af294ea2d6c18c5a8fa9b4f272398b7c98e0c48"
[dev-dependencies]
bytes = "1"
routecore = { version = "0.5", features = ["bgp", "bmp", "serde"] }
tabled = { version = "0.17.0", default-features = false, features = ["std"] }

[profile.profiling]
inherits = "release"
Expand Down
19 changes: 10 additions & 9 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ pub struct FilterMap {
pub filter_type: FilterType,
pub ident: Meta<Identifier>,
pub params: Meta<Params>,
pub body: FilterMapBody,
}

#[derive(Clone, Debug)]
pub struct FilterMapBody {
pub define: Vec<(Meta<Identifier>, Meta<Expr>)>,
pub apply: Meta<Block>,
pub block: Meta<Block>,
}

/// A function declaration, including the [`Block`] forming its definition
Expand All @@ -64,13 +58,20 @@ pub struct FunctionDeclaration {
pub body: Meta<Block>,
}

/// A block of multiple Roto expressions
/// A block of multiple statements
#[derive(Clone, Debug)]
pub struct Block {
pub exprs: Vec<Meta<Expr>>,
pub stmts: Vec<Meta<Stmt>>,
pub last: Option<Box<Meta<Expr>>>,
}

/// A statement in a block
#[derive(Clone, Debug)]
pub enum Stmt {
Let(Meta<Identifier>, Meta<Expr>),
Expr(Meta<Expr>),
}

/// A Roto expression
#[derive(Clone, Debug)]
pub enum Expr {
Expand Down
Loading

0 comments on commit b7fdbb4

Please sign in to comment.