Mercurial > octave
changeset 23750:ea879bc55272
move comment_list and comment_elt classes to octave namespace
* comment-list.h, comment-list.cc (class comment_list, class
comment_elt): Move inside octave namespace and rename from
octave_coment_list and octave_comment_elt. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 07 Jul 2017 18:43:32 -0400 |
parents | 6921d8458203 |
children | 0ebc4f1a5714 |
files | libinterp/octave-value/ov-usr-fcn.h libinterp/parse-tree/comment-list.cc libinterp/parse-tree/comment-list.h libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/parse.h libinterp/parse-tree/pt-classdef.h libinterp/parse-tree/pt-eval.h libinterp/parse-tree/pt-except.h libinterp/parse-tree/pt-loop.h libinterp/parse-tree/pt-pr-code.cc libinterp/parse-tree/pt-pr-code.h libinterp/parse-tree/pt-select.h libinterp/parse-tree/pt-stmt.cc libinterp/parse-tree/pt-stmt.h |
diffstat | 16 files changed, 260 insertions(+), 245 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.h Fri Jul 07 18:43:32 2017 -0400 @@ -252,9 +252,9 @@ void stash_parent_fcn_scope (octave::symbol_table::scope *ps); - void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } + void stash_leading_comment (octave::comment_list *lc) { lead_comm = lc; } - void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } + void stash_trailing_comment (octave::comment_list *tc) { trail_comm = tc; } void mark_fcn_file_up_to_date (const octave::sys::time& t) { t_checked = t; } @@ -380,9 +380,9 @@ octave::tree_statement_list * body (void) { return cmd_list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + octave::comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + octave::comment_list * trailing_comment (void) { return trail_comm; } // If is_special_expr is true, retrieve the sigular expression that forms the // body. May be null (even if is_special_expr is true). @@ -425,10 +425,10 @@ octave::tree_statement_list *cmd_list; // The comments preceding the FUNCTION token. - octave_comment_list *lead_comm; + octave::comment_list *lead_comm; // The comments preceding the ENDFUNCTION token. - octave_comment_list *trail_comm; + octave::comment_list *trail_comm; // The name of the file we parsed. std::string file_name;
--- a/libinterp/parse-tree/comment-list.cc Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/comment-list.cc Fri Jul 07 18:43:32 2017 -0400 @@ -29,13 +29,16 @@ #include "comment-list.h" #include "error.h" -octave_comment_list * -octave_comment_list::dup (void) const +namespace octave { - octave_comment_list *new_cl = new octave_comment_list (); + comment_list * + comment_list::dup (void) const + { + comment_list *new_cl = new comment_list (); - for (const auto& elt : *this) - new_cl->append (elt); + for (const auto& elt : *this) + new_cl->append (elt); - return new_cl; + return new_cl; + } }
--- a/libinterp/parse-tree/comment-list.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/comment-list.h Fri Jul 07 18:43:32 2017 -0400 @@ -29,75 +29,88 @@ #include "base-list.h" -extern std::string get_comment_text (void); - -extern char * get_comment_text_c_str (void); - -extern void save_comment_text (const std::string& text); - -class -octave_comment_elt +namespace octave { -public: + extern std::string get_comment_text (void); + + extern char * get_comment_text_c_str (void); - enum comment_type + extern void save_comment_text (const std::string& text); + + class + comment_elt { - unknown, - block, - full_line, - end_of_line, - doc_string, - copyright + public: + + enum comment_type + { + unknown, + block, + full_line, + end_of_line, + doc_string, + copyright + }; + + comment_elt (const std::string& s = "", + comment_type t = unknown) + : txt (s), typ (t) { } + + comment_elt (const comment_elt& oc) + : txt (oc.txt), typ (oc.typ) { } + + comment_elt& operator = (const comment_elt& oc) + { + if (this != &oc) + { + txt = oc.txt; + typ = oc.typ; + } + + return *this; + } + + std::string text (void) const { return txt; } + + comment_type type (void) const { return typ; } + + ~comment_elt (void) = default; + + private: + + // The text of the comment. + std::string txt; + + // The type of comment. + comment_type typ; }; - octave_comment_elt (const std::string& s = "", - comment_type t = unknown) - : txt (s), typ (t) { } - - octave_comment_elt (const octave_comment_elt& oc) - : txt (oc.txt), typ (oc.typ) { } - - octave_comment_elt& operator = (const octave_comment_elt& oc) + class + comment_list : public octave::base_list<comment_elt> { - if (this != &oc) - { - txt = oc.txt; - typ = oc.typ; - } + public: - return *this; - } + comment_list (void) { } - std::string text (void) const { return txt; } - - comment_type type (void) const { return typ; } - - ~octave_comment_elt (void) = default; + void append (const comment_elt& elt) + { octave::base_list<comment_elt>::append (elt); } -private: + void append (const std::string& s, + comment_elt::comment_type t = comment_elt::unknown) + { append (comment_elt (s, t)); } - // The text of the comment. - std::string txt; - - // The type of comment. - comment_type typ; -}; + comment_list * dup (void) const; + }; +} -class -octave_comment_list : public octave::base_list<octave_comment_elt> -{ -public: - - octave_comment_list (void) { } +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) - void append (const octave_comment_elt& elt) - { octave::base_list<octave_comment_elt>::append (elt); } +OCTAVE_DEPRECATED (4.4, "use 'octave::comment_list' instead") +typedef octave::comment_list octave_comment_list; - void append (const std::string& s, - octave_comment_elt::comment_type t = octave_comment_elt::unknown) - { append (octave_comment_elt (s, t)); } - - octave_comment_list * dup (void) const; -}; +OCTAVE_DEPRECATED (4.4, "use 'octave::comment_elt' instead") +typedef octave::comment_elt octave_comment_elt; #endif + +#endif
--- a/libinterp/parse-tree/lex.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/lex.h Fri Jul 07 18:43:32 2017 -0400 @@ -520,39 +520,39 @@ { public: - comment_buffer (void) : comment_list (0) { } + comment_buffer (void) : m_comment_list (0) { } - ~comment_buffer (void) { delete comment_list; } + ~comment_buffer (void) { delete m_comment_list; } - void append (const std::string& s, octave_comment_elt::comment_type t) + void append (const std::string& s, comment_elt::comment_type t) { - if (! comment_list) - comment_list = new octave_comment_list (); + if (! m_comment_list) + m_comment_list = new comment_list (); - comment_list->append (s, t); + m_comment_list->append (s, t); } // Caller is expected to delete the returned value. - octave_comment_list * get_comment (void) + comment_list * get_comment (void) { - octave_comment_list *retval = comment_list; + comment_list *retval = m_comment_list; - comment_list = 0; + m_comment_list = 0; return retval; } void reset (void) { - delete comment_list; + delete m_comment_list; - comment_list = 0; + m_comment_list = 0; } private: - octave_comment_list *comment_list; + comment_list *m_comment_list; }; base_lexer (interpreter *interp = nullptr) @@ -614,9 +614,9 @@ void handle_continuation (void); - void finish_comment (octave_comment_elt::comment_type typ); + void finish_comment (comment_elt::comment_type typ); - octave_comment_list * get_comment (void) { return comment_buf.get_comment (); } + comment_list * get_comment (void) { return comment_buf.get_comment (); } int handle_close_bracket (int bracket_type);
--- a/libinterp/parse-tree/lex.ll Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/lex.ll Fri Jul 07 18:43:32 2017 -0400 @@ -101,7 +101,6 @@ // times. #include "Cell.h" -#include "comment-list.h" #include "defun.h" #include "error.h" #include "errwarn.h" @@ -658,7 +657,7 @@ if (curr_lexer->start_state () == LINE_COMMENT_START) { if (! curr_lexer->comment_text.empty ()) - curr_lexer->finish_comment (octave_comment_elt::full_line); + curr_lexer->finish_comment (octave::comment_elt::full_line); curr_lexer->pop_start_state (); } @@ -696,7 +695,7 @@ if (curr_lexer->block_comment_nesting_level > 1) curr_lexer->comment_text = "\n"; else - curr_lexer->finish_comment (octave_comment_elt::block); + curr_lexer->finish_comment (octave::comment_elt::block); curr_lexer->block_comment_nesting_level--; @@ -789,7 +788,7 @@ { yyless (0); - curr_lexer->finish_comment (octave_comment_elt::full_line); + curr_lexer->finish_comment (octave::comment_elt::full_line); curr_lexer->pop_start_state (); } @@ -800,7 +799,7 @@ if (have_space) curr_lexer->mark_previous_token_trailing_space (); - curr_lexer->finish_comment (octave_comment_elt::end_of_line); + curr_lexer->finish_comment (octave::comment_elt::end_of_line); curr_lexer->pop_start_state (); @@ -818,7 +817,7 @@ curr_lexer->xunput (yytext[0]); - curr_lexer->finish_comment (octave_comment_elt::full_line); + curr_lexer->finish_comment (octave::comment_elt::full_line); curr_lexer->pop_start_state (); } @@ -830,7 +829,7 @@ <LINE_COMMENT_START><<EOF>> { curr_lexer->lexer_debug ("<LINE_COMMENT_START><<EOF>>"); - curr_lexer->finish_comment (octave_comment_elt::full_line); + curr_lexer->finish_comment (octave::comment_elt::full_line); curr_lexer->pop_start_state (); } @@ -2945,7 +2944,7 @@ bool saved_bos = at_beginning_of_statement; - finish_comment (octave_comment_elt::end_of_line); + finish_comment (comment_elt::end_of_line); at_beginning_of_statement = saved_bos; } @@ -2956,7 +2955,7 @@ } void - base_lexer::finish_comment (octave_comment_elt::comment_type typ) + base_lexer::finish_comment (comment_elt::comment_type typ) { bool copyright = looks_like_copyright (comment_text); @@ -2965,7 +2964,7 @@ help_text = comment_text; if (copyright) - typ = octave_comment_elt::copyright; + typ = comment_elt::copyright; comment_buf.append (comment_text, typ);
--- a/libinterp/parse-tree/oct-parse.in.yy Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Jul 07 18:43:32 2017 -0400 @@ -55,7 +55,6 @@ #include "Cell.h" #include "builtin-defun-decls.h" #include "call-stack.h" -#include "comment-list.h" #include "defaults.h" #include "defun.h" #include "dirfns.h" @@ -140,7 +139,7 @@ octave::token *tok_val; // Comment strings that we need to deal with mid-rule. - octave_comment_list *comment_type; + octave::comment_list *comment_type; // Types for the nonterminals we generate. char punct_type; @@ -2701,14 +2700,14 @@ tree_statement_list *body, tree_statement_list *cleanup_stmts, token *end_tok, - octave_comment_list *lc, - octave_comment_list *mc) + comment_list *lc, + comment_list *mc) { tree_command *retval = 0; if (end_token_ok (end_tok, token::unwind_protect_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = unwind_tok->line (); int c = unwind_tok->column (); @@ -2735,14 +2734,14 @@ char catch_sep, tree_statement_list *cleanup_stmts, token *end_tok, - octave_comment_list *lc, - octave_comment_list *mc) + comment_list *lc, + comment_list *mc) { tree_command *retval = 0; if (end_token_ok (end_tok, token::try_catch_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = try_tok->line (); int c = try_tok->column (); @@ -2790,7 +2789,7 @@ tree_expression *expr, tree_statement_list *body, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_command *retval = 0; @@ -2798,7 +2797,7 @@ if (end_token_ok (end_tok, token::while_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); m_lexer.looping--; @@ -2824,11 +2823,11 @@ base_parser::make_do_until_command (token *until_tok, tree_statement_list *body, tree_expression *expr, - octave_comment_list *lc) + comment_list *lc) { maybe_warn_assign_as_truth_value (expr); - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); m_lexer.looping--; @@ -2847,7 +2846,7 @@ tree_expression *maxproc, tree_statement_list *body, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_command *retval = 0; @@ -2857,7 +2856,7 @@ { expr->mark_as_for_cmd_expr (); - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); m_lexer.looping--; @@ -2960,13 +2959,13 @@ base_parser::finish_if_command (token *if_tok, tree_if_command_list *list, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_if_command *retval = 0; if (end_token_ok (end_tok, token::if_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = if_tok->line (); int c = if_tok->column (); @@ -3000,7 +2999,7 @@ base_parser::make_elseif_clause (token *elseif_tok, tree_expression *expr, tree_statement_list *list, - octave_comment_list *lc) + comment_list *lc) { maybe_warn_assign_as_truth_value (expr); @@ -3017,13 +3016,13 @@ tree_expression *expr, tree_switch_case_list *list, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_switch_command *retval = 0; if (end_token_ok (end_tok, token::switch_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = switch_tok->line (); int c = switch_tok->column (); @@ -3058,7 +3057,7 @@ base_parser::make_switch_case (token *case_tok, tree_expression *expr, tree_statement_list *list, - octave_comment_list *lc) + comment_list *lc) { maybe_warn_variable_switch_label (expr); @@ -3235,7 +3234,7 @@ tree_parameter_list *param_list, tree_statement_list *body, tree_statement *end_fcn_stmt, - octave_comment_list *lc) + comment_list *lc) { tree_function_def *retval = 0; @@ -3285,7 +3284,7 @@ if (fcn) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); fcn->stash_trailing_comment (tc); fcn->stash_fcn_end_location (end_fcn_stmt->line (), @@ -3397,7 +3396,7 @@ tree_function_def * base_parser::finish_function (tree_parameter_list *ret_list, octave_user_function *fcn, - octave_comment_list *lc, + comment_list *lc, int l, int c) { tree_function_def *retval = 0; @@ -3542,7 +3541,7 @@ tree_identifier *id, tree_classdef_superclass_list *sc, tree_classdef_body *body, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_classdef *retval = 0; @@ -3571,7 +3570,7 @@ { if (end_token_ok (end_tok, token::classdef_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = tok_val->line (); int c = tok_val->column (); @@ -3601,13 +3600,13 @@ tree_classdef_attribute_list *a, tree_classdef_property_list *plist, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_classdef_properties_block *retval = 0; if (end_token_ok (end_tok, token::properties_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = tok_val->line (); int c = tok_val->column (); @@ -3633,13 +3632,13 @@ tree_classdef_attribute_list *a, tree_classdef_methods_list *mlist, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_classdef_methods_block *retval = 0; if (end_token_ok (end_tok, token::methods_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = tok_val->line (); int c = tok_val->column (); @@ -3665,13 +3664,13 @@ tree_classdef_attribute_list *a, tree_classdef_events_list *elist, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_classdef_events_block *retval = 0; if (end_token_ok (end_tok, token::events_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = tok_val->line (); int c = tok_val->column (); @@ -3697,13 +3696,13 @@ tree_classdef_attribute_list *a, tree_classdef_enum_list *elist, token *end_tok, - octave_comment_list *lc) + comment_list *lc) { tree_classdef_enum_block *retval = 0; if (end_token_ok (end_tok, token::enumeration_end)) { - octave_comment_list *tc = m_lexer.comment_buf.get_comment (); + comment_list *tc = m_lexer.comment_buf.get_comment (); int l = tok_val->line (); int c = tok_val->column (); @@ -3776,7 +3775,7 @@ tree_function_def * base_parser::finish_classdef_external_method (octave_user_function *fcn, tree_parameter_list *ret_list, - octave_comment_list *cl) + comment_list *cl) { if (ret_list) fcn->define_ret_list (ret_list); @@ -4205,7 +4204,7 @@ tree_statement * base_parser::make_statement (T *arg) { - octave_comment_list *comment = m_lexer.get_comment (); + comment_list *comment = m_lexer.get_comment (); return new tree_statement (arg, comment); }
--- a/libinterp/parse-tree/parse.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/parse.h Fri Jul 07 18:43:32 2017 -0400 @@ -38,12 +38,12 @@ #include "pt-misc.h" #include "token.h" -class octave_comment_list; class octave_function; class octave_user_function; namespace octave { + class comment_list; class tree; class tree_anon_fcn_handle; class tree_argument_list; @@ -206,32 +206,32 @@ tree_command * make_unwind_command (token *unwind_tok, tree_statement_list *body, tree_statement_list *cleanup, token *end_tok, - octave_comment_list *lc, octave_comment_list *mc); + comment_list *lc, comment_list *mc); // Build a try-catch command. tree_command * make_try_command (token *try_tok, tree_statement_list *body, char catch_sep, tree_statement_list *cleanup, - token *end_tok, octave_comment_list *lc, - octave_comment_list *mc); + token *end_tok, comment_list *lc, + comment_list *mc); // Build a while command. tree_command * make_while_command (token *while_tok, tree_expression *expr, tree_statement_list *body, token *end_tok, - octave_comment_list *lc); + comment_list *lc); // Build a do-until command. tree_command * make_do_until_command (token *until_tok, tree_statement_list *body, - tree_expression *expr, octave_comment_list *lc); + tree_expression *expr, comment_list *lc); // Build a for command. tree_command * make_for_command (int tok_id, token *for_tok, tree_argument_list *lhs, tree_expression *expr, tree_expression *maxproc, tree_statement_list *body, token *end_tok, - octave_comment_list *lc); + comment_list *lc); // Build a break command. tree_command * make_break_command (token *break_tok); @@ -249,23 +249,23 @@ // Finish an if command. tree_if_command * finish_if_command (token *if_tok, tree_if_command_list *list, - token *end_tok, octave_comment_list *lc); + token *end_tok, comment_list *lc); // Build an elseif clause. tree_if_clause * make_elseif_clause (token *elseif_tok, tree_expression *expr, - tree_statement_list *list, octave_comment_list *lc); + tree_statement_list *list, comment_list *lc); // Finish a switch command. tree_switch_command * finish_switch_command (token *switch_tok, tree_expression *expr, tree_switch_case_list *list, token *end_tok, - octave_comment_list *lc); + comment_list *lc); // Build a switch case. tree_switch_case * make_switch_case (token *case_tok, tree_expression *expr, - tree_statement_list *list, octave_comment_list *lc); + tree_statement_list *list, comment_list *lc); // Build an assignment to a variable. tree_expression * @@ -280,7 +280,7 @@ make_function (token *fcn_tok, tree_parameter_list *ret_list, tree_identifier *id, tree_parameter_list *param_list, tree_statement_list *body, tree_statement *end_fcn_stmt, - octave_comment_list *lc); + comment_list *lc); // Begin defining a function. octave_user_function * @@ -297,7 +297,7 @@ // Finish defining a function. tree_function_def * finish_function (tree_parameter_list *ret_list, - octave_user_function *fcn, octave_comment_list *lc, + octave_user_function *fcn, comment_list *lc, int l, int c); // Reset state after parsing function. @@ -315,31 +315,31 @@ make_classdef (token *tok_val, tree_classdef_attribute_list *a, tree_identifier *id, tree_classdef_superclass_list *sc, tree_classdef_body *body, token *end_tok, - octave_comment_list *lc); + comment_list *lc); tree_classdef_properties_block * make_classdef_properties_block (token *tok_val, tree_classdef_attribute_list *a, tree_classdef_property_list *plist, - token *end_tok, octave_comment_list *lc); + token *end_tok, comment_list *lc); tree_classdef_methods_block * make_classdef_methods_block (token *tok_val, tree_classdef_attribute_list *a, tree_classdef_methods_list *mlist, - token *end_tok, octave_comment_list *lc); + token *end_tok, comment_list *lc); tree_classdef_events_block * make_classdef_events_block (token *tok_val, tree_classdef_attribute_list *a, tree_classdef_events_list *elist, - token *end_tok, octave_comment_list *lc); + token *end_tok, comment_list *lc); tree_classdef_enum_block * make_classdef_enum_block (token *tok_val, tree_classdef_attribute_list *a, tree_classdef_enum_list *elist, - token *end_tok, octave_comment_list *lc); + token *end_tok, comment_list *lc); octave_user_function * start_classdef_external_method (tree_identifier *id, @@ -348,7 +348,7 @@ tree_function_def * finish_classdef_external_method (octave_user_function *fcn, tree_parameter_list *ret_list, - octave_comment_list *cl); + comment_list *cl); // Make an index expression. tree_index_expression *
--- a/libinterp/parse-tree/pt-classdef.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-classdef.h Fri Jul 07 18:43:32 2017 -0400 @@ -27,6 +27,7 @@ class octave_value; +#include "comment-list.h" #include "pt-cmd.h" #include "pt-exp.h" #include "pt-walk.h" @@ -168,7 +169,7 @@ tree_classdef_element (tree_classdef_attribute_list *a, base_list<T> *elist, - octave_comment_list *lc, octave_comment_list *tc, + comment_list *lc, comment_list *tc, int l = -1, int c = -1) : tree (l, c), attr_list (a), elt_list (elist), lead_comm (lc), trail_comm (tc) @@ -192,9 +193,9 @@ base_list<T> * element_list (void) { return elt_list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker&) { } @@ -207,10 +208,10 @@ base_list<T> *elt_list; // Comment preceding the token marking the beginning of the block. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding END token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; class tree_classdef_property @@ -280,8 +281,8 @@ tree_classdef_properties_block (tree_classdef_attribute_list *a, tree_classdef_property_list *plist, - octave_comment_list *lc, - octave_comment_list *tc, + comment_list *lc, + comment_list *tc, int l = -1, int c = -1) : tree_classdef_element<tree_classdef_property *> (a, plist, lc, tc, l, c) { } @@ -332,8 +333,8 @@ tree_classdef_methods_block (tree_classdef_attribute_list *a, tree_classdef_methods_list *mlist, - octave_comment_list *lc, - octave_comment_list *tc, int l = -1, int c = -1) + comment_list *lc, + comment_list *tc, int l = -1, int c = -1) : tree_classdef_element<octave_value> (a, mlist, lc, tc, l, c) { } // No copying! @@ -413,8 +414,8 @@ tree_classdef_events_block (tree_classdef_attribute_list *a, tree_classdef_events_list *elist, - octave_comment_list *lc, - octave_comment_list *tc, int l = -1, int c = -1) + comment_list *lc, + comment_list *tc, int l = -1, int c = -1) : tree_classdef_element<tree_classdef_event *> (a, elist, lc, tc, l, c) { } // No copying! @@ -500,8 +501,8 @@ tree_classdef_enum_block (tree_classdef_attribute_list *a, tree_classdef_enum_list *elist, - octave_comment_list *lc, - octave_comment_list *tc, int l = -1, int c = -1) + comment_list *lc, + comment_list *tc, int l = -1, int c = -1) : tree_classdef_element<tree_classdef_enum *> (a, elist, lc, tc, l, c) { } // No copying! @@ -634,8 +635,8 @@ tree_classdef (tree_classdef_attribute_list *a, tree_identifier *i, tree_classdef_superclass_list *sc, - tree_classdef_body *b, octave_comment_list *lc, - octave_comment_list *tc, + tree_classdef_body *b, comment_list *lc, + comment_list *tc, const std::string& pn = "", int l = -1, int c = -1) : tree_command (l, c), attr_list (a), id (i), @@ -666,8 +667,8 @@ tree_classdef_body * body (void) { return element_list; } - octave_comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * leading_comment (void) { return lead_comm; } + comment_list * trailing_comment (void) { return trail_comm; } const std::string& package_name (void) const { return pack_name; } @@ -689,8 +690,8 @@ tree_classdef_body *element_list; - octave_comment_list *lead_comm; - octave_comment_list *trail_comm; + comment_list *lead_comm; + comment_list *trail_comm; std::string pack_name; };
--- a/libinterp/parse-tree/pt-eval.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-eval.h Fri Jul 07 18:43:32 2017 -0400 @@ -31,7 +31,6 @@ #include <string> #include "call-stack.h" -#include "comment-list.h" #include "ovl.h" #include "pt-exp.h" #include "pt-walk.h"
--- a/libinterp/parse-tree/pt-except.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-except.h Fri Jul 07 18:43:32 2017 -0400 @@ -25,7 +25,6 @@ #include "octave-config.h" -#include "comment-list.h" #include "pt-cmd.h" #include "pt-id.h" #include "pt-walk.h" @@ -33,6 +32,7 @@ namespace octave { + class comment_list; class tree_statement_list; // Simple exception handling. @@ -47,9 +47,9 @@ tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, tree_identifier *id, - octave_comment_list *cl = nullptr, - octave_comment_list *cm = nullptr, - octave_comment_list *ct = nullptr, + comment_list *cl = nullptr, + comment_list *cm = nullptr, + comment_list *ct = nullptr, int l = -1, int c = -1) : tree_command (l, c), try_code (tc), catch_code (cc), expr_id (id), lead_comm (cl), mid_comm (cm), trail_comm (ct) { } @@ -68,11 +68,11 @@ tree_statement_list * cleanup (void) { return catch_code; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * middle_comment (void) { return mid_comm; } + comment_list * middle_comment (void) { return mid_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -91,13 +91,13 @@ tree_identifier *expr_id; // Comment preceding TRY token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding CATCH token. - octave_comment_list *mid_comm; + comment_list *mid_comm; // Comment preceding END_TRY_CATCH token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; // Simple exception handling. @@ -112,9 +112,9 @@ tree_unwind_protect_command (tree_statement_list *tc, tree_statement_list *cc, - octave_comment_list *cl = nullptr, - octave_comment_list *cm = nullptr, - octave_comment_list *ct = nullptr, + comment_list *cl = nullptr, + comment_list *cm = nullptr, + comment_list *ct = nullptr, int l = -1, int c = -1) : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc), lead_comm (cl), mid_comm (cm), trail_comm (ct) { } @@ -132,11 +132,11 @@ tree_statement_list * cleanup (void) { return cleanup_code; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * middle_comment (void) { return mid_comm; } + comment_list * middle_comment (void) { return mid_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -153,13 +153,13 @@ tree_statement_list *cleanup_code; // Comment preceding UNWIND_PROTECT token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding UNWIND_PROTECT_CLEANUP token. - octave_comment_list *mid_comm; + comment_list *mid_comm; // Comment preceding END_UNWIND_PROTECT token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; }
--- a/libinterp/parse-tree/pt-loop.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-loop.h Fri Jul 07 18:43:32 2017 -0400 @@ -27,7 +27,6 @@ class octave_value; -#include "comment-list.h" #include "pt-cmd.h" #include "pt-walk.h" #include "symtab.h" @@ -55,8 +54,8 @@ { } tree_while_command (tree_expression *e, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_command (l, c), expr (e), list (0), lead_comm (lc), trail_comm (tc) @@ -66,8 +65,8 @@ { } tree_while_command (tree_expression *e, tree_statement_list *lst, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_command (l, c), expr (e), list (lst), lead_comm (lc), trail_comm (tc) @@ -88,9 +87,9 @@ tree_statement_list * body (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -119,10 +118,10 @@ tree_statement_list *list; // Comment preceding WHILE token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding ENDWHILE token. - octave_comment_list *trail_comm; + comment_list *trail_comm; private: @@ -142,14 +141,14 @@ : tree_while_command (l, c) { } tree_do_until_command (tree_expression *e, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_while_command (e, lc, tc, l, c) { } tree_do_until_command (tree_expression *e, tree_statement_list *lst, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_while_command (e, lst, lc, tc, l, c) { } @@ -185,8 +184,8 @@ tree_expression *re, tree_expression *maxproc_arg, tree_statement_list *lst, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_command (l, c), parallel (parallel_arg), lhs (le), expr (re), maxproc (maxproc_arg), list (lst), @@ -214,9 +213,9 @@ tree_statement_list * body (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -255,10 +254,10 @@ tree_statement_list *list; // Comment preceding FOR token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding ENDFOR token. - octave_comment_list *trail_comm; + comment_list *trail_comm; #if defined (HAVE_LLVM) // compiled version of the loop @@ -276,8 +275,8 @@ tree_complex_for_command (tree_argument_list *le, tree_expression *re, tree_statement_list *lst, - octave_comment_list *lc = nullptr, - octave_comment_list *tc = nullptr, + comment_list *lc = nullptr, + comment_list *tc = nullptr, int l = -1, int c = -1) : tree_command (l, c), lhs (le), expr (re), list (lst), lead_comm (lc), trail_comm (tc) { } @@ -296,9 +295,9 @@ tree_statement_list * body (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -317,10 +316,10 @@ tree_statement_list *list; // Comment preceding FOR token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding ENDFOR token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; }
--- a/libinterp/parse-tree/pt-pr-code.cc Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-pr-code.cc Fri Jul 07 18:43:32 2017 -0400 @@ -328,7 +328,7 @@ void tree_print_code::visit_octave_user_function_header (octave_user_function& fcn) { - octave_comment_list *leading_comment = fcn.leading_comment (); + comment_list *leading_comment = fcn.leading_comment (); if (leading_comment) { @@ -1218,7 +1218,7 @@ } void - tree_print_code::print_comment_elt (const octave_comment_elt& elt) + tree_print_code::print_comment_elt (const comment_elt& elt) { bool printed_something = false; @@ -1278,15 +1278,15 @@ } void - tree_print_code::print_comment_list (octave_comment_list *comment_list) + tree_print_code::print_comment_list (comment_list *comment_list) { if (comment_list) { - octave_comment_list::iterator p = comment_list->begin (); + comment_list::iterator p = comment_list->begin (); while (p != comment_list->end ()) { - octave_comment_elt elt = *p++; + comment_elt elt = *p++; print_comment_elt (elt); @@ -1297,7 +1297,7 @@ } void - tree_print_code::print_indented_comment (octave_comment_list *comment_list) + tree_print_code::print_indented_comment (comment_list *comment_list) { increment_indent_level ();
--- a/libinterp/parse-tree/pt-pr-code.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-pr-code.h Fri Jul 07 18:43:32 2017 -0400 @@ -28,11 +28,12 @@ #include <stack> #include <string> -#include "comment-list.h" #include "pt-walk.h" namespace octave { + class comment_elt; + class comment_list; class tree_decl_command; class tree_expression; @@ -183,11 +184,11 @@ void print_parens (const tree_expression& expr, const char *txt); - void print_comment_list (octave_comment_list *comment_list); + void print_comment_list (comment_list *comment_list); - void print_comment_elt (const octave_comment_elt& comment_elt); + void print_comment_elt (const comment_elt& comment_elt); - void print_indented_comment (octave_comment_list *comment_list); + void print_indented_comment (comment_list *comment_list); // Must create with an output stream!
--- a/libinterp/parse-tree/pt-select.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-select.h Fri Jul 07 18:43:32 2017 -0400 @@ -45,12 +45,12 @@ tree_if_clause (int l = -1, int c = -1) : tree (l, c), expr (0), list (0), lead_comm (0) { } - tree_if_clause (tree_statement_list *sl, octave_comment_list *lc = nullptr, + tree_if_clause (tree_statement_list *sl, comment_list *lc = nullptr, int l = -1, int c = -1) : tree (l, c), expr (0), list (sl), lead_comm (lc) { } tree_if_clause (tree_expression *e, tree_statement_list *sl, - octave_comment_list *lc = nullptr, + comment_list *lc = nullptr, int l = -1, int c = -1) : tree (l, c), expr (e), list (sl), lead_comm (lc) { } @@ -68,7 +68,7 @@ tree_statement_list * commands (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } void accept (tree_walker& tw) { @@ -84,7 +84,7 @@ tree_statement_list *list; // Comment preceding ELSE or ELSEIF token. - octave_comment_list *lead_comm; + comment_list *lead_comm; }; class tree_if_command_list : public base_list<tree_if_clause *> @@ -124,8 +124,8 @@ tree_if_command (int l = -1, int c = -1) : tree_command (l, c), list (0), lead_comm (0), trail_comm (0) { } - tree_if_command (tree_if_command_list *lst, octave_comment_list *lc, - octave_comment_list *tc, int l = -1, int c = -1) + tree_if_command (tree_if_command_list *lst, comment_list *lc, + comment_list *tc, int l = -1, int c = -1) : tree_command (l, c), list (lst), lead_comm (lc), trail_comm (tc) { } // No copying! @@ -138,9 +138,9 @@ tree_if_command_list * cmd_list (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -153,10 +153,10 @@ tree_if_command_list *list; // Comment preceding IF token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding ENDIF token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; // Switch. @@ -168,12 +168,12 @@ tree_switch_case (int l = -1, int c = -1) : tree (l, c), label (0), list (0), lead_comm (0) { } - tree_switch_case (tree_statement_list *sl, octave_comment_list *lc = nullptr, + tree_switch_case (tree_statement_list *sl, comment_list *lc = nullptr, int l = -1, int c = -1) : tree (l, c), label (0), list (sl), lead_comm (lc) { } tree_switch_case (tree_expression *e, tree_statement_list *sl, - octave_comment_list *lc = nullptr, + comment_list *lc = nullptr, int l = -1, int c = -1) : tree (l, c), label (e), list (sl), lead_comm (lc) { } @@ -191,7 +191,7 @@ tree_statement_list * commands (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } void accept (tree_walker& tw) { @@ -207,7 +207,7 @@ tree_statement_list *list; // Comment preceding CASE or OTHERWISE token. - octave_comment_list *lead_comm; + comment_list *lead_comm; }; class tree_switch_case_list : public base_list<tree_switch_case *> @@ -249,7 +249,7 @@ trail_comm (0) { } tree_switch_command (tree_expression *e, tree_switch_case_list *lst, - octave_comment_list *lc, octave_comment_list *tc, + comment_list *lc, comment_list *tc, int l = -1, int c = -1) : tree_command (l, c), expr (e), list (lst), lead_comm (lc), trail_comm (tc) { } @@ -266,9 +266,9 @@ tree_switch_case_list * case_list (void) { return list; } - octave_comment_list * leading_comment (void) { return lead_comm; } + comment_list * leading_comment (void) { return lead_comm; } - octave_comment_list * trailing_comment (void) { return trail_comm; } + comment_list * trailing_comment (void) { return trail_comm; } void accept (tree_walker& tw) { @@ -284,10 +284,10 @@ tree_switch_case_list *list; // Comment preceding SWITCH token. - octave_comment_list *lead_comm; + comment_list *lead_comm; // Comment preceding ENDSWITCH token. - octave_comment_list *trail_comm; + comment_list *trail_comm; }; }
--- a/libinterp/parse-tree/pt-stmt.cc Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-stmt.cc Fri Jul 07 18:43:32 2017 -0400 @@ -29,6 +29,7 @@ #include "quit.h" #include "bp-table.h" +#include "comment-list.h" #include "input.h" #include "oct-lvalue.h" #include "octave-link.h"
--- a/libinterp/parse-tree/pt-stmt.h Fri Jul 07 18:17:32 2017 -0400 +++ b/libinterp/parse-tree/pt-stmt.h Fri Jul 07 18:43:32 2017 -0400 @@ -31,13 +31,13 @@ #include "base-list.h" #include "bp-table.h" -#include "comment-list.h" #include "pt.h" #include "pt-walk.h" #include "symtab.h" namespace octave { + class comment_list; class tree_command; class tree_expression; @@ -51,10 +51,10 @@ tree_statement (void) : cmd (0), expr (0), comm (0) { } - tree_statement (tree_command *c, octave_comment_list *cl) + tree_statement (tree_command *c, comment_list *cl) : cmd (c), expr (0), comm (cl) { } - tree_statement (tree_expression *e, octave_comment_list *cl) + tree_statement (tree_expression *e, comment_list *cl) : cmd (0), expr (e), comm (cl) { } // No copying! @@ -91,7 +91,7 @@ tree_expression * expression (void) { return expr; } - octave_comment_list * comment_text (void) { return comm; } + comment_list * comment_text (void) { return comm; } bool is_null_statement (void) const { return ! (cmd || expr || comm); } @@ -123,7 +123,7 @@ tree_expression *expr; // Comment associated with this statement. - octave_comment_list *comm; + comment_list *comm; }; // A list of statements to evaluate.