comparison libinterp/parse-tree/oct-parse.in.yy @ 17653:bb2fa6e5b348 classdef

maint: periodic merge of default to classdef
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 14 Oct 2013 15:00:12 -0400
parents c702371ff6df bd0a84de3375
children d7da5afcdb22
comparison
equal deleted inserted replaced
17650:a98902bda11a 17653:bb2fa6e5b348
258 %type <tree_anon_fcn_handle_type> anon_fcn_handle 258 %type <tree_anon_fcn_handle_type> anon_fcn_handle
259 %type <tree_fcn_handle_type> fcn_handle 259 %type <tree_fcn_handle_type> fcn_handle
260 %type <tree_matrix_type> matrix_rows 260 %type <tree_matrix_type> matrix_rows
261 %type <tree_cell_type> cell_rows 261 %type <tree_cell_type> cell_rows
262 %type <tree_expression_type> matrix cell 262 %type <tree_expression_type> matrix cell
263 %type <tree_expression_type> primary_expr oper_expr 263 %type <tree_expression_type> primary_expr oper_expr power_expr
264 %type <tree_expression_type> simple_expr colon_expr assign_expr expression 264 %type <tree_expression_type> simple_expr colon_expr assign_expr expression
265 %type <tree_identifier_type> identifier fcn_name magic_tilde 265 %type <tree_identifier_type> identifier fcn_name magic_tilde
266 %type <tree_funcall_type> superclass_identifier meta_identifier 266 %type <tree_funcall_type> superclass_identifier meta_identifier
267 %type <octave_user_function_type> function1 function2 267 %type <octave_user_function_type> function1 function2
268 %type <tree_index_expression_type> word_list_cmd 268 %type <tree_index_expression_type> word_list_cmd
319 %right UNARY EXPR_NOT 319 %right UNARY EXPR_NOT
320 %left POW EPOW HERMITIAN TRANSPOSE 320 %left POW EPOW HERMITIAN TRANSPOSE
321 %right PLUS_PLUS MINUS_MINUS 321 %right PLUS_PLUS MINUS_MINUS
322 %left '(' '.' '{' 322 %left '(' '.' '{'
323 323
324 // How to clean up if there is a parse error. We handle deleting tokens
325 // and comments seperately and separators are just characters. The
326 // remaining items are dynamically allocated parse tree objects that
327 // must be deleted.
328 %destructor { } <sep_type> <tok_val> <comment_type> <dummy_type> <>
329 %destructor { delete $$; } <*>
330
324 // Where to start. 331 // Where to start.
325 %start input 332 %start input
326 333
327 %% 334 %%
328 335
391 398
392 word_list_cmd : identifier word_list 399 word_list_cmd : identifier word_list
393 { 400 {
394 $$ = parser.make_index_expression ($1, $2, '('); 401 $$ = parser.make_index_expression ($1, $2, '(');
395 if (! $$) 402 if (! $$)
396 ABORT_PARSE; 403 {
404 // make_index_expression deleted $1 and $2.
405 ABORT_PARSE;
406 }
397 } 407 }
398 ; 408 ;
399 409
400 word_list : string 410 word_list : string
401 { $$ = new tree_argument_list ($1); } 411 { $$ = new tree_argument_list ($1); }
596 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } 606 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); }
597 | oper_expr '(' ')' 607 | oper_expr '(' ')'
598 { 608 {
599 $$ = parser.make_index_expression ($1, 0, '('); 609 $$ = parser.make_index_expression ($1, 0, '(');
600 if (! $$) 610 if (! $$)
601 ABORT_PARSE; 611 {
612 // make_index_expression deleted $1.
613 ABORT_PARSE;
614 }
602 } 615 }
603 | oper_expr '(' arg_list ')' 616 | oper_expr '(' arg_list ')'
604 { 617 {
605 $$ = parser.make_index_expression ($1, $3, '('); 618 $$ = parser.make_index_expression ($1, $3, '(');
606 if (! $$) 619 if (! $$)
607 ABORT_PARSE; 620 {
621 // make_index_expression deleted $1 and $3.
622 ABORT_PARSE;
623 }
608 } 624 }
609 | oper_expr '{' '}' 625 | oper_expr '{' '}'
610 { 626 {
611 $$ = parser.make_index_expression ($1, 0, '{'); 627 $$ = parser.make_index_expression ($1, 0, '{');
612 if (! $$) 628 if (! $$)
613 ABORT_PARSE; 629 {
630 // make_index_expression deleted $1.
631 ABORT_PARSE;
632 }
614 } 633 }
615 | oper_expr '{' arg_list '}' 634 | oper_expr '{' arg_list '}'
616 { 635 {
617 $$ = parser.make_index_expression ($1, $3, '{'); 636 $$ = parser.make_index_expression ($1, $3, '{');
618 if (! $$) 637 if (! $$)
619 ABORT_PARSE; 638 {
639 // make_index_expression deleted $1 and $3.
640 ABORT_PARSE;
641 }
620 } 642 }
621 | oper_expr HERMITIAN 643 | oper_expr HERMITIAN
622 { $$ = parser.make_postfix_op (HERMITIAN, $1, $2); } 644 { $$ = parser.make_postfix_op (HERMITIAN, $1, $2); }
623 | oper_expr TRANSPOSE 645 | oper_expr TRANSPOSE
624 { $$ = parser.make_postfix_op (TRANSPOSE, $1, $2); } 646 { $$ = parser.make_postfix_op (TRANSPOSE, $1, $2); }
634 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); } 656 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); }
635 | '+' oper_expr %prec UNARY 657 | '+' oper_expr %prec UNARY
636 { $$ = parser.make_prefix_op ('+', $2, $1); } 658 { $$ = parser.make_prefix_op ('+', $2, $1); }
637 | '-' oper_expr %prec UNARY 659 | '-' oper_expr %prec UNARY
638 { $$ = parser.make_prefix_op ('-', $2, $1); } 660 { $$ = parser.make_prefix_op ('-', $2, $1); }
639 | oper_expr POW oper_expr 661 | oper_expr POW power_expr
640 { $$ = parser.make_binary_op (POW, $1, $2, $3); } 662 { $$ = parser.make_binary_op (POW, $1, $2, $3); }
641 | oper_expr EPOW oper_expr 663 | oper_expr EPOW power_expr
642 { $$ = parser.make_binary_op (EPOW, $1, $2, $3); } 664 { $$ = parser.make_binary_op (EPOW, $1, $2, $3); }
643 | oper_expr '+' oper_expr 665 | oper_expr '+' oper_expr
644 { $$ = parser.make_binary_op ('+', $1, $2, $3); } 666 { $$ = parser.make_binary_op ('+', $1, $2, $3); }
645 | oper_expr '-' oper_expr 667 | oper_expr '-' oper_expr
646 { $$ = parser.make_binary_op ('-', $1, $2, $3); } 668 { $$ = parser.make_binary_op ('-', $1, $2, $3); }
660 { $$ = parser.make_binary_op (LEFTDIV, $1, $2, $3); } 682 { $$ = parser.make_binary_op (LEFTDIV, $1, $2, $3); }
661 | oper_expr ELEFTDIV oper_expr 683 | oper_expr ELEFTDIV oper_expr
662 { $$ = parser.make_binary_op (ELEFTDIV, $1, $2, $3); } 684 { $$ = parser.make_binary_op (ELEFTDIV, $1, $2, $3); }
663 ; 685 ;
664 686
687 power_expr : primary_expr
688 { $$ = $1; }
689 | power_expr PLUS_PLUS
690 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); }
691 | power_expr MINUS_MINUS
692 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); }
693 | power_expr '(' ')'
694 {
695 $$ = parser.make_index_expression ($1, 0, '(');
696 if (! $$)
697 {
698 // make_index_expression deleted $1.
699 ABORT_PARSE;
700 }
701 }
702 | power_expr '(' arg_list ')'
703 {
704 $$ = parser.make_index_expression ($1, $3, '(');
705 if (! $$)
706 {
707 // make_index_expression deleted $1 and $3.
708 ABORT_PARSE;
709 }
710 }
711 | power_expr '{' '}'
712 {
713 $$ = parser.make_index_expression ($1, 0, '{');
714 if (! $$)
715 {
716 // make_index_expression deleted $1.
717 ABORT_PARSE;
718 }
719 }
720 | power_expr '{' arg_list '}'
721 {
722 $$ = parser.make_index_expression ($1, $3, '{');
723 if (! $$)
724 {
725 // make_index_expression deleted $1 and $3.
726 ABORT_PARSE;
727 }
728 }
729 | power_expr indirect_ref_op STRUCT_ELT
730 { $$ = parser.make_indirect_ref ($1, $3->text ()); }
731 | power_expr indirect_ref_op '(' expression ')'
732 { $$ = parser.make_indirect_ref ($1, $4); }
733 | PLUS_PLUS power_expr %prec POW
734 { $$ = parser.make_prefix_op (PLUS_PLUS, $2, $1); }
735 | MINUS_MINUS power_expr %prec POW
736 { $$ = parser.make_prefix_op (MINUS_MINUS, $2, $1); }
737 | EXPR_NOT power_expr %prec POW
738 { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); }
739 | '+' power_expr %prec POW
740 { $$ = parser.make_prefix_op ('+', $2, $1); }
741 | '-' power_expr %prec POW
742 { $$ = parser.make_prefix_op ('-', $2, $1); }
743 ;
744
665 colon_expr : colon_expr1 745 colon_expr : colon_expr1
666 { $$ = parser.finish_colon_expression ($1); } 746 { $$ = parser.finish_colon_expression ($1); }
667 ; 747 ;
668 748
669 colon_expr1 : oper_expr 749 colon_expr1 : oper_expr
670 { $$ = new tree_colon_expression ($1); } 750 { $$ = new tree_colon_expression ($1); }
671 | colon_expr1 ':' oper_expr 751 | colon_expr1 ':' oper_expr
672 { 752 {
673 if (! ($$ = $1->append ($3))) 753 if (! ($$ = $1->append ($3)))
674 ABORT_PARSE; 754 {
755 delete $1;
756 delete $3;
757 ABORT_PARSE;
758 }
675 } 759 }
676 ; 760 ;
677 761
678 simple_expr : colon_expr 762 simple_expr : colon_expr
679 { $$ = $1; } 763 { $$ = $1; }
842 // ============ 926 // ============
843 927
844 if_command : IF stash_comment if_cmd_list END 928 if_command : IF stash_comment if_cmd_list END
845 { 929 {
846 if (! ($$ = parser.finish_if_command ($1, $3, $4, $2))) 930 if (! ($$ = parser.finish_if_command ($1, $3, $4, $2)))
847 ABORT_PARSE; 931 {
932 // finish_if_command deleted $3.
933 ABORT_PARSE;
934 }
848 } 935 }
849 ; 936 ;
850 937
851 if_cmd_list : if_cmd_list1 938 if_cmd_list : if_cmd_list1
852 { $$ = $1; } 939 { $$ = $1; }
887 // ================ 974 // ================
888 975
889 switch_command : SWITCH stash_comment expression opt_sep case_list END 976 switch_command : SWITCH stash_comment expression opt_sep case_list END
890 { 977 {
891 if (! ($$ = parser.finish_switch_command ($1, $3, $5, $6, $2))) 978 if (! ($$ = parser.finish_switch_command ($1, $3, $5, $6, $2)))
892 ABORT_PARSE; 979 {
980 // finish_switch_command deleted $3 adn $5.
981 ABORT_PARSE;
982 }
893 } 983 }
894 ; 984 ;
895 985
896 case_list : // empty 986 case_list : // empty
897 { $$ = new tree_switch_case_list (); } 987 { $$ = new tree_switch_case_list (); }
932 loop_command : WHILE stash_comment expression stmt_begin opt_sep opt_list END 1022 loop_command : WHILE stash_comment expression stmt_begin opt_sep opt_list END
933 { 1023 {
934 $3->mark_braindead_shortcircuit (lexer.fcn_file_full_name); 1024 $3->mark_braindead_shortcircuit (lexer.fcn_file_full_name);
935 1025
936 if (! ($$ = parser.make_while_command ($1, $3, $6, $7, $2))) 1026 if (! ($$ = parser.make_while_command ($1, $3, $6, $7, $2)))
937 ABORT_PARSE; 1027 {
1028 // make_while_command deleted $3 and $6.
1029 ABORT_PARSE;
1030 }
938 } 1031 }
939 | DO stash_comment opt_sep opt_list UNTIL expression 1032 | DO stash_comment opt_sep opt_list UNTIL expression
940 { 1033 {
941 if (! ($$ = parser.make_do_until_command ($5, $4, $6, $2))) 1034 $$ = parser.make_do_until_command ($5, $4, $6, $2);
942 ABORT_PARSE;
943 } 1035 }
944 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END 1036 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END
945 { 1037 {
946 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, 0, 1038 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, 0,
947 $8, $9, $2))) 1039 $8, $9, $2)))
948 ABORT_PARSE; 1040 {
1041 // make_for_command deleted $3, $5, and $8.
1042 ABORT_PARSE;
1043 }
949 } 1044 }
950 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END 1045 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END
951 { 1046 {
952 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, 0, 1047 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, 0,
953 $9, $10, $2))) 1048 $9, $10, $2)))
954 ABORT_PARSE; 1049 {
1050 // make_for_command deleted $4, $6, and $9.
1051 ABORT_PARSE;
1052 }
955 } 1053 }
956 | PARFOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END 1054 | PARFOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END
957 { 1055 {
958 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5, 1056 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5,
959 0, $8, $9, $2))) 1057 0, $8, $9, $2)))
960 ABORT_PARSE; 1058 {
1059 // make_for_command deleted $3, $5, and $8.
1060 ABORT_PARSE;
1061 }
961 } 1062 }
962 | PARFOR stash_comment '(' assign_lhs '=' expression ',' expression ')' opt_sep opt_list END 1063 | PARFOR stash_comment '(' assign_lhs '=' expression ',' expression ')' opt_sep opt_list END
963 { 1064 {
964 if (! ($$ = parser.make_for_command (PARFOR, $1, $4, $6, 1065 if (! ($$ = parser.make_for_command (PARFOR, $1, $4, $6,
965 $8, $11, $12, $2))) 1066 $8, $11, $12, $2)))
966 ABORT_PARSE; 1067 {
1068 // make_for_command deleted $4, $6, $8, and $11.
1069 ABORT_PARSE;
1070 }
967 } 1071 }
968 ; 1072 ;
969 1073
970 // ======= 1074 // =======
971 // Jumping 1075 // Jumping
972 // ======= 1076 // =======
973 1077
974 jump_command : BREAK 1078 jump_command : BREAK
975 { 1079 { $$ = parser.make_break_command ($1); }
976 if (! ($$ = parser.make_break_command ($1)))
977 ABORT_PARSE;
978 }
979 | CONTINUE 1080 | CONTINUE
980 { 1081 { $$ = parser.make_continue_command ($1); }
981 if (! ($$ = parser.make_continue_command ($1)))
982 ABORT_PARSE;
983 }
984 | FUNC_RET 1082 | FUNC_RET
985 { 1083 { $$ = parser.make_return_command ($1); }
986 if (! ($$ = parser.make_return_command ($1)))
987 ABORT_PARSE;
988 }
989 ; 1084 ;
990 1085
991 // ========== 1086 // ==========
992 // Exceptions 1087 // Exceptions
993 // ========== 1088 // ==========
994 1089
995 except_command : UNWIND stash_comment opt_sep opt_list CLEANUP 1090 except_command : UNWIND stash_comment opt_sep opt_list CLEANUP
996 stash_comment opt_sep opt_list END 1091 stash_comment opt_sep opt_list END
997 { 1092 {
998 if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6))) 1093 if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6)))
999 ABORT_PARSE; 1094 {
1095 // make_unwind_command deleted $4 and $8.
1096 ABORT_PARSE;
1097 }
1000 } 1098 }
1001 | TRY stash_comment opt_sep opt_list CATCH stash_comment 1099 | TRY stash_comment opt_sep opt_list CATCH stash_comment
1002 opt_sep opt_list END 1100 opt_sep opt_list END
1003 { 1101 {
1004 if (! ($$ = parser.make_try_command ($1, $4, $7, $8, $9, $2, $6))) 1102 if (! ($$ = parser.make_try_command ($1, $4, $7, $8, $9, $2, $6)))
1005 ABORT_PARSE; 1103 {
1104 // make_try_command deleted $4 and $8.
1105 ABORT_PARSE;
1106 }
1006 } 1107 }
1007 | TRY stash_comment opt_sep opt_list END 1108 | TRY stash_comment opt_sep opt_list END
1008 { 1109 {
1009 if (! ($$ = parser.make_try_command ($1, $4, 0, 0, $5, $2, 0))) 1110 if (! ($$ = parser.make_try_command ($1, $4, 0, 0, $5, $2, 0)))
1010 ABORT_PARSE; 1111 {
1112 // make_try_command deleted $4.
1113 ABORT_PARSE;
1114 }
1011 } 1115 }
1012 ; 1116 ;
1013 1117
1014 // =========================================== 1118 // ===========================================
1015 // Some 'subroutines' for function definitions 1119 // Some 'subroutines' for function definitions
1087 { 1191 {
1088 lexer.mark_as_variables ($1->variable_names ()); 1192 lexer.mark_as_variables ($1->variable_names ());
1089 $$ = $1; 1193 $$ = $1;
1090 } 1194 }
1091 else 1195 else
1092 ABORT_PARSE; 1196 {
1197 delete $1;
1198 ABORT_PARSE;
1199 }
1093 } 1200 }
1094 ; 1201 ;
1095 1202
1096 param_list2 : param_list_elt 1203 param_list2 : param_list_elt
1097 { $$ = new tree_parameter_list ($1); } 1204 { $$ = new tree_parameter_list ($1); }
1129 // to check for varargin or varargout. 1236 // to check for varargin or varargout.
1130 1237
1131 if (tmp->validate (tree_parameter_list::out)) 1238 if (tmp->validate (tree_parameter_list::out))
1132 $$ = tmp; 1239 $$ = tmp;
1133 else 1240 else
1134 ABORT_PARSE; 1241 {
1242 delete tmp;
1243 ABORT_PARSE;
1244 }
1135 } 1245 }
1136 | '[' return_list1 ']' 1246 | '[' return_list1 ']'
1137 { 1247 {
1138 lexer.looking_at_return_list = false; 1248 lexer.looking_at_return_list = false;
1139 1249
1141 // or varargout. 1251 // or varargout.
1142 1252
1143 if ($2->validate (tree_parameter_list::out)) 1253 if ($2->validate (tree_parameter_list::out))
1144 $$ = $2; 1254 $$ = $2;
1145 else 1255 else
1146 ABORT_PARSE; 1256 {
1257 delete $2;
1258 ABORT_PARSE;
1259 }
1147 } 1260 }
1148 ; 1261 ;
1149 1262
1150 return_list1 : identifier 1263 return_list1 : identifier
1151 { $$ = new tree_parameter_list (new tree_decl_elt ($1)); } 1264 { $$ = new tree_parameter_list (new tree_decl_elt ($1)); }
1160 // Script or function file 1273 // Script or function file
1161 // ======================= 1274 // =======================
1162 1275
1163 file : INPUT_FILE opt_nl opt_list END_OF_INPUT 1276 file : INPUT_FILE opt_nl opt_list END_OF_INPUT
1164 { 1277 {
1165 if (! lexer.reading_fcn_file) 1278 if (lexer.reading_fcn_file)
1279 {
1280 // Delete the dummy statement_list we created
1281 // after parsing the function. Any function
1282 // definitions found in the file have already
1283 // been stored in the symbol table or in
1284 // octave_base_parser::primary_fcn_ptr.
1285
1286 delete $3;
1287 }
1288 else
1166 { 1289 {
1167 tree_statement *end_of_script 1290 tree_statement *end_of_script
1168 = parser.make_end ("endscript", true, 1291 = parser.make_end ("endscript", true,
1169 lexer.input_line_number, 1292 lexer.input_line_number,
1170 lexer.current_input_column); 1293 lexer.current_input_column);
1244 if (lexer.parsing_classdef_get_method) 1367 if (lexer.parsing_classdef_get_method)
1245 fname.insert (0, "get."); 1368 fname.insert (0, "get.");
1246 else if (lexer.parsing_classdef_set_method) 1369 else if (lexer.parsing_classdef_set_method)
1247 fname.insert (0, "set."); 1370 fname.insert (0, "set.");
1248 1371
1249 if (! ($$ = parser.frob_function (fname, $2))) 1372 $$ = parser.frob_function (fname, $2);
1250 ABORT_PARSE;
1251 } 1373 }
1252 ; 1374 ;
1253 1375
1254 function2 : param_list opt_sep opt_list function_end 1376 function2 : param_list opt_sep opt_list function_end
1255 { $$ = parser.start_function ($1, $3, $4); } 1377 { $$ = parser.start_function ($1, $3, $4); }
2279 int c = unwind_tok->column (); 2401 int c = unwind_tok->column ();
2280 2402
2281 retval = new tree_unwind_protect_command (body, cleanup_stmts, 2403 retval = new tree_unwind_protect_command (body, cleanup_stmts,
2282 lc, mc, tc, l, c); 2404 lc, mc, tc, l, c);
2283 } 2405 }
2406 else
2407 {
2408 delete body;
2409 delete cleanup_stmts;
2410 }
2284 2411
2285 return retval; 2412 return retval;
2286 } 2413 }
2287 2414
2288 // Build a try-catch command. 2415 // Build a try-catch command.
2325 } 2452 }
2326 2453
2327 retval = new tree_try_catch_command (body, cleanup_stmts, id, 2454 retval = new tree_try_catch_command (body, cleanup_stmts, id,
2328 lc, mc, tc, l, c); 2455 lc, mc, tc, l, c);
2329 } 2456 }
2457 else
2458 {
2459 delete body;
2460 delete cleanup_stmts;
2461 }
2330 2462
2331 return retval; 2463 return retval;
2332 } 2464 }
2333 2465
2334 // Build a while command. 2466 // Build a while command.
2353 int l = while_tok->line (); 2485 int l = while_tok->line ();
2354 int c = while_tok->column (); 2486 int c = while_tok->column ();
2355 2487
2356 retval = new tree_while_command (expr, body, lc, tc, l, c); 2488 retval = new tree_while_command (expr, body, lc, tc, l, c);
2357 } 2489 }
2490 else
2491 {
2492 delete expr;
2493 delete body;
2494 }
2358 2495
2359 return retval; 2496 return retval;
2360 } 2497 }
2361 2498
2362 // Build a do-until command. 2499 // Build a do-until command.
2365 octave_base_parser::make_do_until_command (token *until_tok, 2502 octave_base_parser::make_do_until_command (token *until_tok,
2366 tree_statement_list *body, 2503 tree_statement_list *body,
2367 tree_expression *expr, 2504 tree_expression *expr,
2368 octave_comment_list *lc) 2505 octave_comment_list *lc)
2369 { 2506 {
2370 tree_command *retval = 0;
2371
2372 maybe_warn_assign_as_truth_value (expr); 2507 maybe_warn_assign_as_truth_value (expr);
2373 2508
2374 octave_comment_list *tc = octave_comment_buffer::get_comment (); 2509 octave_comment_list *tc = octave_comment_buffer::get_comment ();
2375 2510
2376 lexer.looping--; 2511 lexer.looping--;
2377 2512
2378 int l = until_tok->line (); 2513 int l = until_tok->line ();
2379 int c = until_tok->column (); 2514 int c = until_tok->column ();
2380 2515
2381 retval = new tree_do_until_command (expr, body, lc, tc, l, c); 2516 return new tree_do_until_command (expr, body, lc, tc, l, c);
2382
2383 return retval;
2384 } 2517 }
2385 2518
2386 // Build a for command. 2519 // Build a for command.
2387 2520
2388 tree_command * 2521 tree_command *
2423 else 2556 else
2424 retval = new tree_complex_for_command (lhs, expr, body, 2557 retval = new tree_complex_for_command (lhs, expr, body,
2425 lc, tc, l, c); 2558 lc, tc, l, c);
2426 } 2559 }
2427 } 2560 }
2561 else
2562 {
2563 delete lhs;
2564 delete expr;
2565 delete maxproc;
2566 delete body;
2567 }
2428 2568
2429 return retval; 2569 return retval;
2430 } 2570 }
2431 2571
2432 // Build a break command. 2572 // Build a break command.
2433 2573
2434 tree_command * 2574 tree_command *
2435 octave_base_parser::make_break_command (token *break_tok) 2575 octave_base_parser::make_break_command (token *break_tok)
2436 { 2576 {
2437 tree_command *retval = 0;
2438
2439 int l = break_tok->line (); 2577 int l = break_tok->line ();
2440 int c = break_tok->column (); 2578 int c = break_tok->column ();
2441 2579
2442 retval = new tree_break_command (l, c); 2580 return new tree_break_command (l, c);
2443
2444 return retval;
2445 } 2581 }
2446 2582
2447 // Build a continue command. 2583 // Build a continue command.
2448 2584
2449 tree_command * 2585 tree_command *
2450 octave_base_parser::make_continue_command (token *continue_tok) 2586 octave_base_parser::make_continue_command (token *continue_tok)
2451 { 2587 {
2452 tree_command *retval = 0;
2453
2454 int l = continue_tok->line (); 2588 int l = continue_tok->line ();
2455 int c = continue_tok->column (); 2589 int c = continue_tok->column ();
2456 2590
2457 retval = new tree_continue_command (l, c); 2591 return new tree_continue_command (l, c);
2458
2459 return retval;
2460 } 2592 }
2461 2593
2462 // Build a return command. 2594 // Build a return command.
2463 2595
2464 tree_command * 2596 tree_command *
2465 octave_base_parser::make_return_command (token *return_tok) 2597 octave_base_parser::make_return_command (token *return_tok)
2466 { 2598 {
2467 tree_command *retval = 0;
2468
2469 int l = return_tok->line (); 2599 int l = return_tok->line ();
2470 int c = return_tok->column (); 2600 int c = return_tok->column ();
2471 2601
2472 retval = new tree_return_command (l, c); 2602 return new tree_return_command (l, c);
2473
2474 return retval;
2475 } 2603 }
2476 2604
2477 // Start an if command. 2605 // Start an if command.
2478 2606
2479 tree_if_command_list * 2607 tree_if_command_list *
2515 } 2643 }
2516 } 2644 }
2517 2645
2518 retval = new tree_if_command (list, lc, tc, l, c); 2646 retval = new tree_if_command (list, lc, tc, l, c);
2519 } 2647 }
2648 else
2649 delete list;
2520 2650
2521 return retval; 2651 return retval;
2522 } 2652 }
2523 2653
2524 // Build an elseif clause. 2654 // Build an elseif clause.
2565 elt->column (c); 2695 elt->column (c);
2566 } 2696 }
2567 } 2697 }
2568 2698
2569 retval = new tree_switch_command (expr, list, lc, tc, l, c); 2699 retval = new tree_switch_command (expr, list, lc, tc, l, c);
2700 }
2701 else
2702 {
2703 delete expr;
2704 delete list;
2570 } 2705 }
2571 2706
2572 return retval; 2707 return retval;
2573 } 2708 }
2574 2709
3114 tree_index_expression *retval = 0; 3249 tree_index_expression *retval = 0;
3115 3250
3116 if (args && args->has_magic_tilde ()) 3251 if (args && args->has_magic_tilde ())
3117 { 3252 {
3118 bison_error ("invalid use of empty argument (~) in index expression"); 3253 bison_error ("invalid use of empty argument (~) in index expression");
3254
3255 delete expr;
3256 delete args;
3257
3119 return retval; 3258 return retval;
3120 } 3259 }
3121 3260
3122 int l = expr->line (); 3261 int l = expr->line ();
3123 int c = expr->column (); 3262 int c = expr->column ();