Mercurial > hg > octave-terminal
changeset 482:680426c10c5e
[project @ 1994-06-30 15:23:09 by jwe]
author | jwe |
---|---|
date | Thu, 30 Jun 1994 15:23:09 +0000 |
parents | 376ac108f611 |
children | 41a70d08c1f7 |
files | src/parse.y src/pt-base.h src/pt-const.cc src/pt-const.h src/t-builtins.cc src/t-builtins.h src/tree.h.old |
diffstat | 7 files changed, 88 insertions(+), 147 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parse.y +++ b/src/parse.y @@ -151,12 +151,10 @@ tree_colon_expression *tree_colon_expression_type; tree_argument_list *tree_argument_list_type; tree_parameter_list *tree_parameter_list_type; - tree_word_list *tree_word_list_type; tree_command *tree_command_type; tree_if_command *tree_if_command_type; tree_global_command *tree_global_command_type; tree_command_list *tree_command_list_type; - tree_word_list_command *tree_word_list_command_type; tree_plot_command *tree_plot_command_type; tree_subplot_list *tree_subplot_list_type; tree_plot_limits *tree_plot_limits_type; @@ -193,16 +191,14 @@ %type <tree_matrix_type> matrix %type <tree_identifier_type> identifier %type <tree_function_type> func_def func_def1 func_def2 func_def3 -%type <tree_index_expression_type> variable +%type <tree_index_expression_type> variable word_list_cmd %type <tree_colon_expression_type> colon_expr -%type <tree_argument_list_type> arg_list arg_list1 +%type <tree_argument_list_type> arg_list arg_list1 word_list word_list1 %type <tree_parameter_list_type> param_list param_list1 func_def1a -%type <tree_word_list_type> word_list word_list1 %type <tree_command_type> statement %type <tree_if_command_type> elseif %type <tree_global_command_type> global_decl global_decl1 %type <tree_command_list_type> simple_list simple_list1 list list1 opt_list -%type <tree_word_list_command_type> word_list_cmd %type <tree_plot_command_type> plot_command %type <tree_subplot_list_type> plot_command1 plot_command2 plot_options %type <tree_plot_limits_type> ranges @@ -855,7 +851,10 @@ ; word_list_cmd : identifier word_list - { $$ = new tree_word_list_command ($1, $2); } + { + $$ = new tree_index_expression + ($1, $2, $1->line (), $1->column ()); + } ; word_list : word_list1 @@ -863,9 +862,15 @@ ; word_list1 : TEXT - { $$ = new tree_word_list ($1->string ()); } + { + tree_constant *tmp = new tree_constant ($1->string ()); + $$ = new tree_argument_list (tmp); + } | word_list1 TEXT - { $$ = $1->chain ($2->string ()); } + { + tree_constant *tmp = new tree_constant ($2->string ()); + $$ = $1->chain (tmp); + } ; // This is truly disgusting.
--- a/src/pt-base.h +++ b/src/pt-base.h @@ -144,10 +144,8 @@ virtual tree_constant *eval (int print, int nargout); - virtual tree_constant eval (int argc, char **argv, int print); - - virtual tree_constant *eval (const tree_constant *args, int n_in, int nout, - int print) + virtual tree_constant *eval (const tree_constant *args, int nargin, + int nargout, int print) { assert (0); return NULL_TREE_CONST; } virtual int save (ostream& os, int mark_as_global = 0,
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -2520,13 +2520,6 @@ } } -tree_constant -tree_constant::eval (int argc, char **argv, int print) -{ - ::error ("first element of word-list command is a constant"); - return tree_constant (); -} - #if defined (MDEBUG) void * tree_constant::operator new (size_t size)
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -197,7 +197,7 @@ #ifndef TREE_FCN_TYPEDEFS #define TREE_FCN_TYPEDEFS 1 -typedef tree_constant (*Text_fcn)(int, char **); +typedef tree_constant* (*Text_fcn)(int, char **, int); typedef tree_constant* (*General_fcn)(tree_constant *, int, int); #endif @@ -762,8 +762,6 @@ return retval; } - tree_constant eval (int argc, char **argv, int print); - tree_constant *eval (const tree_constant *args, int n_in, int n_out, int print) { return rep->eval (args, n_in, n_out, print); }
--- a/src/t-builtins.cc +++ b/src/t-builtins.cc @@ -174,10 +174,10 @@ return os; } -tree_constant -builtin_casesen (int argc, char **argv) +tree_constant * +builtin_casesen (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; if (argc == 1 || (argc > 1 && strcmp (argv[1], "off") == 0)) warning ("casesen: sorry, Octave is always case sensitive"); @@ -192,10 +192,10 @@ /* * Change current working directory. */ -tree_constant -builtin_cd (int argc, char **argv) +tree_constant * +builtin_cd (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; if (argc > 1) { @@ -251,10 +251,10 @@ * Wipe out user-defined variables and functions given a list of * globbing patterns. */ -tree_constant -builtin_clear (int argc, char **argv) +tree_constant * +builtin_clear (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; // Always clear the local table, but don't clear currently compiled // functions unless we are at the top level. (Allowing that to happen @@ -328,10 +328,10 @@ /* * Associate a cryptic message with a variable name. */ -tree_constant -builtin_document (int argc, char **argv) +tree_constant * +builtin_document (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; if (argc == 3) document_symbol (argv[1], argv[2]); else @@ -342,10 +342,10 @@ /* * Edit commands with your favorite editor. */ -tree_constant -builtin_edit_history (int argc, char **argv) +tree_constant * +builtin_edit_history (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; do_edit_history (argc, argv); return retval; } @@ -353,10 +353,10 @@ /* * Set output format state. */ -tree_constant -builtin_format (int argc, char **argv) +tree_constant * +builtin_format (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; set_format_style (argc, argv); return retval; } @@ -488,10 +488,10 @@ /* * Print cryptic yet witty messages. */ -tree_constant -builtin_help (int argc, char **argv) +tree_constant * +builtin_help (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; if (argc == 1) { @@ -623,10 +623,10 @@ /* * Display, save, or load history. */ -tree_constant -builtin_history (int argc, char **argv) +tree_constant * +builtin_history (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; do_history (argc, argv); @@ -637,10 +637,10 @@ * Change state flag that determines whether lines are added to plots * or drawn on new plots. */ -tree_constant -builtin_hold (int argc, char **argv) +tree_constant * +builtin_hold (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; switch (argc) { @@ -809,10 +809,10 @@ * * -- This function is not terribly robust. */ -tree_constant -builtin_load (int argc, char **argv) +tree_constant * +builtin_load (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; argc--; argv++; @@ -895,10 +895,10 @@ /* * Get a directory listing. */ -tree_constant -builtin_ls (int argc, char **argv) +tree_constant * +builtin_ls (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; ostrstream ls_buf; @@ -929,10 +929,10 @@ /* * Run previous commands from the history list. */ -tree_constant -builtin_run_history (int argc, char **argv) +tree_constant * +builtin_run_history (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; do_run_history (argc, argv); return retval; } @@ -979,10 +979,10 @@ /* * Write variables to an output stream. */ -tree_constant -builtin_save (int argc, char **argv) +tree_constant * +builtin_save (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; if (argc < 2) { @@ -1082,10 +1082,10 @@ /* * Set plotting options. */ -tree_constant -builtin_set (int argc, char **argv) +tree_constant * +builtin_set (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; ostrstream plot_buf; @@ -1113,10 +1113,10 @@ /* * Set plotting options. */ -tree_constant -builtin_show (int argc, char **argv) +tree_constant * +builtin_show (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; ostrstream plot_buf; @@ -1205,10 +1205,10 @@ return status; } -tree_constant -builtin_who (int argc, char **argv) +tree_constant * +builtin_who (int argc, char **argv, int nargout) { - tree_constant retval; + tree_constant *retval = NULL_TREE_CONST; int show_builtins = 0; int show_functions = (curr_sym_tab == top_level_sym_tab);
--- a/src/t-builtins.h +++ b/src/t-builtins.h @@ -34,22 +34,23 @@ char *help_string; }; -extern tree_constant builtin_casesen (int, char **); -extern tree_constant builtin_cd (int, char **); -extern tree_constant builtin_clear (int, char **); -extern tree_constant builtin_document (int, char **); -extern tree_constant builtin_edit_history (int, char **); -extern tree_constant builtin_format (int, char **); -extern tree_constant builtin_help (int, char **); -extern tree_constant builtin_history (int, char **); -extern tree_constant builtin_hold (int, char **); -extern tree_constant builtin_load (int, char **); -extern tree_constant builtin_ls (int, char **); -extern tree_constant builtin_run_history (int, char **); -extern tree_constant builtin_save (int, char **); -extern tree_constant builtin_set (int, char **); -extern tree_constant builtin_show (int, char **); -extern tree_constant builtin_who (int, char **); +extern tree_constant *builtin_casesen (int argc, char **argv, int nargout); +extern tree_constant *builtin_cd (int argc, char **argv, int nargout); +extern tree_constant *builtin_clear (int argc, char **argv, int nargout); +extern tree_constant *builtin_document (int argc, char **argv, int nargout); +extern tree_constant *builtin_edit_history (int argc, char **argv, + int nargout); +extern tree_constant *builtin_format (int argc, char **argv, int nargout); +extern tree_constant *builtin_help (int argc, char **argv, int nargout); +extern tree_constant *builtin_history (int argc, char **argv, int nargout); +extern tree_constant *builtin_hold (int argc, char **argv, int nargout); +extern tree_constant *builtin_load (int argc, char **argv, int nargout); +extern tree_constant *builtin_ls (int argc, char **argv, int nargout); +extern tree_constant *builtin_run_history (int argc, char **argv, int nargout); +extern tree_constant *builtin_save (int argc, char **argv, int nargout); +extern tree_constant *builtin_set (int argc, char **argv, int nargout); +extern tree_constant *builtin_show (int argc, char **argv, int nargout); +extern tree_constant *builtin_who (int argc, char **argv, int nargout); #endif
--- a/src/tree.h.old +++ b/src/tree.h.old @@ -78,7 +78,6 @@ class tree_argument_list; class tree_parameter_list; class tree_return_list; -class tree_word_list; class tree_command; class tree_command_list; class tree_global_command; @@ -88,7 +87,6 @@ class tree_break_command; class tree_continue_command; class tree_return_command; -class tree_word_list_command;; class tree_plot_limits; class tree_plot_range; class tree_subplot; @@ -150,10 +148,8 @@ tree_constant *eval (int print, int nargout); - tree_constant eval (int argc, char **argv, int print); - - tree_constant *eval (const tree_constant *args, int n_in, int n_out, - int print); + tree_constant *eval (const tree_constant *args, int nargin, + int nargout, int print); char *name (void) const; @@ -211,10 +207,8 @@ tree_constant *eval (int print, int nargout); - tree_constant eval (int argc, char **argv, int print); - - tree_constant *eval (const tree_constant *args, int n_in, int n_out, - int print); + tree_constant *eval (const tree_constant *args, int nargin, + int nargout, int print); void eval_undefined_error (void); @@ -259,10 +253,8 @@ tree_constant *eval (int print, int nargout); - tree_constant eval (int argc, char **argv, int print); - - tree_constant *eval (const tree_constant *args, int n_in, int n_out, - int print); + tree_constant *eval (const tree_constant *args, int nargin, + int nargout, int print); int max_expected_args (void); @@ -612,33 +604,6 @@ }; /* - * Word lists. - */ -class -tree_word_list : public tree -{ - public: - tree_word_list (void); - tree_word_list (char *s); - - ~tree_word_list (void); - - tree_word_list *chain (char *s); - tree_word_list *reverse (void); - int length (void); - - char *name (void) const; - - tree_word_list *next_elem (void); - - tree_constant eval (int print); - - private: - char *word; - tree_word_list *next; -}; - -/* * A base class for commands. */ class @@ -814,25 +779,6 @@ tree_constant eval (int print); }; -/* - * Functions that take a list of strings as arguments. - */ -class -tree_word_list_command : public tree_command -{ - public: - tree_word_list_command (void); - tree_word_list_command (tree_identifier *id, tree_word_list *wl); - - ~tree_word_list_command (void); - - tree_constant eval (int print); - - private: - tree_identifier *ident; - tree_word_list *word_list; -}; - #endif /*