| 408 | } |
| 409 | |
| 410 | var runtime_type::parse_expr(const tree_type<token_base *>::iterator &it, bool disable_parallel) |
| 411 | { |
| 412 | if (!it.usable()) |
| 413 | throw internal_error("The expression tree is not available."); |
| 414 | token_base *token = it.data(); |
| 415 | if (token == nullptr) |
| 416 | return var(); |
| 417 | switch (token->get_type()) { |
| 418 | default: |
| 419 | break; |
| 420 | case token_types::vargs: |
| 421 | throw runtime_error("Wrong declaration of variable argument list."); |
| 422 | break; |
| 423 | case token_types::expand: |
| 424 | throw runtime_error("Wrong expanding position."); |
| 425 | break; |
| 426 | case token_types::id: |
| 427 | return storage.get_var(static_cast<token_id *>(token)->get_id()); |
| 428 | break; |
| 429 | case token_types::literal: { |
| 430 | token_literal *ptr = static_cast<token_literal *>(token); |
| 431 | return get_string_literal(ptr->get_data(), ptr->get_literal()); |
| 432 | } |
| 433 | case token_types::value: |
| 434 | return static_cast<token_value *>(token)->get_value(); |
| 435 | break; |
| 436 | case token_types::expr: |
| 437 | return parse_expr(static_cast<token_expr *>(token)->get_tree().root()); |
| 438 | break; |
| 439 | case token_types::array: { |
| 440 | array arr; |
| 441 | token_base *ptr = nullptr; |
| 442 | for (auto &tree : static_cast<token_array *>(token)->get_array()) { |
| 443 | ptr = tree.root().data(); |
| 444 | if (ptr != nullptr && ptr->get_type() == token_types::expand) { |
| 445 | var val = parse_expr(static_cast<token_expand *>(ptr)->get_tree().root()); |
| 446 | const auto &child_arr = val.const_val<array>(); |
| 447 | for (auto &it : child_arr) |
| 448 | arr.push_back(copy(it)); |
| 449 | } |
| 450 | else |
| 451 | arr.push_back(copy(parse_expr(tree.root()))); |
| 452 | } |
| 453 | return rvalue(var::make<array>(std::move(arr))); |
| 454 | } |
| 455 | case token_types::parallel: { |
| 456 | if (disable_parallel) |
| 457 | throw runtime_error("Do not allowed parallel list."); |
| 458 | var result; |
| 459 | for (auto &tree : static_cast<token_parallel *>(token)->get_parallel()) |
| 460 | result = parse_expr(tree.root()); |
| 461 | return result; |
| 462 | } |
| 463 | case token_types::signal: { |
| 464 | switch (static_cast<token_signal *>(token)->get_signal()) { |
| 465 | default: |
| 466 | break; |
| 467 | case signal_types::add_: |
no test coverage detected