aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-27 18:25:58 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-27 18:25:58 -0800
commitcbd3fa6b01bab709d0b6f5277a984685d8c45888 (patch)
treeec329ec4db36008fa451829edba60b3b946bc786
parent584cca59bfa5ff038dfecf6471347dde47ff01ed (diff)
Eliminate parser_type_t
It was never fully implemented and wasn't used for anything
-rw-r--r--src/complete.cpp9
-rw-r--r--src/fish_tests.cpp10
-rw-r--r--src/parser.cpp21
-rw-r--r--src/parser.h17
4 files changed, 19 insertions, 38 deletions
diff --git a/src/complete.cpp b/src/complete.cpp
index 132dbb74..be79b7eb 100644
--- a/src/complete.cpp
+++ b/src/complete.cpp
@@ -986,17 +986,22 @@ void completer_t::complete_from_args(const wcstring &str,
complete_flags_t flags)
{
bool is_autosuggest = (this->type() == COMPLETE_AUTOSUGGEST);
- parser_t parser(is_autosuggest ? PARSER_TYPE_COMPLETIONS_ONLY : PARSER_TYPE_GENERAL, false /* don't show errors */);
+ parser_t parser(false /* don't show errors */);
/* If type is COMPLETE_AUTOSUGGEST, it means we're on a background thread, so don't call proc_push_interactive */
if (! is_autosuggest)
+ {
proc_push_interactive(0);
+ }
+ expand_flags_t eflags = is_autosuggest ? EXPAND_SKIP_CMDSUBST : 0;
std::vector<completion_t> possible_comp;
- parser.expand_argument_list(args, &possible_comp);
+ parser.expand_argument_list(args, eflags, &possible_comp);
if (! is_autosuggest)
+ {
proc_pop_interactive();
+ }
this->complete_strings(escape_string(str, ESCAPE_ALL), desc.c_str(), 0, possible_comp, flags);
}
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp
index d6972139..871e5622 100644
--- a/src/fish_tests.cpp
+++ b/src/fish_tests.cpp
@@ -593,7 +593,7 @@ static void test_parser()
{
say(L"Testing parser");
- parser_t parser(PARSER_TYPE_GENERAL, true);
+ parser_t parser(true);
say(L"Testing block nesting");
if (!parse_util_detect_errors(L"if; end"))
@@ -776,7 +776,7 @@ static void test_parser()
say(L"Testing eval_args");
completion_list_t comps;
- parser_t::principal_parser().expand_argument_list(L"alpha 'beta gamma' delta", &comps);
+ parser_t::principal_parser().expand_argument_list(L"alpha 'beta gamma' delta", 0, &comps);
do_test(comps.size() == 3);
do_test(comps.at(0).completion == L"alpha");
do_test(comps.at(1).completion == L"beta gamma");
@@ -1954,7 +1954,7 @@ static void test_is_potential_path()
int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv);
static bool run_one_test_test(int expected, wcstring_list_t &lst, bool bracket)
{
- parser_t parser(PARSER_TYPE_GENERAL, true);
+ parser_t parser(true);
size_t i, count = lst.size();
wchar_t **argv = new wchar_t *[count+3];
argv[0] = (wchar_t *)(bracket ? L"[" : L"test");
@@ -1993,7 +1993,7 @@ static bool run_test_test(int expected, const wcstring &str)
static void test_test_brackets()
{
// Ensure [ knows it needs a ]
- parser_t parser(PARSER_TYPE_GENERAL, true);
+ parser_t parser(true);
io_streams_t streams;
const wchar_t *argv1[] = {L"[", L"foo", NULL};
@@ -4116,7 +4116,7 @@ static void test_wcstring_tok(void)
int builtin_string(parser_t &parser, io_streams_t &streams, wchar_t **argv);
static void run_one_string_test(const wchar_t **argv, int expected_rc, const wchar_t *expected_out)
{
- parser_t parser(PARSER_TYPE_GENERAL, true);
+ parser_t parser(true);
io_streams_t streams;
streams.stdin_is_directly_redirected = false; // read from argv instead of stdin
int rc = builtin_string(parser, streams, const_cast<wchar_t**>(argv));
diff --git a/src/parser.cpp b/src/parser.cpp
index 5813bb12..325b053d 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -162,8 +162,7 @@ static wcstring user_presentable_path(const wcstring &path)
}
-parser_t::parser_t(enum parser_type_t type, bool errors) :
- parser_type(type),
+parser_t::parser_t(bool errors) :
show_errors(errors),
cancellation_requested(false),
is_within_fish_initialization(false)
@@ -177,7 +176,7 @@ parser_t &parser_t::principal_parser(void)
{
ASSERT_IS_NOT_FORKED_CHILD();
ASSERT_IS_MAIN_THREAD();
- static parser_t parser(PARSER_TYPE_GENERAL, true);
+ static parser_t parser(true);
if (! s_principal_parser)
{
s_principal_parser = &parser;
@@ -467,20 +466,11 @@ void parser_t::emit_profiling(const char *path) const
}
}
-void parser_t::expand_argument_list(const wcstring &arg_list_src, std::vector<completion_t> *output_arg_list)
+void parser_t::expand_argument_list(const wcstring &arg_list_src, expand_flags_t eflags, std::vector<completion_t> *output_arg_list)
{
assert(output_arg_list != NULL);
- expand_flags_t eflags = 0;
if (! show_errors)
eflags |= EXPAND_NO_DESCRIPTIONS;
- if (this->parser_type != PARSER_TYPE_GENERAL)
- eflags |= EXPAND_SKIP_CMDSUBST;
-
- /* Suppress calling proc_push_interactive off of the main thread. */
- if (this->parser_type == PARSER_TYPE_GENERAL)
- {
- proc_push_interactive(0);
- }
/* Parse the string as an argument list */
parse_node_tree_t tree;
@@ -509,11 +499,6 @@ void parser_t::expand_argument_list(const wcstring &arg_list_src, std::vector<co
}
}
}
-
- if (this->parser_type == PARSER_TYPE_GENERAL)
- {
- proc_pop_interactive();
- }
}
wcstring parser_t::stack_trace() const
diff --git a/src/parser.h b/src/parser.h
index 13fa6d16..df3df8ee 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -14,6 +14,7 @@
#include "parse_tree.h"
#include "io.h"
#include "parse_constants.h"
+#include "expand.h"
#include <vector>
@@ -202,15 +203,6 @@ enum parser_error
CMDSUBST_ERROR,
};
-enum parser_type_t
-{
- PARSER_TYPE_NONE,
- PARSER_TYPE_GENERAL,
- PARSER_TYPE_FUNCTIONS_ONLY,
- PARSER_TYPE_COMPLETIONS_ONLY,
- PARSER_TYPE_ERRORS_ONLY
-};
-
struct profile_item_t
{
/** Time spent executing the specified command, including parse time for nested blocks. */
@@ -236,8 +228,6 @@ class parser_t
{
friend class parse_execution_context_t;
private:
- enum parser_type_t parser_type;
-
/** Whether or not we output errors */
const bool show_errors;
@@ -294,7 +284,7 @@ public:
static void skip_all_blocks();
/** Create a parser of the given type */
- parser_t(enum parser_type_t type, bool show_errors);
+ parser_t(bool show_errors);
/** Global event blocks */
event_blockage_list_t global_event_blocks;
@@ -319,9 +309,10 @@ public:
Errors are ignored.
\param arg_src String to evaluate as an argument list
+ \param flags Some expand flags to use
\param output List to insert output into
*/
- void expand_argument_list(const wcstring &arg_src, std::vector<completion_t> *output);
+ void expand_argument_list(const wcstring &arg_src, expand_flags_t flags, std::vector<completion_t> *output);
/**
Returns a string describing the current parser pisition in the format 'FILENAME (line LINE_NUMBER): LINE'.