-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add keyword continue, break, pass in lexer, parser #173
base: main
Are you sure you want to change the base?
Conversation
ctx.tokenIter->is(Keyword::Pass)); | ||
ctx.goNextToken(); | ||
if (!ctx.token().is(Special::EndOfExpression)) { | ||
ctx.pushError("Unexepted tokens after control flow keyword"); |
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.
- я думаю сообщение должно быть более конкретным: Unexpected token in a break|continue|pass statement.
- в случае этой ошибки нужно явно перейти на следующее выражение, ctx.goNextExperssion()
@@ -433,6 +433,17 @@ std::stack<SubExpression> generatePostfixForm(TokenIterator tokenIterBegin, Toke | |||
return postfixForm; | |||
} | |||
|
|||
void parseControlFlowStatement(ParserContext &ctx) { |
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.
pass не влияет на control flow, лучше parseSimpleStatement или что-нибудь такое
@@ -1193,6 +1193,53 @@ TEST(Parser, can_parse_for_enumerate) { | |||
ASSERT_EQ(expected, tree.dump()); | |||
} | |||
|
|||
TEST(Parser, can_parse_pass_continue_break_loops) { |
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.
наверное для pass лучше сделать отдельный тест? он же не только в цикле может быть, а где угодно
}; | ||
TokenList tokens = Lexer::process(source); | ||
SyntaxTree tree = Parser::process(tokens); | ||
std::string expected = "ProgramRoot\n" |
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.
как смотришь на использование DeclarativeTree?
t.node(NodeType::FunctionDefinition).withChildren(); |
No description provided.