mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-26 07:41:15 -03:00
Clean up the return type of parser_t::eval
parser_t::eval indicates whether there was a parse error. It can be easily confused with the status of the execution. Use a real type to make it more clear.
This commit is contained in:
24
src/parser.h
24
src/parser.h
@@ -53,6 +53,18 @@ enum class loop_status_t {
|
||||
continues, /// current loop block should be skipped
|
||||
};
|
||||
|
||||
/// Result of the source code form of eval.
|
||||
enum class eval_result_t {
|
||||
/// eval was able to evaluate the source or tree.
|
||||
ok,
|
||||
|
||||
/// Evaluation was cancelled, e.g. because of a signal.
|
||||
cancelled,
|
||||
|
||||
/// Parse or execution error (but not simply a failed command).
|
||||
error,
|
||||
};
|
||||
|
||||
/// block_t represents a block of commands.
|
||||
class block_t {
|
||||
/// Construct from a block type.
|
||||
@@ -258,18 +270,18 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
|
||||
/// \param io io redirections to perform on all started jobs
|
||||
/// \param block_type The type of block to push on the block stack
|
||||
///
|
||||
/// \return 0 on success, 1 on a parse error.
|
||||
int eval(wcstring cmd, const io_chain_t &io, enum block_type_t block_type);
|
||||
/// \return the eval result,
|
||||
eval_result_t eval(const wcstring &cmd, const io_chain_t &io, enum block_type_t block_type);
|
||||
|
||||
/// Evaluate the parsed source ps.
|
||||
/// \return 0 on success, 1 on a parse error.
|
||||
int eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type);
|
||||
/// Because the source has been parsed, a syntax error is impossible.
|
||||
eval_result_t eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type);
|
||||
|
||||
/// Evaluates a node.
|
||||
/// The node type must be grammar::statement or grammar::job_list.
|
||||
template <typename T>
|
||||
int eval_node(parsed_source_ref_t ps, tnode_t<T> node, block_type_t block_type,
|
||||
job_lineage_t lineage);
|
||||
eval_result_t eval_node(parsed_source_ref_t ps, tnode_t<T> node, block_type_t block_type,
|
||||
job_lineage_t lineage);
|
||||
|
||||
/// Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and
|
||||
/// cmdsubst execution on the tokens. Errors are ignored. If a parser is provided, it is used
|
||||
|
||||
Reference in New Issue
Block a user