Mercurial > hg > octave-terminal
changeset 3485:e5d5848370c9
[project @ 2000-01-28 02:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 28 Jan 2000 02:07:38 +0000 |
parents | 8b1f46ac2b64 |
children | 9493fe321888 |
files | ChangeLog emacs/octave-mod.el src/ChangeLog src/Makefile.in src/parse.y src/pt-loop.cc src/pt-loop.h src/pt-pr-code.cc src/pt-pr-code.h src/pt-walk.h |
diffstat | 10 files changed, 18 insertions(+), 159 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-01-27 John W. Eaton <jwe@bevo.che.wisc.edu> + + * emacs/octave-mod.el (octave-begin-keywords): Add "do". + (octave-end-keywords): Add "until". + (octave-abbrev-table): Add "u" as abbrev for "until ()" + (octave-block-match-alist): Add do-until. + 2000-01-25 John W. Eaton <jwe@bevo.che.wisc.edu> * configure.in: Don't look for the sunmath library.
--- a/emacs/octave-mod.el +++ b/emacs/octave-mod.el @@ -87,6 +87,7 @@ (define-abbrev octave-abbrev-table "`r" "return" nil) (define-abbrev octave-abbrev-table "`s" "switch" nil) (define-abbrev octave-abbrev-table "`t" "try" nil) + (define-abbrev octave-abbrev-table "`u" "until ()" nil) (define-abbrev octave-abbrev-table "`up" "unwind_protect" nil) (define-abbrev octave-abbrev-table "`upc" "unwind_protect_cleanup" nil) (define-abbrev octave-abbrev-table "`w" "while ()" nil) @@ -101,12 +102,12 @@ "Regexp to match the start of an Octave comment up to its body.") (defvar octave-begin-keywords - '("for" "function" "if" "switch" "try" "unwind_protect" "while")) + '("do" "for" "function" "if" "switch" "try" "unwind_protect" "while")) (defvar octave-else-keywords '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup")) (defvar octave-end-keywords '("end" "endfor" "endfunction" "endif" "endswitch" "end_try_catch" - "end_unwind_protect" "endwhile")) + "end_unwind_protect" "endwhile" "until")) (defvar octave-reserved-words (append octave-begin-keywords @@ -353,7 +354,8 @@ (defvar octave-block-else-or-end-regexp (concat octave-block-else-regexp "\\|" octave-block-end-regexp)) (defvar octave-block-match-alist - '(("for" . ("end" "endfor")) + '(("do" . ("until")) + ("for" . ("end" "endfor")) ("function" . ("end" "endfunction")) ("if" . ("else" "elseif" "end" "endif")) ("switch" . ("case" "otherwise" "end" "endswitch"))
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,19 +1,14 @@ 2000-01-27 John W. Eaton <jwe@bevo.che.wisc.edu> - * pt-walk.h (tree_walker::visit_do_while_command): New pure virtual. - (tree_walker::visit_do_until_command): Ditto. - * pt-pr-code.cc (tree_print_code::visit_do_while_command): + * pt-walk.h (tree_walker::visit_do_until_command): New pure virtual. + * pt-pr-code.cc (tree_print_code::visit_do_until_command): New function. - (tree_print_code::visit_do_until_command): Ditto. - * pt-loop.h (tree_do_while_command): New class. - (tree_do_until_command): Ditto. + * pt-loop.h (tree_do_until_command): New class. (tree_while_command::expr, tree_while_command::list): Now protected instead of private. - * parse.y (make_do_while_command): New function. - (make_do_until_command): Ditto. - (loop_command): Recognize do-while and do-until statements. + * parse.y (make_do_until_command): New function. + (loop_command): Recognize do-until statement. (DO, UNTIL): New tokens. - * Makefile.in (parse.cc): Expect 13 shift/reduce conflicts. * input.cc (match_sans_spaces): Require non-blank part of test string to match standard string exactly.
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -437,7 +437,7 @@ # Special rules -- these files need special things to be defined. parse.cc : parse.y - @echo "expect 13 shift/reduce conflicts" + @echo "expect 11 shift/reduce conflicts" $(YACC) $(YFLAGS) $< @$(top_srcdir)/move-if-change y.tab.c $(@F)
--- a/src/parse.y +++ b/src/parse.y @@ -186,11 +186,6 @@ make_while_command (token *while_tok, tree_expression *expr, tree_statement_list *body, token *end_tok); -// Build a do-while command. -static tree_command * -make_do_while_command (token *do_tok, tree_statement_list *body, - tree_expression *expr); - // Build a do-until command. static tree_command * make_do_until_command (token *do_tok, tree_statement_list *body, @@ -959,11 +954,6 @@ if (! ($$ = make_while_command ($1, $2, $4, $5))) ABORT_PARSE; } - | DO opt_sep opt_list WHILE expression - { - if (! ($$ = make_do_while_command ($1, $3, $5))) - ABORT_PARSE; - } | DO opt_sep opt_list UNTIL expression { if (! ($$ = make_do_until_command ($1, $3, $5))) @@ -2092,28 +2082,6 @@ return retval; } -// Build a do-while command. - -static tree_command * -make_do_while_command (token *do_tok, tree_statement_list *body, - tree_expression *expr) -{ - tree_command *retval = 0; - - maybe_warn_assign_as_truth_value (expr); - - // We have to do this because while can also be used to begin a loop. - lexer_flags.looping -= 2; - promptflag++; - - int l = do_tok->line (); - int c = do_tok->column (); - - retval = new tree_do_while_command (expr, body, l, c); - - return retval; -} - // Build a do-until command. static tree_command *
--- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -115,49 +115,6 @@ tw.visit_while_command (*this); } -// Do-While - -void -tree_do_while_command::eval (void) -{ - if (error_state) - return; - - if (! expr) - panic_impossible (); - - for (;;) - { - if (list) - { - list->eval (); - - if (error_state) - { - eval_error (); - return; - } - } - - if (quit_loop_now () || ! expr->is_logically_true ("do-while")) - break; - } -} - -void -tree_do_while_command::eval_error (void) -{ - if (error_state > 0) - ::error ("evaluating do-while command near line %d, column %d", - line (), column ()); -} - -void -tree_do_while_command::accept (tree_walker& tw) -{ - tw.visit_do_while_command (*this); -} - // Do-Until void
--- a/src/pt-loop.h +++ b/src/pt-loop.h @@ -84,40 +84,6 @@ tree_while_command& operator = (const tree_while_command&); }; -// Do-While. - -class -tree_do_while_command : public tree_while_command -{ -public: - - tree_do_while_command (int l = -1, int c = -1) - : tree_while_command (l, c) { } - - tree_do_while_command (tree_expression *e, int l = -1, int c = -1) - : tree_while_command (e, l, c) { } - - tree_do_while_command (tree_expression *e, tree_statement_list *lst, - int l = -1, int c = -1) - : tree_while_command (e, lst, l, c) { } - - ~tree_do_while_command (void) { } - - void eval (void); - - void eval_error (void); - - void accept (tree_walker& tw); - -private: - - // No copying! - - tree_do_while_command (const tree_do_while_command&); - - tree_do_while_command& operator = (const tree_do_while_command&); -}; - // Do-Until. class
--- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -1102,36 +1102,6 @@ } void -tree_print_code::visit_do_while_command (tree_do_while_command& cmd) -{ - indent (); - - os << "do"; - - newline (); - - tree_statement_list *list = cmd.body (); - - if (list) - { - increment_indent_level (); - list->accept (*this); - decrement_indent_level (); - } - - indent (); - - os << "while"; - - tree_expression *expr = cmd.condition (); - - if (expr) - expr->accept (*this); - - newline (); -} - -void tree_print_code::visit_do_until_command (tree_do_until_command& cmd) { indent ();
--- a/src/pt-pr-code.h +++ b/src/pt-pr-code.h @@ -138,8 +138,6 @@ void visit_while_command (tree_while_command&); - void visit_do_while_command (tree_do_while_command&); - void visit_do_until_command (tree_do_until_command&); private:
--- a/src/pt-walk.h +++ b/src/pt-walk.h @@ -68,7 +68,6 @@ class tree_unwind_protect_command; class tree_while_command; class tree_do_until_command; -class tree_do_while_command; class tree_walker @@ -208,9 +207,6 @@ visit_while_command (tree_while_command&) = 0; virtual void - visit_do_while_command (tree_do_while_command&) = 0; - - virtual void visit_do_until_command (tree_do_until_command&) = 0; protected: