-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.cpp
More file actions
20 lines (20 loc) · 858 Bytes
/
Copy pathformat.cpp
File metadata and controls
20 lines (20 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
std::tuple<ast_block_t, token_vec_t::const_iterator>
parse_block(token_vec_t::const_iterator parse_begin,
token_vec_t::const_iterator parse_end) {
std::vector<ast_node_ptr_t> block_content;
for (; parse_begin != parse_end; parse_begin++) {
if (*parse_begin == while_end_v) {
return {std::move(block_content), parse_begin};
} else if (*parse_begin == while_begin_v) {
auto [while_block_content, while_block_end] =
parse_block(parse_begin + 1, parse_end);
block_content.push_back(
std::make_unique<ast_while_t>(std::move(while_block_content)));
parse_begin = while_block_end;
} else if (*parse_begin != nop_v) {
block_content.push_back(
ast_node_ptr_t(std::make_unique<ast_token_t>(*parse_begin)));
}
}
return {ast_block_t(std::move(block_content)), parse_end};
}