# HG changeset patch # User jwe # Date 949025258 0 # Node ID e5d5848370c90301b235746356125cce69495691 # Parent 8b1f46ac2b6498999a41384367fc211e3f41cc32 [project @ 2000-01-28 02:07:35 by jwe] diff -r 8b1f46ac2b64 -r e5d5848370c9 ChangeLog --- a/ChangeLog Thu Jan 27 23:30:48 2000 +0000 +++ b/ChangeLog Fri Jan 28 02:07:38 2000 +0000 @@ -1,3 +1,10 @@ +2000-01-27 John W. Eaton + + * 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 * configure.in: Don't look for the sunmath library. diff -r 8b1f46ac2b64 -r e5d5848370c9 emacs/octave-mod.el --- a/emacs/octave-mod.el Thu Jan 27 23:30:48 2000 +0000 +++ b/emacs/octave-mod.el Fri Jan 28 02:07:38 2000 +0000 @@ -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")) diff -r 8b1f46ac2b64 -r e5d5848370c9 src/ChangeLog --- a/src/ChangeLog Thu Jan 27 23:30:48 2000 +0000 +++ b/src/ChangeLog Fri Jan 28 02:07:38 2000 +0000 @@ -1,19 +1,14 @@ 2000-01-27 John W. Eaton - * 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. diff -r 8b1f46ac2b64 -r e5d5848370c9 src/Makefile.in --- a/src/Makefile.in Thu Jan 27 23:30:48 2000 +0000 +++ b/src/Makefile.in Fri Jan 28 02:07:38 2000 +0000 @@ -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) diff -r 8b1f46ac2b64 -r e5d5848370c9 src/parse.y --- a/src/parse.y Thu Jan 27 23:30:48 2000 +0000 +++ b/src/parse.y Fri Jan 28 02:07:38 2000 +0000 @@ -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 * diff -r 8b1f46ac2b64 -r e5d5848370c9 src/pt-loop.cc --- a/src/pt-loop.cc Thu Jan 27 23:30:48 2000 +0000 +++ b/src/pt-loop.cc Fri Jan 28 02:07:38 2000 +0000 @@ -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 diff -r 8b1f46ac2b64 -r e5d5848370c9 src/pt-loop.h --- a/src/pt-loop.h Thu Jan 27 23:30:48 2000 +0000 +++ b/src/pt-loop.h Fri Jan 28 02:07:38 2000 +0000 @@ -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 diff -r 8b1f46ac2b64 -r e5d5848370c9 src/pt-pr-code.cc --- a/src/pt-pr-code.cc Thu Jan 27 23:30:48 2000 +0000 +++ b/src/pt-pr-code.cc Fri Jan 28 02:07:38 2000 +0000 @@ -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 (); diff -r 8b1f46ac2b64 -r e5d5848370c9 src/pt-pr-code.h --- a/src/pt-pr-code.h Thu Jan 27 23:30:48 2000 +0000 +++ b/src/pt-pr-code.h Fri Jan 28 02:07:38 2000 +0000 @@ -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: diff -r 8b1f46ac2b64 -r e5d5848370c9 src/pt-walk.h --- a/src/pt-walk.h Thu Jan 27 23:30:48 2000 +0000 +++ b/src/pt-walk.h Fri Jan 28 02:07:38 2000 +0000 @@ -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: