Skip to content

Implement Vyper AST #291

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
49 changes: 49 additions & 0 deletions crates/artifacts/vyper/src/ast/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
macro_rules! vyper_node {
(
$(#[$struct_meta:meta])*
struct $name:ident {
$(
$(#[$field_meta:meta])*
$field:ident: $ty:ty
),* $(,)?
}
) => {
$(#[$struct_meta])*
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct $name {
pub node_id: u64,
pub src: String,
pub lineno: u64,
pub col_offset: u64,
pub end_lineno: u64,
pub end_col_offset: u64,
$(
$(#[$field_meta])*
pub $field: $ty
),*
}
};
}

macro_rules! node_group {
(
$group:ident;

$(
$(#[$field_meta:meta])?
$name:ident
),* $(,)?
) => {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "ast_type")]
pub enum $group {
$(
$(#[$field_meta])*
$name($name),
)*
}
};
}

pub(crate) use vyper_node;
pub(crate) use node_group;
Loading