Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions core/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ good_lp = { version = "1", features = [
], default-features = false }
itertools = "0.14"
ena = "0.14"
enumify = { version = "0.2.1", registry = "substrate" }
enumify = { version = "0.2", registry = "substrate" }
gds21 = "0.2"
arcstr = { version = "1", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
derive-where = "1"
nalgebra = "0.33.2"
nalgebra = "0"
approx = "0.5"
rust_decimal = "1"
rust_decimal_macros = "1"
indexmap = "2.10.0"
indexmap = { version = "2", features = ["serde"] }
clap = { version = "4", features = ["derive"] }
geometry = { version = "0.7.1", registry = "substrate" }
geometry = { version = "0.7", registry = "substrate" }

[build-dependencies]
cfgrammar = "0.13"
Expand Down
11 changes: 11 additions & 0 deletions core/compiler/examples/nested_inst.ar
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
cell bot() {
let met1 = rect(Layer::Met1, x0=0., y0=0., x1=100., y1=100.)!;
let met2 = rect(Layer::Met1, x0=100., y0=0., x1=200., y1=100.)!;
let met3 = make_rect()!;
let met4 = emit_rect();
}

fn make_rect() -> Rect {
rect(Layer::Met2, x0=0., y0=0., x1=200., y1=100.)
}

fn emit_rect() -> Rect {
rect(Layer::Met2, x0=0., y0=0., x1=200., y1=100.)!
}

cell middle() {
Expand All @@ -18,5 +28,6 @@ cell top() {
eq(right.x, 300.);
eq(right.y, 0.);
let met3 = rect(Layer::Met3, x0=left.bot.met1.x0, y0=20., x1=right.bot.met1.x1, y1=80.)!;
let duplicate_rect = left.bot.met3!;
}

20 changes: 15 additions & 5 deletions core/compiler/src/argon.y
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
%start Decls
%start Ast
%%
Ast -> Result<Ast<'input, ParseMetadata>, ()>:
Decls {
Ok(Ast {
decls: $1?,
span: $span,
})
};

Decls -> Result<Vec<Decl<'input, ParseMetadata>>, ()>:
Decls Decl {
let mut __tmp = $1?;
Expand Down Expand Up @@ -105,6 +113,7 @@ CellDecl -> Result<CellDecl<'input, ParseMetadata>, ()>
name: $2?,
args: $4?,
scope: $6?,
span: $span,
metadata: (),
})
}
Expand All @@ -118,6 +127,7 @@ FnDecl -> Result<FnDecl<'input, ParseMetadata>, ()>
args: $4?,
scope: $8?,
return_ty: $7?,
span: $span,
metadata: (),
})
}
Expand Down Expand Up @@ -159,10 +169,10 @@ Scope -> Result<Scope<'input, ParseMetadata>, ()>
if let Some(Statement::Expr { value, semicolon }) = __stmts.last().cloned() && !semicolon {
__stmts.pop().unwrap();
return Ok(Scope {
span: $span,
stmts: __stmts,
tail: Some(value),
metadata: (),
span: $span,
stmts: __stmts,
tail: Some(value),
metadata: (),
})
}
Ok(Scope {
Expand Down
7 changes: 6 additions & 1 deletion core/compiler/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use cfgrammar::Span;
use derive_where::derive_where;
use itertools::Itertools;

#[derive_where(Default, Debug, Clone)]
#[derive_where(Debug, Clone)]
pub struct Ast<'a, T: AstMetadata> {
pub decls: Vec<Decl<'a, T>>,
pub span: Span,
}

#[derive_where(Debug, Clone)]
Expand Down Expand Up @@ -65,6 +66,7 @@ pub struct CellDecl<'a, T: AstMetadata> {
pub name: Ident<'a, T>,
pub args: Vec<ArgDecl<'a, T>>,
pub scope: Scope<'a, T>,
pub span: Span,
pub metadata: T::CellDecl,
}

Expand All @@ -74,6 +76,7 @@ pub struct FnDecl<'a, T: AstMetadata> {
pub args: Vec<ArgDecl<'a, T>>,
pub return_ty: Ident<'a, T>,
pub scope: Scope<'a, T>,
pub span: Span,
pub metadata: T::FnDecl,
}

Expand Down Expand Up @@ -486,6 +489,7 @@ pub trait AstTransformer<'a> {
name,
args,
scope,
span: input.span,
metadata,
}
}
Expand All @@ -504,6 +508,7 @@ pub trait AstTransformer<'a> {
args,
return_ty,
scope,
span: input.span,
metadata,
}
}
Expand Down
Loading