-
Notifications
You must be signed in to change notification settings - Fork 604
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
added statement expansion to parser #7724
Conversation
12ea42b
to
888bd51
Compare
There was a problem hiding this 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 {
^
888bd51
to
0edd08a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 11 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)
crates/cairo-lang-parser/src/parser.rs
line 1536 at r2 (raw file):
Previously, orizi wrote…
move to under the usage.
(probably right below
parse_statements_and_block
.
Done.
0edd08a
to
9dd305b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 11 files reviewed, 4 unresolved discussions (waiting on @dean-starkware and @orizi)
crates/cairo-lang-semantic/src/expr/compute.rs
line 1786 at r4 (raw file):
ast::StatementBlock::Statements(statements) => statements.elements(db), _ => vec![], };
Placeholders shouldn't reach this point (it'll be replaces in the expansion, which should happen before), so extract the exprblock
at the top of the function and panic if it's a placeholder.
Code quote:
let mut statements = match syntax.statements(db) {
ast::StatementBlock::Statements(statements) => statements.elements(db),
_ => vec![],
};
crates/cairo-lang-parser/src/parser_test_data/partial_trees/macro_declaration
line 288 at r4 (raw file):
} //! > top_level_kind
Suggestion:
//! > top_level_kind
PlaceholderRepetitionBlock
9dd305b
to
0e9d727
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 11 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware and @orizi)
crates/cairo-lang-parser/src/parser_test_data/diagnostics/expr_diagnostics
line 42 at r2 (raw file):
Previously, orizi wrote…
?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: 1 of 11 files reviewed, 5 unresolved discussions (waiting on @dean-starkware and @orizi)
crates/cairo-lang-parser/src/diagnostic.rs
line 155 at r5 (raw file):
} ParserDiagnosticKind::MissingRepetitionOperator => { "Missing tokens. Expected an operator.".to_string()
Suggestion:
Missing tokens. Expected a repetition operator.
0e9d727
to
90a6791
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 11 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware and @orizi)
crates/cairo-lang-semantic/src/expr/compute.rs
line 1786 at r4 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Placeholders shouldn't reach this point (it'll be replaces in the expansion, which should happen before), so extract the
exprblock
at the top of the function and panic if it's a placeholder.
Done.
crates/cairo-lang-parser/src/diagnostic.rs
line 155 at r5 (raw file):
} ParserDiagnosticKind::MissingRepetitionOperator => { "Missing tokens. Expected an operator.".to_string()
Done.
90a6791
to
1fec6a0
Compare
41c13ce
to
0753382
Compare
No description provided.