diff options
author | Łukasz Niemier <lukasz@niemier.pl> | 2012-11-18 11:23:22 +0100 |
---|---|---|
committer | Łukasz Niemier <lukasz@niemier.pl> | 2012-11-18 11:23:22 +0100 |
commit | 47df1ae40adecd0a02fc7dd06ab0745cb18c3fe0 (patch) | |
tree | 13bf3e8fdcae60fdfb5fa5e26c95818dc7a49790 /parser.h | |
parent | b79854ad1aa814d9d35d76a1929b4726fa4bffa5 (diff) |
Remove trailing whitespaces and change tabs to spaces
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 306 |
1 files changed, 153 insertions, 153 deletions
@@ -1,5 +1,5 @@ /** \file parser.h - The fish parser. + The fish parser. */ #ifndef FISH_PARSER_H @@ -21,15 +21,15 @@ */ struct event_blockage_t { - /** - The types of events to block. This is interpreted as a bitset - whete the value is 1 for every bit corresponding to a blocked - event type. For example, if EVENT_VARIABLE type events should - be blocked, (type & 1<<EVENT_BLOCKED) should be set. - - Note that EVENT_ANY can be used to specify any event. - */ - unsigned int typemask; + /** + The types of events to block. This is interpreted as a bitset + whete the value is 1 for every bit corresponding to a blocked + event type. For example, if EVENT_VARIABLE type events should + be blocked, (type & 1<<EVENT_BLOCKED) should be set. + + Note that EVENT_ANY can be used to specify any event. + */ + unsigned int typemask; }; typedef std::list<event_blockage_t> event_blockage_list_t; @@ -45,30 +45,30 @@ inline bool event_block_list_blocks_type(const event_blockage_list_t &ebls, int } -/** - Types of blocks +/** + Types of blocks */ enum block_type_t { - WHILE, /**< While loop block */ - FOR, /**< For loop block */ - IF, /**< If block */ - FUNCTION_DEF, /**< Function definition block */ - FUNCTION_CALL, /**< Function invocation block */ - FUNCTION_CALL_NO_SHADOW, /**< Function invocation block with no variable shadowing */ - SWITCH, /**< Switch block */ - FAKE, /**< Fake block */ - SUBST, /**< Command substitution scope */ - TOP, /**< Outermost block */ - BEGIN, /**< Unconditional block */ - SOURCE, /**< Block created by the . (source) builtin */ - EVENT, /**< Block created on event notifier invocation */ - BREAKPOINT, /**< Breakpoint block */ + WHILE, /**< While loop block */ + FOR, /**< For loop block */ + IF, /**< If block */ + FUNCTION_DEF, /**< Function definition block */ + FUNCTION_CALL, /**< Function invocation block */ + FUNCTION_CALL_NO_SHADOW, /**< Function invocation block with no variable shadowing */ + SWITCH, /**< Switch block */ + FAKE, /**< Fake block */ + SUBST, /**< Command substitution scope */ + TOP, /**< Outermost block */ + BEGIN, /**< Unconditional block */ + SOURCE, /**< Block created by the . (source) builtin */ + EVENT, /**< Block created on event notifier invocation */ + BREAKPOINT, /**< Breakpoint block */ } ; /** - block_t represents a block of commands. + block_t represents a block of commands. */ struct block_t { @@ -77,63 +77,63 @@ struct block_t block_t(block_type_t t); private: - const block_type_t block_type; /**< Type of block. */ + const block_type_t block_type; /**< Type of block. */ bool made_fake; public: block_type_t type() const { return this->made_fake ? FAKE : this->block_type; } - + /** Mark a block as fake; this is used by the return statement. */ void mark_as_fake() { this->made_fake = true; } - bool skip; /**< Whether execution of the commands in this block should be skipped */ - bool had_command; /**< Set to non-zero once a command has been executed in this block */ - int tok_pos; /**< The start index of the block */ - - /** - Status for the current loop block. Can be any of the values from the loop_status enum. - */ - int loop_status; + bool skip; /**< Whether execution of the commands in this block should be skipped */ + bool had_command; /**< Set to non-zero once a command has been executed in this block */ + int tok_pos; /**< The start index of the block */ + + /** + Status for the current loop block. Can be any of the values from the loop_status enum. + */ + int loop_status; - /** - The job that is currently evaluated in the specified block. - */ - job_t *job; + /** + The job that is currently evaluated in the specified block. + */ + job_t *job; #if 0 - union - { - int while_state; /**< True if the loop condition has not yet been evaluated*/ - wchar_t *for_variable; /**< Name of the variable to loop over */ - int if_state; /**< The state of the if block, can be one of IF_STATE_UNTESTED, IF_STATE_FALSE, IF_STATE_TRUE */ - wchar_t *switch_value; /**< The value to test in a switch block */ - const wchar_t *source_dest; /**< The name of the file to source*/ - event_t *event; /**<The event that triggered this block */ - wchar_t *function_call_name; - } param1; + union + { + int while_state; /**< True if the loop condition has not yet been evaluated*/ + wchar_t *for_variable; /**< Name of the variable to loop over */ + int if_state; /**< The state of the if block, can be one of IF_STATE_UNTESTED, IF_STATE_FALSE, IF_STATE_TRUE */ + wchar_t *switch_value; /**< The value to test in a switch block */ + const wchar_t *source_dest; /**< The name of the file to source*/ + event_t *event; /**<The event that triggered this block */ + wchar_t *function_call_name; + } param1; #endif - /** - Name of file that created this block - */ - const wchar_t *src_filename; - - /** - Line number where this block was created - */ - int src_lineno; - + /** + Name of file that created this block + */ + const wchar_t *src_filename; + + /** + Line number where this block was created + */ + int src_lineno; + /** Whether we should pop the environment variable stack when we're popped off of the block stack */ bool wants_pop_env; - - /** List of event blocks. */ - event_blockage_list_t event_blocks; - + + /** List of event blocks. */ + event_blockage_list_t event_blocks; + /** - Next outer block - */ - block_t *outer; - + Next outer block + */ + block_t *outer; + /** Destructor */ virtual ~block_t(); }; @@ -144,7 +144,7 @@ struct if_block_t : public block_t bool is_elseif_entry; // whether we're at the beginning of an ELSEIF branch bool any_branch_taken; // whether the clause of the if statement or any elseif has been found to be true bool else_evaluated; // whether we've encountered a terminal else block - + if_block_t(); }; @@ -211,11 +211,11 @@ struct breakpoint_block_t : public block_t /** Possible states for a loop */ -enum loop_status +enum loop_status { - LOOP_NORMAL, /**< Current loop block executed as normal */ - LOOP_BREAK, /**< Current loop block should be removed */ - LOOP_CONTINUE, /**< Current loop block should be skipped */ + LOOP_NORMAL, /**< Current loop block executed as normal */ + LOOP_BREAK, /**< Current loop block should be removed */ + LOOP_CONTINUE, /**< Current loop block should be skipped */ }; @@ -224,9 +224,9 @@ enum loop_status */ enum while_status { - WHILE_TEST_FIRST, /**< This is the first command of the first lap of a while loop */ - WHILE_TEST_AGAIN, /**< This is not the first lap of the while loop, but it is the first command of the loop */ - WHILE_TESTED, /**< This is not the first command in the loop */ + WHILE_TEST_FIRST, /**< This is the first command of the first lap of a while loop */ + WHILE_TEST_AGAIN, /**< This is not the first lap of the while loop, but it is the first command of the loop */ + WHILE_TESTED, /**< This is not the first command in the loop */ } ; @@ -234,24 +234,24 @@ enum while_status /** Errors that can be generated by the parser */ -enum parser_error +enum parser_error { - /** - No error - */ - NO_ERR=0, - /** - An error in the syntax - */ - SYNTAX_ERROR, - /** - Error occured while evaluating commands - */ - EVAL_ERROR, - /** - Error while evaluating cmdsubst - */ - CMDSUBST_ERROR, + /** + No error + */ + NO_ERR=0, + /** + An error in the syntax + */ + SYNTAX_ERROR, + /** + Error occured while evaluating commands + */ + EVAL_ERROR, + /** + Error while evaluating cmdsubst + */ + CMDSUBST_ERROR, }; enum parser_type_t { @@ -259,30 +259,30 @@ enum parser_type_t { PARSER_TYPE_GENERAL, PARSER_TYPE_FUNCTIONS_ONLY, PARSER_TYPE_COMPLETIONS_ONLY, - PARSER_TYPE_ERRORS_ONLY + PARSER_TYPE_ERRORS_ONLY }; struct profile_item_t { - /** - Time spent executing the specified command, including parse time for nested blocks. - */ - int exec; - /** - Time spent parsing the specified command, including execution time for command substitutions. - */ - int parse; - /** - The block level of the specified command. nested blocks and command substitutions both increase the block level. - */ - size_t level; - /** - If the execution of this command was skipped. - */ - int skipped; - /** - The command string. - */ - wcstring cmd; + /** + Time spent executing the specified command, including parse time for nested blocks. + */ + int exec; + /** + Time spent parsing the specified command, including execution time for command substitutions. + */ + int parse; + /** + The block level of the specified command. nested blocks and command substitutions both increase the block level. + */ + size_t level; + /** + If the execution of this command was skipped. + */ + int skipped; + /** + The command string. + */ + wcstring cmd; }; struct tokenizer; @@ -291,48 +291,48 @@ class parser_t { private: enum parser_type_t parser_type; std::vector<block_t> blocks; - + /** Whether or not we output errors */ const bool show_errors; - + /** Last error code */ int error_code; - + /** Position of last error */ int err_pos; - + /** Description of last error */ wcstring err_buff; - + /** Pointer to the current tokenizer */ tokenizer *current_tokenizer; - + /** String for representing the current line */ wcstring lineinfo; - + /** This is the position of the beginning of the currently parsed command */ int current_tokenizer_pos; - + /** List of called functions, used to help prevent infinite recursion */ wcstring_list_t forbidden_function; - + /** String index where the current job started. */ int job_start_pos; - + /** The jobs associated with this parser */ job_list_t my_job_list; - + /** Keeps track of how many recursive eval calls have been made. Eval doesn't call itself directly, recursion happens on blocks and on command substitutions. */ int eval_level; - + /* No copying allowed */ parser_t(const parser_t&); parser_t& operator=(const parser_t&); - + void parse_job_argument_list( process_t *p, job_t *j, tokenizer *tok, std::vector<completion_t>&, bool ); int parse_job( process_t *p, job_t *j, tokenizer *tok ); void skipped_exec( job_t * j ); @@ -340,10 +340,10 @@ class parser_t { int parser_test_argument( const wchar_t *arg, wcstring *out, const wchar_t *prefix, int offset ); void print_errors( wcstring &target, const wchar_t *prefix ); void print_errors_stderr(); - + public: std::vector<profile_item_t> profile_items; - + /** Returns the name of the currently evaluated function if we are currently evaluating a function, null otherwise. This is tested by @@ -351,27 +351,27 @@ class parser_t { type FUNCTION_CALL. */ const wchar_t *is_function() const; - + /** Get the "principal" parser, whatever that is */ static parser_t &principal_parser(); - + /** Indicates that execution of all blocks in the principal parser should stop. This is called from signal handlers! */ static void skip_all_blocks(); - + /** Create a parser of the given type */ parser_t(enum parser_type_t type, bool show_errors); - + /** The current innermost block, allocated with new */ block_t *current_block; - + /** Global event blocks */ event_blockage_list_t global_event_blocks; - + /** Current block level io redirections */ io_chain_t block_io; - + /** Evaluate the expressions contained in cmd. @@ -382,7 +382,7 @@ class parser_t { \return 0 on success, 1 otherwise */ int eval( const wcstring &cmdStr, const io_chain_t &io, enum block_type_t block_type ); - + /** Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and cmdsubst execution on the tokens. The output is inserted into output, and should be freed by the caller. @@ -390,24 +390,24 @@ class parser_t { \param line Line to evaluate \param output List to insert output to */ - /** - \param line Line to evaluate - \param output List to insert output to - */ - int eval_args( const wchar_t *line, std::vector<completion_t> &output ); + /** + \param line Line to evaluate + \param output List to insert output to + */ + int eval_args( const wchar_t *line, std::vector<completion_t> &output ); /** - Sets the current evaluation error. This function should only be used by libraries that are called by + Sets the current evaluation error. This function should only be used by libraries that are called by \param ec The new error code \param p The character offset at which the error occured \param str The printf-style error message filter */ void error( int ec, int p, const wchar_t *str, ... ); - + /** Returns a string describing the current parser pisition in the format 'FILENAME (line LINE_NUMBER): LINE'. - Example: + Example: init.fish (line 127): ls|grep pancake */ @@ -415,7 +415,7 @@ class parser_t { /** Returns the current line number */ int get_lineno() const; - + /** Returns the line number for the character at the given index */ int line_number_of_character_at_offset(size_t idx) const; @@ -430,7 +430,7 @@ class parser_t { /** Get the string currently parsed */ const wchar_t *get_buffer() const; - + /** Get the list of jobs */ job_list_t &job_list() { return my_job_list; } @@ -445,16 +445,16 @@ class parser_t { /** Create a job */ job_t *job_create(); - + /** Removes a job */ bool job_remove(job_t *job); - + /** Promotes a job to the front of the list */ void job_promote(job_t *job); - + /** Return the job with the specified job id. If id is 0 or less, return the last job used. */ job_t *job_get(int job_id); - + /** Returns the job with the given pid */ job_t *job_get_from_pid( int pid ); @@ -502,7 +502,7 @@ class parser_t { void destroy(); /** - This function checks if the specified string is a help option. + This function checks if the specified string is a help option. \param s the string to test \param min_match is the minimum number of characters that must match in a long style option, i.e. the longest common prefix between --help and any other option. If less than 3, 3 will be assumed. |