Skip to content

Commit

Permalink
Merge pull request #66 from lambdaclass/add-salsa
Browse files Browse the repository at this point in the history
Add `salsa`.
  • Loading branch information
unbalancedparentheses authored Jan 10, 2024
2 parents 5ea7a94 + f3fe7d1 commit 538a911
Show file tree
Hide file tree
Showing 17 changed files with 340 additions and 136 deletions.
167 changes: 167 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/concrete_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing.workspace = true
tracing = { workspace = true }
4 changes: 2 additions & 2 deletions crates/concrete_ast/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::{
types::TypeSpec,
};

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ConstantDecl {
pub doc_string: Option<DocString>,
pub name: Ident,
pub r#type: TypeSpec,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ConstantDef {
pub decl: ConstantDecl,
pub value: Expression,
Expand Down
32 changes: 16 additions & 16 deletions crates/concrete_ast/src/expressions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{common::Ident, statements::Statement, types::TypeSpec};

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Expression {
Simple(SimpleExpr),
FnCall(FnCallOp),
Expand All @@ -11,32 +11,32 @@ pub enum Expression {
}

// needed for match variants and array accesses
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SimpleExpr {
ConstBool(bool),
ConstChar(char),
ConstInt(u64),
ConstFloat(f64),
ConstFloat(()),
ConstStr(String),
Path(PathOp),
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UnaryOp {
ArithNeg,
LogicalNot,
BitwiseNot,
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BinaryOp {
Arith(ArithOp),
Logic(LogicOp),
Compare(CmpOp),
Bitwise(BitwiseOp),
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ArithOp {
Add,
Sub,
Expand All @@ -45,13 +45,13 @@ pub enum ArithOp {
Mod,
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum LogicOp {
And,
Or,
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CmpOp {
Eq,
NotEq,
Expand All @@ -61,51 +61,51 @@ pub enum CmpOp {
GtEq,
}

#[derive(Clone, Debug, PartialEq, Copy)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BitwiseOp {
And,
Or,
Xor,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatchExpr {
pub value: Box<Expression>,
pub variants: Vec<MatchVariant>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IfExpr {
pub value: Box<Expression>,
pub contents: Vec<Statement>,
pub r#else: Option<Vec<Statement>>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatchVariant {
pub case: SimpleExpr,
pub block: Vec<Statement>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PathSegment {
FieldAccess(Ident),
ArrayIndex(SimpleExpr),
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PathOp {
pub first: Ident,
pub extra: Vec<PathSegment>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CastOp {
pub value: Expression,
pub r#type: TypeSpec,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct FnCallOp {
pub target: Ident,
pub args: Vec<Expression>,
Expand Down
Loading

0 comments on commit 538a911

Please sign in to comment.