Skip to content

Commit

Permalink
♻️ (parser): Add expect_statement and expect_expression macros
Browse files Browse the repository at this point in the history
semver: chore
  • Loading branch information
Somfic committed Jun 12, 2024
1 parent ffa035f commit 897b7c3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/parser/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
macro_rules! expect_statement {
($parser:expr, $cursor:expr) => {{
crate::parser::statement::parse($parser, $cursor)
}};
}

macro_rules! expect_expression {
($parser:expr, $cursor:expr, $binding_power:expr) => {{
crate::parser::expression::parse($parser, $cursor, &$binding_power)
}};
}

macro_rules! expect_token {
($parser:expr, $cursor:expr, $token_type:expr) => {{
let lexeme = crate::parser::macros::expect_tokens!($parser, $cursor, ($token_type))
Expand Down Expand Up @@ -44,5 +56,7 @@ macro_rules! expect_tokens {
}};
}

pub(crate) use expect_expression;
pub(crate) use expect_statement;
pub(crate) use expect_token;
pub(crate) use expect_tokens;

0 comments on commit 897b7c3

Please sign in to comment.