Skip to content

added statement expansion to parser #7724

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 1 commit into
base: high-level-inline-macros
Choose a base branch
from

Conversation

dean-starkware
Copy link
Collaborator

No description provided.

@dean-starkware dean-starkware marked this pull request as ready for review May 3, 2025 13:41
@reviewable-StarkWare
Copy link

This change is Reviewable

@dean-starkware dean-starkware force-pushed the dean/macro_placeholder_repetition_block branch from 12ea42b to 888bd51 Compare May 6, 2025 11:41
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 11 files at r2, all commit messages.
Reviewable status: 2 of 11 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware)


crates/cairo-lang-parser/src/parser.rs line 1536 at r2 (raw file):

        );
        Ok(placeholder_repetition_block.into())
    }

move to under the usage.

(probably right below parse_statements_and_block.

Code quote:

    /// Parses a placeholder repetition block inside a macro.
    fn parse_placeholder_repetition_block(&mut self) -> TryParseResult<StatementBlockGreen> {
        let dollar = self.take::<TerminalDollar>();
        if self.peek().kind != SyntaxKind::TerminalLParen {
            return Err(TryParseFailure::SkipToken);
        }
        let lparen = self.take::<TerminalLParen>();
        let elements = StatementList::new_green(
            self.db,
            self.parse_list(
                Self::try_parse_statement,
                is_of_kind!(rparen, block, rbrace, module_item_kw),
                "statement",
            ),
        );
        let rparen = self.parse_token::<TerminalRParen>();
        let operator = match self.peek().kind {
            SyntaxKind::TerminalQuestionMark => self.take::<TerminalQuestionMark>().into(),
            SyntaxKind::TerminalPlus => self.take::<TerminalPlus>().into(),
            SyntaxKind::TerminalMul => self.take::<TerminalMul>().into(),
            _ => self
                .create_and_report_missing::<TerminalPlus>(
                    ParserDiagnosticKind::MissingRepetitionOperator,
                )
                .into(),
        };
        let placeholder_repetition_block = PlaceholderRepetitionBlock::new_green(
            self.db, dollar, lparen, elements, rparen, operator,
        );
        Ok(placeholder_repetition_block.into())
    }

crates/cairo-lang-parser/src/parser_test_data/diagnostics/expr_diagnostics line 42 at r2 (raw file):

 --> dummy_file.cairo:4:7
    } + match x {
      ^

?

Code quote:

error: Skipped tokens. Expected: statement.
 --> dummy_file.cairo:4:7
    } + match x {
      ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants