Mercurial > octave
diff libinterp/parse-tree/pt-exp.h @ 23075:4e3d47dc7e25
move parse tree classes inside octave namespace
* lex.h, lex.ll, oct-parse.in.yy, parse.h, pt-all.h, pt-arg-list.cc,
pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc,
pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc,
pt-cbinop.h, pt.cc, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc,
pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h,
pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h,
pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt.h,
pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h,
pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h,
pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc,
pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, token.cc, token.h:
Move classes and most functions inside octave namespace.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Jan 2017 23:41:54 -0500 |
parents | f75d289645ec |
children | ef4d915df748 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-exp.h Thu Jan 19 14:47:19 2017 -0500 +++ b/libinterp/parse-tree/pt-exp.h Thu Jan 19 23:41:54 2017 -0500 @@ -34,135 +34,143 @@ #include "pt.h" #include "symtab.h" -// A base class for expressions. +namespace octave +{ + // A base class for expressions. -class -tree_expression : public tree -{ -public: + class tree_expression : public tree + { + public: - tree_expression (int l = -1, int c = -1) - : tree (l, c), num_parens (0), postfix_index_type ('\0'), - for_cmd_expr (false), print_flag (false) { } + tree_expression (int l = -1, int c = -1) + : tree (l, c), num_parens (0), postfix_index_type ('\0'), + for_cmd_expr (false), print_flag (false) { } - // No copying! + // No copying! - tree_expression (const tree_expression&) = delete; + tree_expression (const tree_expression&) = delete; - tree_expression& operator = (const tree_expression&) = delete; + tree_expression& operator = (const tree_expression&) = delete; - virtual ~tree_expression (void) = default; + virtual ~tree_expression (void) = default; - virtual bool has_magic_end (void) const = 0; + virtual bool has_magic_end (void) const = 0; - virtual tree_expression *dup (symbol_table::scope_id, - symbol_table::context_id context) const = 0; + virtual tree_expression *dup (symbol_table::scope_id, + symbol_table::context_id context) const = 0; - virtual bool is_constant (void) const { return false; } + virtual bool is_constant (void) const { return false; } - virtual bool is_matrix (void) const { return false; } + virtual bool is_matrix (void) const { return false; } - virtual bool is_cell (void) const { return false; } + virtual bool is_cell (void) const { return false; } - virtual bool is_identifier (void) const { return false; } + virtual bool is_identifier (void) const { return false; } - virtual bool is_index_expression (void) const { return false; } + virtual bool is_index_expression (void) const { return false; } - virtual bool is_assignment_expression (void) const { return false; } + virtual bool is_assignment_expression (void) const { return false; } - virtual bool is_prefix_expression (void) const { return false; } + virtual bool is_prefix_expression (void) const { return false; } - virtual bool is_unary_expression (void) const { return false; } + virtual bool is_unary_expression (void) const { return false; } - virtual bool is_binary_expression (void) const { return false; } + virtual bool is_binary_expression (void) const { return false; } - virtual bool is_boolean_expression (void) const { return false; } + virtual bool is_boolean_expression (void) const { return false; } - virtual bool is_logically_true (const char *); + virtual bool is_logically_true (const char *); - virtual bool lvalue_ok (void) const { return false; } + virtual bool lvalue_ok (void) const { return false; } - virtual bool rvalue_ok (void) const { return false; } + virtual bool rvalue_ok (void) const { return false; } - virtual octave_value rvalue1 (int nargout = 1); + virtual octave_value rvalue1 (int nargout = 1); - virtual octave_value_list rvalue (int nargout); + virtual octave_value_list rvalue (int nargout); - virtual octave_value_list - rvalue (int nargout, const std::list<octave_lvalue> *lvalue_list); + virtual octave_value_list + rvalue (int nargout, const std::list<octave_lvalue> *lvalue_list); - virtual octave_lvalue lvalue (void); + virtual octave_lvalue lvalue (void); - int paren_count (void) const { return num_parens; } + int paren_count (void) const { return num_parens; } - bool is_postfix_indexed (void) const { return (postfix_index_type != '\0'); } + bool is_postfix_indexed (void) const { return (postfix_index_type != '\0'); } - char postfix_index (void) const { return postfix_index_type; } + char postfix_index (void) const { return postfix_index_type; } - // Check if the result of the expression should be printed. - // Should normally be used in conjunction with - // octave::tree_evaluator::statement_printing_enabled. - bool print_result (void) const { return print_flag; } + // Check if the result of the expression should be printed. + // Should normally be used in conjunction with + // octave::tree_evaluator::statement_printing_enabled. + bool print_result (void) const { return print_flag; } + + virtual std::string oper (void) const { return "<unknown>"; } - virtual std::string oper (void) const { return "<unknown>"; } + virtual std::string name (void) const { return "<unknown>"; } - virtual std::string name (void) const { return "<unknown>"; } + virtual std::string original_text (void) const; - virtual std::string original_text (void) const; + virtual void mark_braindead_shortcircuit (void) { } - virtual void mark_braindead_shortcircuit (void) { } + void mark_as_for_cmd_expr (void) { for_cmd_expr = true; } + + bool is_for_cmd_expr (void) const { return for_cmd_expr; } - void mark_as_for_cmd_expr (void) { for_cmd_expr = true; } - - bool is_for_cmd_expr (void) const { return for_cmd_expr; } + tree_expression *mark_in_parens (void) + { + num_parens++; + return this; + } - tree_expression *mark_in_parens (void) - { - num_parens++; - return this; - } + tree_expression *set_postfix_index (char type) + { + postfix_index_type = type; + return this; + } - tree_expression *set_postfix_index (char type) - { - postfix_index_type = type; - return this; - } + tree_expression *set_print_flag (bool print) + { + print_flag = print; + return this; + } - tree_expression *set_print_flag (bool print) - { - print_flag = print; - return this; - } + virtual void copy_base (const tree_expression& e) + { + num_parens = e.num_parens; + postfix_index_type = e.postfix_index_type; + print_flag = e.print_flag; + } - virtual void copy_base (const tree_expression& e) - { - num_parens = e.num_parens; - postfix_index_type = e.postfix_index_type; - print_flag = e.print_flag; - } + protected: -protected: + // A count of the number of times this expression appears directly + // inside a set of parentheses. + // + // (((e1)) + e2) ==> 2 for expression e1 + // ==> 1 for expression ((e1)) + e2 + // ==> 0 for expression e2 + int num_parens; - // A count of the number of times this expression appears directly - // inside a set of parentheses. - // - // (((e1)) + e2) ==> 2 for expression e1 - // ==> 1 for expression ((e1)) + e2 - // ==> 0 for expression e2 - int num_parens; + // The first index type associated with this expression. This field + // is 0 (character '\0') if the expression has no associated index. + // See the code in tree_identifier::rvalue for the rationale. + char postfix_index_type; + + // TRUE if this expression is the EXPR in for loop: + // FOR i = EXPR ... END + bool for_cmd_expr; - // The first index type associated with this expression. This field - // is 0 (character '\0') if the expression has no associated index. - // See the code in tree_identifier::rvalue for the rationale. - char postfix_index_type; + // Print result of rvalue for this expression? + bool print_flag; + }; +} - // TRUE if this expression is the EXPR in for loop: - // FOR i = EXPR ... END - bool for_cmd_expr; +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) - // Print result of rvalue for this expression? - bool print_flag; -}; +OCTAVE_DEPRECATED ("use 'octave::tree_expression' instead") +typedef octave::tree_expression tree_expression; #endif +#endif