diff --git a/src/builtin.cpp b/src/builtin.cpp index 350614e7b..34bd7febc 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -3050,53 +3050,6 @@ static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **ar return status; } -#if 0 -// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809. -int builtin_parse(parser_t &parser, io_streams_t &streams, wchar_t **argv) -{ - struct sigaction act; - sigemptyset(& act.sa_mask); - act.sa_flags=0; - act.sa_handler=SIG_DFL; - sigaction(SIGINT, &act, 0); - - std::vector txt; - for (;;) - { - char buff[256]; - ssize_t amt = read_loop(streams.stdin_fd, buff, sizeof buff); - if (amt <= 0) break; - txt.insert(txt.end(), buff, buff + amt); - } - if (! txt.empty()) - { - const wcstring src = str2wcstring(&txt.at(0), txt.size()); - parse_node_tree_t parse_tree; - parse_error_list_t errors; - bool success = parse_tree_from_string(src, parse_flag_include_comments, &parse_tree, - &errors); - if (! success) - { - streams.out.append(L"Parsing failed:\n"); - for (size_t i=0; i < errors.size(); i++) - { - streams.out.append(errors.at(i).describe(src)); - streams.out.push_back(L'\n'); - } - - streams.out.append(L"(Reparsed with continue after error)\n"); - parse_tree.clear(); - errors.clear(); - parse_tree_from_string(src, parse_flag_continue_after_error | - parse_flag_include_comments, &parse_tree, &errors); - } - const wcstring dump = parse_dump_tree(parse_tree, src); - streams.out.append(dump); - } - return STATUS_CMD_OK; -} -#endif - int builtin_true(parser_t &parser, io_streams_t &streams, wchar_t **argv) { UNUSED(parser); UNUSED(streams); @@ -3152,10 +3105,6 @@ int builtin_realpath(parser_t &parser, io_streams_t &streams, wchar_t **argv) { // NOTE: These must be kept in sorted order! static const builtin_data_t builtin_datas[] = { {L"[", &builtin_test, N_(L"Test a condition")}, -#if 0 - // Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809. - { L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") }, -#endif {L"and", &builtin_generic, N_(L"Execute command if previous command suceeded")}, {L"begin", &builtin_generic, N_(L"Create a block of code")}, {L"bg", &builtin_bg, N_(L"Send job to background")}, diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 861eff6de..bc33a9e72 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -172,23 +172,27 @@ static void prettify_node_recursive(const wcstring &source, const parse_node_tre // Entry point for prettification. static wcstring prettify(const wcstring &src, bool do_indent) { - parse_node_tree_t tree; + parse_node_tree_t parse_tree; int parse_flags = (parse_flag_continue_after_error | parse_flag_include_comments | parse_flag_leave_unterminated | parse_flag_show_blank_lines); - if (!parse_tree_from_string(src, parse_flags, &tree, NULL)) { - // We return the initial string on failure. - return src; + if (!parse_tree_from_string(src, parse_flags, &parse_tree, NULL)) { + return src; // we return the original string on failure + } + + if (dump_parse_tree) { + const wcstring dump = parse_dump_tree(parse_tree, src); + fwprintf(stderr, L"%ls\n", dump.c_str()); } // We may have a forest of disconnected trees on a parse failure. We have to handle all nodes // that have no parent, and all parse errors. bool has_new_line = true; wcstring result; - for (node_offset_t i = 0; i < tree.size(); i++) { - const parse_node_t &node = tree.at(i); + for (node_offset_t i = 0; i < parse_tree.size(); i++) { + const parse_node_t &node = parse_tree.at(i); if (node.parent == NODE_OFFSET_INVALID || node.type == parse_special_type_parse_error) { // A root node. - prettify_node_recursive(src, tree, i, 0, symbol_job_list, &has_new_line, &result, + prettify_node_recursive(src, parse_tree, i, 0, symbol_job_list, &has_new_line, &result, do_indent); } } diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 1158d4a33..613fc100d 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -254,7 +254,7 @@ static inline parse_token_type_t parse_token_type_from_tokenizer_token( return result; } -#if 0 +#if 1 // Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809. /// Helper function for parse_dump_tree().