Mercurial > hg > octave-lyh
changeset 751:c9f3cb77478d
[project @ 1994-09-30 18:46:17 by jwe]
author | jwe |
---|---|
date | Fri, 30 Sep 1994 18:46:27 +0000 |
parents | 09d3f476c85b |
children | 3dece74ae10c |
files | src/Makefile.in src/parse.y |
diffstat | 2 files changed, 70 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -67,22 +67,22 @@ defun-int.h dirfns.h dynamic-ld.h error.h file-io.h fnmatch.h \ getopt.h gripes.h help.h idx-vector.h input.h lex.h \ load-save.h mappers.h missing-math.h octave.h octave-hist.h \ - oct-obj.h pager.h parse.h pr-output.h procstream.h \ + oct-map.h oct-obj.h pager.h parse.h pr-output.h procstream.h \ sighandlers.h statdefs.h symtab.h sysdep.h token.h \ tree-base.h tree-cmd.h tree-const.h tree-expr.h tree-misc.h \ tree-plot.h tc-rep.h unwind-prot.h user-prefs.h utils.h \ - variables.h version.h xdiv.h xpow.h SLStack.h Stack.h + variables.h version.h xdiv.h xpow.h Map.h SLStack.h Stack.h SOURCES = arith-ops.cc data.cc dirfns.cc dynamic-ld.cc \ error.cc file-io.cc fnmatch.c getopt.c getopt1.c gripes.cc \ help.cc idx-vector.cc input.cc lex.l load-save.cc mappers.cc \ - octave.cc oct-obj.cc octave-hist.cc pager.cc parse.y \ + octave.cc octave-hist.cc oct-obj.cc pager.cc parse.y \ pr-output.cc procstream.cc sighandlers.cc strcasecmp.c \ strncase.c symtab.cc sysdep.cc tc-inlines.cc tc-rep.cc \ - timefns.cc token.cc tree-base.cc tree-cmd.cc tree-const.cc \ - tree-expr.cc tree-misc.cc tree-plot.cc unwind-prot.cc \ - user-prefs.cc utils.cc variables.cc xdiv.cc xpow.cc \ - SLStack.cc \ + tc-rep-ass.cc tc-rep-idx.cc timefns.cc token.cc tree-base.cc \ + tree-cmd.cc tree-const.cc tree-expr.cc tree-misc.cc \ + tree-plot.cc unwind-prot.cc user-prefs.cc utils.cc \ + variables.cc xdiv.cc xpow.cc Map.cc SLStack.cc \ $(DLD_SRC) # Ugh. @@ -106,9 +106,10 @@ idx-vector.o input.o lex.o load-save.o mappers.o octave.o \ octave-hist.o oct-obj.o pager.o parse.o pr-output.o \ procstream.o sighandlers.o strcasecmp.o strncase.o symtab.o \ - sysdep.o tc-rep.o timefns.o token.o tree-base.o tree-cmd.o \ - tree-const.o tree-expr.o tree-plot.o tree-misc.o unwind-prot.o \ - user-prefs.o utils.o variables.o xdiv.o xpow.o SLStack.o + sysdep.o tc-rep.o tc-rep-ass.o tc-rep-idx.o timefns.o token.o \ + tree-base.o tree-cmd.o tree-const.o tree-expr.o tree-plot.o \ + tree-misc.o unwind-prot.o user-prefs.o utils.o variables.o \ + xdiv.o xpow.o Map.o SLStack.o OCTAVE_LIBS = @LIBOCTDLD@ ../liboctave.a ../libcruft.a ../libinfo.a \ ../libreadline.a ../libkpathsea.a @LIBDLD@
--- a/src/parse.y +++ b/src/parse.y @@ -111,6 +111,10 @@ // Nonzero means we're looking at the style part of a plot command. int in_plot_style = 0; +// Nonzero means we're looking at an indirect reference to a structure +// element. +int looking_at_indirect_ref = 0; + // Forward declarations for some functions defined at the bottom of // the file. @@ -132,25 +136,28 @@ static void maybe_warn_assign_as_truth_value (tree_expression *expr); // Build a binary expression. -static tree_expression *make_binary_op (int op, tree_expression *op1, - token *tok_val, - tree_expression *op2); +static tree_expression *make_binary_op + (int op, tree_expression *op1, token *tok_val, tree_expression *op2); // Build a prefix expression. -static tree_expression *make_prefix_op (int op, tree_identifier *op1, - token *tok_val); +static tree_expression *make_prefix_op + (int op, tree_identifier *op1, token *tok_val); // Build a postfix expression. -static tree_expression *make_postfix_op (int op, tree_identifier *op1, - token *tok_val); +static tree_expression *make_postfix_op + (int op, tree_identifier *op1, token *tok_val); // Build a binary expression. -static tree_expression *make_unary_op (int op, tree_expression *op1, - token *tok_val); +static tree_expression *make_unary_op + (int op, tree_expression *op1, token *tok_val); // Make an expression that handles assignment of multiple values. -static tree_expression *make_multi_val_ret (tree_expression *rhs, - int l = -1, int c = -1); +static tree_expression *make_multi_val_ret + (tree_expression *rhs, int l = -1, int c = -1); + +// Make an index expression. +static tree_index_expression *make_index_expression + (tree_indirect_ref *indir, tree_argument_list *args); #define ABORT_PARSE \ do \ @@ -180,6 +187,7 @@ tree_constant *tree_constant_type; tree_matrix *tree_matrix_type; tree_identifier *tree_identifier_type; + tree_indirect_ref *tree_indirect_ref_type; tree_function *tree_function_type; tree_index_expression *tree_index_expression_type; tree_colon_expression *tree_colon_expression_type; @@ -217,6 +225,7 @@ %token <tok_val> TEXT STYLE %token <tok_val> FOR WHILE IF ELSEIF ELSE BREAK CONTINUE FUNC_RET %token <tok_val> GLOBAL +%token <tok_val> TEXT_ID // Other tokens. %token LEXICAL_ERROR @@ -231,6 +240,7 @@ %type <tree_expression_type> ans_expression title %type <tree_matrix_type> matrix %type <tree_identifier_type> identifier +%type <tree_indirect_ref_type> indirect_ref indirect_ref1 %type <tree_function_type> func_def1 func_def2 func_def3 %type <tree_index_expression_type> variable word_list_cmd %type <tree_colon_expression_type> colon_expr @@ -999,22 +1009,28 @@ } ; -variable : identifier +indirect_ref : indirect_ref1 { - $$ = new tree_index_expression - ($1, $1->line (), $1->column ()); + looking_at_indirect_ref = 0; + $$ = $1; } - | identifier '(' arg_list ')' + +indirect_ref1 : identifier { - $$ = new tree_index_expression - ($1, $3, $1->line (), $1->column ()); + $$ = new tree_indirect_ref ($1, $1->line (), + $1->column ()); } - | identifier '(' ')' - { - $$ = new tree_index_expression ($1, 0, $1->line (), - $1->column ()); - } - | identifier '[' + | indirect_ref1 '.' { looking_at_indirect_ref = 1; } TEXT_ID + { $$ = $1->chain ($4->string ()); } + ; + +variable : indirect_ref + { $$ = make_index_expression ($1, 0); } + | indirect_ref '(' ')' + { $$ = make_index_expression ($1, 0); } + | indirect_ref '(' arg_list ')' + { $$ = make_index_expression ($1, $3); } + | indirect_ref '[' { yyerror ("parse error"); error ("use `(\' and `)\' as index operators, not\ @@ -1514,3 +1530,23 @@ return retval; } + +static tree_index_expression * +make_index_expression (tree_indirect_ref *indir, tree_argument_list *args) +{ + tree_index_expression *retval = 0; + + int l = indir->line (); + int c = indir->column (); + + if (indir->is_identifier_only ()) + { + indir->preserve_identifier (); + retval = new tree_index_expression (indir->ident (), args, l, c); + delete indir; + } + else + retval = new tree_index_expression (indir, args, l, c); + + return retval; +}