Mercurial > hg > octave-nkf
diff libinterp/parse-tree/pt-exp.h @ 15954:46ca8488de92 classdef
Re-engineer tree_expression postfix handling to make it more flexible.
* libinterp/octave-value/ov-fcn.h (octave_function::is_postfix_index_handled):
New method.
* libinterp/parse-tree/oct-parse.yy
(make_index_expression, make_indirect_ref): Set expression postfix index type.
* libinterp/parse-tree/pt-exp.h (tree_expression::postfix_index): Remove field.
(tree_expression::postfix_index_type): New field.
(tree_expression::tree_expression): Initialize it.
(tree_expression::copy_base): Copy it.
(tree_expression::set_postfix_index, tree_expression::postfix_index): New
methods.
(tree_expression::mark_postfix_indexed): Remove method.
(tree_expression::is_postfix_indexed): Use postfix_index_type field.
* libinterp/parse-tree/pt-id.cc (tree_identifier::rvalue): Let the function
object determine whether it can handle the first postfix index and call
do_multi_index_op if it can't.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Tue, 15 Jan 2013 17:01:10 -0500 |
parents | fb9dffe5fbfb |
children | 3c265e4dba6d |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-exp.h +++ b/libinterp/parse-tree/pt-exp.h @@ -40,7 +40,7 @@ public: tree_expression (int l = -1, int c = -1) - : tree (l, c), num_parens (0), postfix_indexed (false), + : tree (l, c), num_parens (0), postfix_index_type ('\0'), print_flag (false) { } virtual ~tree_expression (void) { } @@ -85,7 +85,9 @@ int paren_count (void) const { return num_parens; } - bool is_postfix_indexed (void) const { return postfix_indexed; } + bool is_postfix_indexed (void) const { return (postfix_index_type != '\0'); } + + 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 @@ -106,9 +108,9 @@ return this; } - tree_expression *mark_postfix_indexed (void) + tree_expression *set_postfix_index (char type) { - postfix_indexed = true; + postfix_index_type = type; return this; } @@ -121,7 +123,7 @@ virtual void copy_base (const tree_expression& e) { num_parens = e.num_parens; - postfix_indexed = e.postfix_indexed; + postfix_index_type = e.postfix_index_type; print_flag = e.print_flag; } @@ -135,9 +137,10 @@ // ==> 0 for expression e2 int num_parens; - // A flag that says whether this expression has an index associated - // with it. See the code in tree_identifier::rvalue for the rationale. - bool postfix_indexed; + // 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;