diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-01-15 01:40:40 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-01-15 01:40:40 -0800 |
commit | 53814983ff5404d0d2a53069ed2bc951a85ea0ee (patch) | |
tree | 7b9cbd5e5506d2d6237515bfdf9fd7afa0472d23 /parse_tree.h | |
parent | e2fe8730496eb8019e8f8ace211eeaa596534942 (diff) |
Update style and formatting to conform to fish style guide.
Diffstat (limited to 'parse_tree.h')
-rw-r--r-- | parse_tree.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/parse_tree.h b/parse_tree.h index 530b5c25..255ab467 100644 --- a/parse_tree.h +++ b/parse_tree.h @@ -25,7 +25,7 @@ struct parse_error_t { /** Text of the error */ wcstring text; - + /** Code for the error */ enum parse_error_code_t code; @@ -62,16 +62,16 @@ enum /* Attempt to build a "parse tree" no matter what. This may result in a 'forest' of disconnected trees. This is intended to be used by syntax highlighting. */ parse_flag_continue_after_error = 1 << 0, - + /* Include comment tokens */ parse_flag_include_comments = 1 << 1, - + /* Indicate that the tokenizer should accept incomplete tokens */ parse_flag_accept_incomplete_tokens = 1 << 2, - + /* Indicate that the parser should not generate the terminate token, allowing an 'unfinished' tree where some nodes may have no productions. */ parse_flag_leave_unterminated = 1 << 3 - + }; typedef unsigned int parse_tree_flags_t; @@ -93,7 +93,7 @@ public: /* Length of our range in the source code */ size_t source_length; - + /* Parent */ node_offset_t parent; @@ -123,7 +123,7 @@ public: { return source_start != (size_t)(-1); } - + /* Gets source for the node, or the empty string if it has no source */ wcstring get_source(const wcstring &str) const { @@ -132,7 +132,7 @@ public: else return wcstring(str, this->source_start, this->source_length); } - + /* Returns whether the given location is within the source range or at its end */ bool location_in_or_at_end_of_source_range(size_t loc) const { @@ -149,50 +149,50 @@ public: /* Get the node corresponding to a child of the given node, or NULL if there is no such child. If expected_type is provided, assert that the node has that type. */ const parse_node_t *get_child(const parse_node_t &parent, node_offset_t which, parse_token_type_t expected_type = token_type_invalid) const; - + /* Find the first direct child of the given node of the given type. asserts on failure */ const parse_node_t &find_child(const parse_node_t &parent, parse_token_type_t type) const; - + /* Get the node corresponding to the parent of the given node, or NULL if there is no such child. If expected_type is provided, only returns the parent if it is of that type. Note the asymmetry: get_child asserts since the children are known, but get_parent does not, since the parent may not be known. */ const parse_node_t *get_parent(const parse_node_t &node, parse_token_type_t expected_type = token_type_invalid) const; - + /* Returns the first ancestor of the given type, or NULL. */ const parse_node_t *get_first_ancestor_of_type(const parse_node_t &node, parse_token_type_t desired_type) const; /* Find all the nodes of a given type underneath a given node, up to max_count of them */ typedef std::vector<const parse_node_t *> parse_node_list_t; parse_node_list_t find_nodes(const parse_node_t &parent, parse_token_type_t type, size_t max_count = (size_t)(-1)) const; - + /* Finds the last node of a given type underneath a given node, or NULL if it could not be found. If parent is NULL, this finds the last node in the tree of that type. */ const parse_node_t *find_last_node_of_type(parse_token_type_t type, const parse_node_t *parent = NULL) const; - + /* Finds a node containing the given source location. If 'parent' is not NULL, it must be an ancestor. */ const parse_node_t *find_node_matching_source_location(parse_token_type_t type, size_t source_loc, const parse_node_t *parent) const; - + /* Indicate if the given argument_list or arguments_or_redirections_list is a root list, or has a parent */ bool argument_list_is_root(const parse_node_t &node) const; - + /* Utilities */ - + /* Given a plain statement, get the decoration (from the parent node), or none if there is no decoration */ enum parse_statement_decoration_t decoration_for_plain_statement(const parse_node_t &node) const; - + /* Given a plain statement, get the command by reference (from the child node). Returns true if successful. Clears the command on failure. */ bool command_for_plain_statement(const parse_node_t &node, const wcstring &src, wcstring *out_cmd) const; - + /* Given a plain statement, return true if the statement is part of a pipeline. If include_first is set, the first command in a pipeline is considered part of it; otherwise only the second or additional commands are */ bool statement_is_in_pipeline(const parse_node_t &node, bool include_first) const; - + /* Given a redirection, get the redirection type (or TOK_NONE) and target (file path, or fd) */ enum token_type type_for_redirection(const parse_node_t &node, const wcstring &src, int *out_fd, wcstring *out_target) const; - + /* If the given node is a block statement, returns the header node (for_header, while_header, begin_header, or function_header). Otherwise returns NULL */ const parse_node_t *header_node_for_block_statement(const parse_node_t &node) const; - + /* Given a node list (e.g. of type symbol_job_list) and a node type (e.g. symbol_job), return the next element of the given type in that list, and the tail (by reference). Returns NULL if we've exhausted the list. */ const parse_node_t *next_node_in_node_list(const parse_node_t &node_list, parse_token_type_t item_type, const parse_node_t **list_tail) const; - + /* Given a job, return all of its statements. These are 'specific statements' (e.g. symbol_decorated_statement, not symbol_statement) */ parse_node_list_t specific_statements_for_job(const parse_node_t &job) const; }; @@ -231,7 +231,7 @@ bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t flags, parse case_item_list = <empty> | case_item case_item_list | <TOK_END> case_item_list - + case_item = CASE argument_list STATEMENT_TERMINATOR job_list block_statement = block_header <TOK_END> job_list end_command arguments_or_redirections_list @@ -239,7 +239,7 @@ bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t flags, parse for_header = FOR var_name IN argument_list while_header = WHILE job begin_header = BEGIN - + # Functions take arguments, and require at least one (the name). No redirections allowed. function_header = FUNCTION argument argument_list @@ -258,13 +258,13 @@ bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t flags, parse argument_or_redirection arguments_or_redirections_list argument_or_redirection = argument | redirection argument = <TOK_STRING> - + redirection = <TOK_REDIRECTION> <TOK_STRING> terminator = <TOK_END> | <TOK_BACKGROUND> optional_background = <empty> | <TOK_BACKGROUND> - + end_command = END */ |