Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add salsa. #66

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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