comparison libinterp/parse-tree/oct-parse.in.yy @ 23796:4f12819a634f

Use C++11 nullptr rather than 0 in code (bug #51565). * mk-opts.pl, BlockArray.cpp, KeyboardTranslator.cpp, Screen.cpp, TerminalCharacterDecoder.cpp, TerminalView.cpp, Vt102Emulation.cpp, dialog.cc, find-files-dialog.cc, file-editor-tab.cc, main-window.cc, ls-hdf5.cc, oct-procbuf.h, oct-stream.cc, oct-tex-lexer.in.ll, zfstream.cc, ov-builtin.h, ov-fcn-handle.cc, ov-typeinfo.h, ov-usr-fcn.h, options-usage.h, lex.ll, oct-parse.in.yy, pt-loop.h, Array.cc, CSparse.cc, Sparse.h, dSparse.cc, fCMatrix.cc, idx-vector.cc, idx-vector.h, sparse-chol.cc, cmd-edit.cc, oct-sort.cc, main.in.cc: Use C++11 nullptr rather than 0 in code (bug #51565).
author Rik <rik@octave.org>
date Wed, 26 Jul 2017 16:26:31 -0700
parents ea879bc55272
children 771310737137
comparison
equal deleted inserted replaced
23795:980f39c3ab90 23796:4f12819a634f
380 // Statements and statement lists 380 // Statements and statement lists
381 // ============================== 381 // ==============================
382 382
383 input : simple_list '\n' 383 input : simple_list '\n'
384 { 384 {
385 $$ = 0; 385 $$ = nullptr;
386 parser.m_stmt_list = $1; 386 parser.m_stmt_list = $1;
387 YYACCEPT; 387 YYACCEPT;
388 } 388 }
389 | simple_list END_OF_INPUT 389 | simple_list END_OF_INPUT
390 { 390 {
391 $$ = 0; 391 $$ = nullptr;
392 lexer.end_of_input = true; 392 lexer.end_of_input = true;
393 parser.m_stmt_list = $1; 393 parser.m_stmt_list = $1;
394 YYACCEPT; 394 YYACCEPT;
395 } 395 }
396 | parse_error 396 | parse_error
397 { 397 {
398 $$ = 0; 398 $$ = nullptr;
399 YYABORT; 399 YYABORT;
400 } 400 }
401 ; 401 ;
402 402
403 simple_list : opt_sep_no_nl 403 simple_list : opt_sep_no_nl
404 { 404 {
405 YYUSE ($1); 405 YYUSE ($1);
406 406
407 $$ = 0; 407 $$ = nullptr;
408 } 408 }
409 | simple_list1 opt_sep_no_nl 409 | simple_list1 opt_sep_no_nl
410 { $$ = parser.set_stmt_print_flag ($1, $2, false); } 410 { $$ = parser.set_stmt_print_flag ($1, $2, false); }
411 ; 411 ;
412 412
540 matrix : '[' matrix_rows ']' 540 matrix : '[' matrix_rows ']'
541 { $$ = parser.finish_matrix ($2); } 541 { $$ = parser.finish_matrix ($2); }
542 ; 542 ;
543 543
544 matrix_rows : cell_or_matrix_row 544 matrix_rows : cell_or_matrix_row
545 { $$ = $1 ? new octave::tree_matrix ($1) : 0; } 545 { $$ = $1 ? new octave::tree_matrix ($1) : nullptr; }
546 | matrix_rows ';' cell_or_matrix_row 546 | matrix_rows ';' cell_or_matrix_row
547 { 547 {
548 if ($1) 548 if ($1)
549 { 549 {
550 if ($3) 550 if ($3)
551 $1->append ($3); 551 $1->append ($3);
552 552
553 $$ = $1; 553 $$ = $1;
554 } 554 }
555 else 555 else
556 $$ = $3 ? new octave::tree_matrix ($3) : 0; 556 $$ = $3 ? new octave::tree_matrix ($3) : nullptr;
557 } 557 }
558 ; 558 ;
559 559
560 cell : '{' cell_rows '}' 560 cell : '{' cell_rows '}'
561 { $$ = parser.finish_cell ($2); } 561 { $$ = parser.finish_cell ($2); }
562 ; 562 ;
563 563
564 cell_rows : cell_or_matrix_row 564 cell_rows : cell_or_matrix_row
565 { $$ = $1 ? new octave::tree_cell ($1) : 0; } 565 { $$ = $1 ? new octave::tree_cell ($1) : nullptr; }
566 | cell_rows ';' cell_or_matrix_row 566 | cell_rows ';' cell_or_matrix_row
567 { 567 {
568 if ($1) 568 if ($1)
569 { 569 {
570 if ($3) 570 if ($3)
571 $1->append ($3); 571 $1->append ($3);
572 572
573 $$ = $1; 573 $$ = $1;
574 } 574 }
575 else 575 else
576 $$ = $3 ? new octave::tree_cell ($3) : 0; 576 $$ = $3 ? new octave::tree_cell ($3) : nullptr;
577 } 577 }
578 ; 578 ;
579 579
580 // tree_argument_list objects can't be empty or have leading or trailing 580 // tree_argument_list objects can't be empty or have leading or trailing
581 // commas, but those are all allowed in matrix and cell array rows. 581 // commas, but those are all allowed in matrix and cell array rows.
582 582
583 cell_or_matrix_row 583 cell_or_matrix_row
584 : // empty 584 : // empty
585 { $$ = 0; } 585 { $$ = nullptr; }
586 | ',' 586 | ','
587 { $$ = 0; } 587 { $$ = nullptr; }
588 | arg_list 588 | arg_list
589 { $$ = $1; } 589 { $$ = $1; }
590 | arg_list ',' 590 | arg_list ','
591 { $$ = $1; } 591 { $$ = $1; }
592 | ',' arg_list 592 | ',' arg_list
683 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); } 683 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); }
684 | oper_expr MINUS_MINUS 684 | oper_expr MINUS_MINUS
685 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } 685 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); }
686 | oper_expr '(' ')' 686 | oper_expr '(' ')'
687 { 687 {
688 $$ = parser.make_index_expression ($1, 0, '('); 688 $$ = parser.make_index_expression ($1, nullptr, '(');
689 if (! $$) 689 if (! $$)
690 { 690 {
691 // make_index_expression deleted $1. 691 // make_index_expression deleted $1.
692 YYABORT; 692 YYABORT;
693 } 693 }
701 YYABORT; 701 YYABORT;
702 } 702 }
703 } 703 }
704 | oper_expr '{' '}' 704 | oper_expr '{' '}'
705 { 705 {
706 $$ = parser.make_index_expression ($1, 0, '{'); 706 $$ = parser.make_index_expression ($1, nullptr, '{');
707 if (! $$) 707 if (! $$)
708 { 708 {
709 // make_index_expression deleted $1. 709 // make_index_expression deleted $1.
710 YYABORT; 710 YYABORT;
711 } 711 }
769 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); } 769 { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); }
770 | power_expr MINUS_MINUS 770 | power_expr MINUS_MINUS
771 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); } 771 { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); }
772 | power_expr '(' ')' 772 | power_expr '(' ')'
773 { 773 {
774 $$ = parser.make_index_expression ($1, 0, '('); 774 $$ = parser.make_index_expression ($1, nullptr, '(');
775 if (! $$) 775 if (! $$)
776 { 776 {
777 // make_index_expression deleted $1. 777 // make_index_expression deleted $1.
778 YYABORT; 778 YYABORT;
779 } 779 }
787 YYABORT; 787 YYABORT;
788 } 788 }
789 } 789 }
790 | power_expr '{' '}' 790 | power_expr '{' '}'
791 { 791 {
792 $$ = parser.make_index_expression ($1, 0, '{'); 792 $$ = parser.make_index_expression ($1, nullptr, '{');
793 if (! $$) 793 if (! $$)
794 { 794 {
795 // make_index_expression deleted $1. 795 // make_index_expression deleted $1.
796 YYABORT; 796 YYABORT;
797 } 797 }
1157 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END 1157 | FOR stash_comment assign_lhs '=' expression stmt_begin opt_sep opt_list END
1158 { 1158 {
1159 YYUSE ($4); 1159 YYUSE ($4);
1160 YYUSE ($7); 1160 YYUSE ($7);
1161 1161
1162 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, 0, 1162 if (! ($$ = parser.make_for_command (FOR, $1, $3, $5,
1163 $8, $9, $2))) 1163 nullptr, $8, $9, $2)))
1164 { 1164 {
1165 // make_for_command deleted $3, $5, and $8. 1165 // make_for_command deleted $3, $5, and $8.
1166 YYABORT; 1166 YYABORT;
1167 } 1167 }
1168 } 1168 }
1169 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END 1169 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END
1170 { 1170 {
1171 YYUSE ($5); 1171 YYUSE ($5);
1172 YYUSE ($8); 1172 YYUSE ($8);
1173 1173
1174 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, 0, 1174 if (! ($$ = parser.make_for_command (FOR, $1, $4, $6,
1175 $9, $10, $2))) 1175 nullptr, $9, $10, $2)))
1176 { 1176 {
1177 // make_for_command deleted $4, $6, and $9. 1177 // make_for_command deleted $4, $6, and $9.
1178 YYABORT; 1178 YYABORT;
1179 } 1179 }
1180 } 1180 }
1182 { 1182 {
1183 YYUSE ($4); 1183 YYUSE ($4);
1184 YYUSE ($7); 1184 YYUSE ($7);
1185 1185
1186 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5, 1186 if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5,
1187 0, $8, $9, $2))) 1187 nullptr, $8, $9, $2)))
1188 { 1188 {
1189 // make_for_command deleted $3, $5, and $8. 1189 // make_for_command deleted $3, $5, and $8.
1190 YYABORT; 1190 YYABORT;
1191 } 1191 }
1192 } 1192 }
1251 } 1251 }
1252 | TRY stash_comment opt_sep opt_list END 1252 | TRY stash_comment opt_sep opt_list END
1253 { 1253 {
1254 YYUSE ($3); 1254 YYUSE ($3);
1255 1255
1256 if (! ($$ = parser.make_try_command ($1, $4, 0, 0, $5, $2, 0))) 1256 if (! ($$ = parser.make_try_command ($1, $4, 0, nullptr,
1257 $5, $2, nullptr)))
1257 { 1258 {
1258 // make_try_command deleted $4. 1259 // make_try_command deleted $4.
1259 YYABORT; 1260 YYABORT;
1260 } 1261 }
1261 } 1262 }
1318 lexer.looking_for_object_index = false; 1319 lexer.looking_for_object_index = false;
1319 } 1320 }
1320 ; 1321 ;
1321 1322
1322 opt_param_list : // empty 1323 opt_param_list : // empty
1323 { $$ = 0; } 1324 { $$ = nullptr; }
1324 | param_list 1325 | param_list
1325 { $$ = $1; } 1326 { $$ = $1; }
1326 ; 1327 ;
1327 1328
1328 param_list : param_list_beg param_list1 param_list_end 1329 param_list : param_list_beg param_list1 param_list_end
1332 1333
1333 $$ = $2; 1334 $$ = $2;
1334 } 1335 }
1335 | param_list_beg error 1336 | param_list_beg error
1336 { 1337 {
1337 $$ = 0; 1338 $$ = nullptr;
1338 parser.bison_error ("invalid parameter list"); 1339 parser.bison_error ("invalid parameter list");
1339 YYABORT; 1340 YYABORT;
1340 } 1341 }
1341 ; 1342 ;
1342 1343
1343 param_list1 : // empty 1344 param_list1 : // empty
1344 { $$ = 0; } 1345 { $$ = nullptr; }
1345 | param_list2 1346 | param_list2
1346 { 1347 {
1347 $1->mark_as_formal_parameters (); 1348 $1->mark_as_formal_parameters ();
1348 1349
1349 if (parser.validate_param_list ($1, octave::tree_parameter_list::in)) 1350 if (parser.validate_param_list ($1, octave::tree_parameter_list::in))
1459 lexer.current_input_column); 1460 lexer.current_input_column);
1460 1461
1461 parser.make_script ($3, end_of_script); 1462 parser.make_script ($3, end_of_script);
1462 } 1463 }
1463 1464
1464 $$ = 0; 1465 $$ = nullptr;
1465 } 1466 }
1466 | INPUT_FILE opt_nl classdef parsing_local_fcns opt_sep opt_fcn_list END_OF_INPUT 1467 | INPUT_FILE opt_nl classdef parsing_local_fcns opt_sep opt_fcn_list END_OF_INPUT
1467 { 1468 {
1468 YYUSE ($2); 1469 YYUSE ($2);
1469 YYUSE ($5); 1470 YYUSE ($5);
1470 YYUSE ($6); 1471 YYUSE ($6);
1471 1472
1472 if (lexer.reading_classdef_file) 1473 if (lexer.reading_classdef_file)
1473 parser.m_classdef_object = $3; 1474 parser.m_classdef_object = $3;
1474 1475
1475 $$ = 0; 1476 $$ = nullptr;
1476 } 1477 }
1477 ; 1478 ;
1478 1479
1479 // =================== 1480 // ===================
1480 // Function definition 1481 // Function definition
1584 function : function_beg stash_comment fcn_name 1585 function : function_beg stash_comment fcn_name
1585 opt_param_list opt_sep opt_list function_end 1586 opt_param_list opt_sep opt_list function_end
1586 { 1587 {
1587 YYUSE ($5); 1588 YYUSE ($5);
1588 1589
1589 $$ = parser.make_function ($1, 0, $3, $4, $6, $7, $2); 1590 $$ = parser.make_function ($1, nullptr, $3, $4, $6, $7, $2);
1590 } 1591 }
1591 | function_beg stash_comment return_list '=' fcn_name 1592 | function_beg stash_comment return_list '=' fcn_name
1592 opt_param_list opt_sep opt_list function_end 1593 opt_param_list opt_sep opt_list function_end
1593 { 1594 {
1594 YYUSE ($4); 1595 YYUSE ($4);
1609 parser.bison_error ("classdef must appear inside a file containing only a class definition"); 1610 parser.bison_error ("classdef must appear inside a file containing only a class definition");
1610 YYABORT; 1611 YYABORT;
1611 } 1612 }
1612 1613
1613 // Create invalid parent scope. 1614 // Create invalid parent scope.
1614 lexer.symtab_context.push (0); 1615 lexer.symtab_context.push (nullptr);
1615 lexer.parsing_classdef = true; 1616 lexer.parsing_classdef = true;
1616 $$ = $1; 1617 $$ = $1;
1617 } 1618 }
1618 ; 1619 ;
1619 1620
1634 { 1635 {
1635 YYUSE ($6); 1636 YYUSE ($6);
1636 1637
1637 lexer.parsing_classdef = false; 1638 lexer.parsing_classdef = false;
1638 1639
1639 if (! ($$ = parser.make_classdef ($1, $3, $4, $5, 0, $7, $2))) 1640 if (! ($$ = parser.make_classdef ($1, $3, $4, $5, nullptr,
1641 $7, $2)))
1640 { 1642 {
1641 // make_classdef deleted $3, $4, and $5. 1643 // make_classdef deleted $3, $4, and $5.
1642 YYABORT; 1644 YYABORT;
1643 } 1645 }
1644 } 1646 }
1645 ; 1647 ;
1646 1648
1647 opt_attr_list : // empty 1649 opt_attr_list : // empty
1648 { $$ = 0; } 1650 { $$ = nullptr; }
1649 | '(' attr_list ')' 1651 | '(' attr_list ')'
1650 { $$ = $2; } 1652 { $$ = $2; }
1651 ; 1653 ;
1652 1654
1653 attr_list : attr 1655 attr_list : attr
1676 } 1678 }
1677 ; 1679 ;
1678 1680
1679 opt_superclass_list 1681 opt_superclass_list
1680 : // empty 1682 : // empty
1681 { $$ = 0; } 1683 { $$ = nullptr; }
1682 | superclass_list 1684 | superclass_list
1683 { $$ = $1; } 1685 { $$ = $1; }
1684 ; 1686 ;
1685 1687
1686 superclass_list : EXPR_LT 1688 superclass_list : EXPR_LT
1762 | PROPERTIES stash_comment opt_attr_list opt_sep END 1764 | PROPERTIES stash_comment opt_attr_list opt_sep END
1763 { 1765 {
1764 YYUSE ($4); 1766 YYUSE ($4);
1765 1767
1766 if (! ($$ = parser.make_classdef_properties_block 1768 if (! ($$ = parser.make_classdef_properties_block
1767 ($1, $3, 0, $5, $2))) 1769 ($1, $3, nullptr, $5, $2)))
1768 { 1770 {
1769 // make_classdef_properties_block delete $3. 1771 // make_classdef_properties_block delete $3.
1770 YYABORT; 1772 YYABORT;
1771 } 1773 }
1772 } 1774 }
1810 | METHODS stash_comment opt_attr_list opt_sep END 1812 | METHODS stash_comment opt_attr_list opt_sep END
1811 { 1813 {
1812 YYUSE ($4); 1814 YYUSE ($4);
1813 1815
1814 if (! ($$ = parser.make_classdef_methods_block 1816 if (! ($$ = parser.make_classdef_methods_block
1815 ($1, $3, 0, $5, $2))) 1817 ($1, $3, nullptr, $5, $2)))
1816 { 1818 {
1817 // make_classdef_methods_block deleted $3. 1819 // make_classdef_methods_block deleted $3.
1818 YYABORT; 1820 YYABORT;
1819 } 1821 }
1820 } 1822 }
1821 ; 1823 ;
1822 ; 1824 ;
1823 1825
1824 method_decl1 : identifier 1826 method_decl1 : identifier
1825 { 1827 {
1826 if (! ($$ = parser.start_classdef_external_method ($1, 0))) 1828 if (! ($$ = parser.start_classdef_external_method ($1, nullptr)))
1827 YYABORT; 1829 YYABORT;
1828 } 1830 }
1829 | identifier param_list 1831 | identifier param_list
1830 { 1832 {
1831 if (! ($$ = parser.start_classdef_external_method ($1, $2))) 1833 if (! ($$ = parser.start_classdef_external_method ($1, $2)))
1832 YYABORT; 1834 YYABORT;
1833 } 1835 }
1834 ; 1836 ;
1835 1837
1836 method_decl : stash_comment method_decl1 1838 method_decl : stash_comment method_decl1
1837 { $$ = parser.finish_classdef_external_method ($2, 0, $1); } 1839 { $$ = parser.finish_classdef_external_method ($2, nullptr, $1); }
1838 | stash_comment return_list '=' 1840 | stash_comment return_list '='
1839 { 1841 {
1840 YYUSE ($3); 1842 YYUSE ($3);
1841 1843
1842 lexer.defining_func++; 1844 lexer.defining_func++;
1933 | ENUMERATION stash_comment opt_attr_list opt_sep END 1935 | ENUMERATION stash_comment opt_attr_list opt_sep END
1934 { 1936 {
1935 YYUSE ($4); 1937 YYUSE ($4);
1936 1938
1937 if (! ($$ = parser.make_classdef_enum_block 1939 if (! ($$ = parser.make_classdef_enum_block
1938 ($1, $3, 0, $5, $2))) 1940 ($1, $3, nullptr, $5, $2)))
1939 { 1941 {
1940 // make_classdef_enum_block deleted $3. 1942 // make_classdef_enum_block deleted $3.
1941 YYABORT; 1943 YYABORT;
1942 } 1944 }
1943 } 1945 }
2118 } 2120 }
2119 2121
2120 symbol_table::scope * 2122 symbol_table::scope *
2121 base_parser::parent_scope_info::parent_scope (void) const 2123 base_parser::parent_scope_info::parent_scope (void) const
2122 { 2124 {
2123 return size () > 1 ? m_info[size()-2].first : 0; 2125 return size () > 1 ? m_info[size()-2].first : nullptr;
2124 } 2126 }
2125 2127
2126 std::string 2128 std::string
2127 base_parser::parent_scope_info::parent_name (void) const 2129 base_parser::parent_scope_info::parent_name (void) const
2128 { 2130 {
2137 2139
2138 base_parser::base_parser (base_lexer& lxr) 2140 base_parser::base_parser (base_lexer& lxr)
2139 : m_endfunction_found (false), m_autoloading (false), 2141 : m_endfunction_found (false), m_autoloading (false),
2140 m_fcn_file_from_relative_lookup (false), 2142 m_fcn_file_from_relative_lookup (false),
2141 m_parsing_subfunctions (false), m_parsing_local_functions (false), 2143 m_parsing_subfunctions (false), m_parsing_local_functions (false),
2142 m_max_fcn_depth (0), m_curr_fcn_depth (0), m_primary_fcn_scope (0), 2144 m_max_fcn_depth (0), m_curr_fcn_depth (0), m_primary_fcn_scope (nullptr),
2143 m_curr_class_name (), m_curr_package_name (), m_function_scopes (), 2145 m_curr_class_name (), m_curr_package_name (), m_function_scopes (),
2144 m_primary_fcn_ptr (0), m_subfunction_names (), m_classdef_object (0), 2146 m_primary_fcn_ptr (nullptr), m_subfunction_names (),
2145 m_stmt_list (0), m_lexer (lxr), m_parser_state (yypstate_new ()) 2147 m_classdef_object (nullptr), m_stmt_list (nullptr), m_lexer (lxr),
2148 m_parser_state (yypstate_new ())
2146 { } 2149 { }
2147 2150
2148 base_parser::~base_parser (void) 2151 base_parser::~base_parser (void)
2149 { 2152 {
2150 delete m_stmt_list; 2153 delete m_stmt_list;
2170 m_fcn_file_from_relative_lookup = false; 2173 m_fcn_file_from_relative_lookup = false;
2171 m_parsing_subfunctions = false; 2174 m_parsing_subfunctions = false;
2172 m_parsing_local_functions = false; 2175 m_parsing_local_functions = false;
2173 m_max_fcn_depth = 0; 2176 m_max_fcn_depth = 0;
2174 m_curr_fcn_depth = 0; 2177 m_curr_fcn_depth = 0;
2175 m_primary_fcn_scope = 0; 2178 m_primary_fcn_scope = nullptr;
2176 m_curr_class_name = ""; 2179 m_curr_class_name = "";
2177 m_curr_package_name = ""; 2180 m_curr_package_name = "";
2178 m_function_scopes.clear (); 2181 m_function_scopes.clear ();
2179 m_primary_fcn_ptr = 0; 2182 m_primary_fcn_ptr = nullptr;
2180 m_subfunction_names.clear (); 2183 m_subfunction_names.clear ();
2184 // FIXME: What about m_classdef_object? Shouldn't this be required?
2185 // m_classdef_object = nullptr;
2181 2186
2182 delete m_stmt_list; 2187 delete m_stmt_list;
2183 m_stmt_list = 0; 2188 m_stmt_list = nullptr;
2184 2189
2185 m_lexer.reset (); 2190 m_lexer.reset ();
2186 2191
2187 yypstate_delete (static_cast<yypstate *> (m_parser_state)); 2192 yypstate_delete (static_cast<yypstate *> (m_parser_state));
2188 m_parser_state = yypstate_new (); 2193 m_parser_state = yypstate_new ();
2329 base_parser::make_constant (int op, token *tok_val) 2334 base_parser::make_constant (int op, token *tok_val)
2330 { 2335 {
2331 int l = tok_val->line (); 2336 int l = tok_val->line ();
2332 int c = tok_val->column (); 2337 int c = tok_val->column ();
2333 2338
2334 tree_constant *retval = 0; 2339 tree_constant *retval = nullptr;
2335 2340
2336 switch (op) 2341 switch (op)
2337 { 2342 {
2338 case NUM: 2343 case NUM:
2339 { 2344 {
2701 tree_statement_list *cleanup_stmts, 2706 tree_statement_list *cleanup_stmts,
2702 token *end_tok, 2707 token *end_tok,
2703 comment_list *lc, 2708 comment_list *lc,
2704 comment_list *mc) 2709 comment_list *mc)
2705 { 2710 {
2706 tree_command *retval = 0; 2711 tree_command *retval = nullptr;
2707 2712
2708 if (end_token_ok (end_tok, token::unwind_protect_end)) 2713 if (end_token_ok (end_tok, token::unwind_protect_end))
2709 { 2714 {
2710 comment_list *tc = m_lexer.comment_buf.get_comment (); 2715 comment_list *tc = m_lexer.comment_buf.get_comment ();
2711 2716
2735 tree_statement_list *cleanup_stmts, 2740 tree_statement_list *cleanup_stmts,
2736 token *end_tok, 2741 token *end_tok,
2737 comment_list *lc, 2742 comment_list *lc,
2738 comment_list *mc) 2743 comment_list *mc)
2739 { 2744 {
2740 tree_command *retval = 0; 2745 tree_command *retval = nullptr;
2741 2746
2742 if (end_token_ok (end_tok, token::try_catch_end)) 2747 if (end_token_ok (end_tok, token::try_catch_end))
2743 { 2748 {
2744 comment_list *tc = m_lexer.comment_buf.get_comment (); 2749 comment_list *tc = m_lexer.comment_buf.get_comment ();
2745 2750
2746 int l = try_tok->line (); 2751 int l = try_tok->line ();
2747 int c = try_tok->column (); 2752 int c = try_tok->column ();
2748 2753
2749 tree_identifier *id = 0; 2754 tree_identifier *id = nullptr;
2750 2755
2751 if (! catch_sep && cleanup_stmts && ! cleanup_stmts->empty ()) 2756 if (! catch_sep && cleanup_stmts && ! cleanup_stmts->empty ())
2752 { 2757 {
2753 tree_statement *stmt = cleanup_stmts->front (); 2758 tree_statement *stmt = cleanup_stmts->front ();
2754 2759
2760 { 2765 {
2761 id = dynamic_cast<tree_identifier *> (expr); 2766 id = dynamic_cast<tree_identifier *> (expr);
2762 2767
2763 cleanup_stmts->pop_front (); 2768 cleanup_stmts->pop_front ();
2764 2769
2765 stmt->set_expression (0); 2770 stmt->set_expression (nullptr);
2766 delete stmt; 2771 delete stmt;
2767 } 2772 }
2768 } 2773 }
2769 } 2774 }
2770 2775
2846 tree_expression *maxproc, 2851 tree_expression *maxproc,
2847 tree_statement_list *body, 2852 tree_statement_list *body,
2848 token *end_tok, 2853 token *end_tok,
2849 comment_list *lc) 2854 comment_list *lc)
2850 { 2855 {
2851 tree_command *retval = 0; 2856 tree_command *retval = nullptr;
2852 2857
2853 bool parfor = tok_id == PARFOR; 2858 bool parfor = tok_id == PARFOR;
2854 2859
2855 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end)) 2860 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end))
2856 { 2861 {
2910 int c = break_tok->column (); 2915 int c = break_tok->column ();
2911 2916
2912 if (! m_lexer.looping) 2917 if (! m_lexer.looping)
2913 { 2918 {
2914 bison_error ("break must appear in a loop in the same file as loop command"); 2919 bison_error ("break must appear in a loop in the same file as loop command");
2915 return 0; 2920 return nullptr;
2916 } 2921 }
2917 else 2922 else
2918 return new tree_break_command (l, c); 2923 return new tree_break_command (l, c);
2919 } 2924 }
2920 2925
2959 base_parser::finish_if_command (token *if_tok, 2964 base_parser::finish_if_command (token *if_tok,
2960 tree_if_command_list *list, 2965 tree_if_command_list *list,
2961 token *end_tok, 2966 token *end_tok,
2962 comment_list *lc) 2967 comment_list *lc)
2963 { 2968 {
2964 tree_if_command *retval = 0; 2969 tree_if_command *retval = nullptr;
2965 2970
2966 if (end_token_ok (end_tok, token::if_end)) 2971 if (end_token_ok (end_tok, token::if_end))
2967 { 2972 {
2968 comment_list *tc = m_lexer.comment_buf.get_comment (); 2973 comment_list *tc = m_lexer.comment_buf.get_comment ();
2969 2974
3016 tree_expression *expr, 3021 tree_expression *expr,
3017 tree_switch_case_list *list, 3022 tree_switch_case_list *list,
3018 token *end_tok, 3023 token *end_tok,
3019 comment_list *lc) 3024 comment_list *lc)
3020 { 3025 {
3021 tree_switch_command *retval = 0; 3026 tree_switch_command *retval = nullptr;
3022 3027
3023 if (end_token_ok (end_tok, token::switch_end)) 3028 if (end_token_ok (end_tok, token::switch_end))
3024 { 3029 {
3025 comment_list *tc = m_lexer.comment_buf.get_comment (); 3030 comment_list *tc = m_lexer.comment_buf.get_comment ();
3026 3031
3145 delete lhs; 3150 delete lhs;
3146 delete rhs; 3151 delete rhs;
3147 3152
3148 bison_error ("computed multiple assignment not allowed", l, c); 3153 bison_error ("computed multiple assignment not allowed", l, c);
3149 3154
3150 return 0; 3155 return nullptr;
3151 } 3156 }
3152 3157
3153 if (lhs->is_simple_assign_lhs ()) 3158 if (lhs->is_simple_assign_lhs ())
3154 { 3159 {
3155 // We are looking at a simple assignment statement like x = rhs; 3160 // We are looking at a simple assignment statement like x = rhs;
3165 delete lhs; 3170 delete lhs;
3166 delete rhs; 3171 delete rhs;
3167 3172
3168 bison_error ("invalid assignment to keyword \"" + kw + "\"", l, c); 3173 bison_error ("invalid assignment to keyword \"" + kw + "\"", l, c);
3169 3174
3170 return 0; 3175 return nullptr;
3171 } 3176 }
3172 3177
3173 delete lhs; 3178 delete lhs;
3174 3179
3175 return new tree_simple_assignment (tmp, rhs, false, l, c, t); 3180 return new tree_simple_assignment (tmp, rhs, false, l, c, t);
3186 delete rhs; 3191 delete rhs;
3187 3192
3188 bison_error ("invalid assignment to keyword \"" + kw + "\"", 3193 bison_error ("invalid assignment to keyword \"" + kw + "\"",
3189 l, c); 3194 l, c);
3190 3195
3191 return 0; 3196 return nullptr;
3192 } 3197 }
3193 } 3198 }
3194 3199
3195 return new tree_multi_assignment (lhs, rhs, false, l, c); 3200 return new tree_multi_assignment (lhs, rhs, false, l, c);
3196 } 3201 }
3234 tree_parameter_list *param_list, 3239 tree_parameter_list *param_list,
3235 tree_statement_list *body, 3240 tree_statement_list *body,
3236 tree_statement *end_fcn_stmt, 3241 tree_statement *end_fcn_stmt,
3237 comment_list *lc) 3242 comment_list *lc)
3238 { 3243 {
3239 tree_function_def *retval = 0; 3244 tree_function_def *retval = nullptr;
3240 3245
3241 int l = fcn_tok->line (); 3246 int l = fcn_tok->line ();
3242 int c = fcn_tok->column (); 3247 int c = fcn_tok->column ();
3243 3248
3244 octave_user_function *tmp_fcn 3249 octave_user_function *tmp_fcn
3278 3283
3279 body->append (end_fcn_stmt); 3284 body->append (end_fcn_stmt);
3280 3285
3281 octave_user_function *fcn 3286 octave_user_function *fcn
3282 = new octave_user_function (m_lexer.symtab_context.curr_scope (), 3287 = new octave_user_function (m_lexer.symtab_context.curr_scope (),
3283 param_list, 0, body); 3288 param_list, nullptr, body);
3284 3289
3285 if (fcn) 3290 if (fcn)
3286 { 3291 {
3287 comment_list *tc = m_lexer.comment_buf.get_comment (); 3292 comment_list *tc = m_lexer.comment_buf.get_comment ();
3288 3293
3397 base_parser::finish_function (tree_parameter_list *ret_list, 3402 base_parser::finish_function (tree_parameter_list *ret_list,
3398 octave_user_function *fcn, 3403 octave_user_function *fcn,
3399 comment_list *lc, 3404 comment_list *lc,
3400 int l, int c) 3405 int l, int c)
3401 { 3406 {
3402 tree_function_def *retval = 0; 3407 tree_function_def *retval = nullptr;
3403 3408
3404 if (ret_list) 3409 if (ret_list)
3405 ret_list->mark_as_formal_parameters (); 3410 ret_list->mark_as_formal_parameters ();
3406 3411
3407 if (fcn) 3412 if (fcn)
3541 tree_identifier *id, 3546 tree_identifier *id,
3542 tree_classdef_superclass_list *sc, 3547 tree_classdef_superclass_list *sc,
3543 tree_classdef_body *body, token *end_tok, 3548 tree_classdef_body *body, token *end_tok,
3544 comment_list *lc) 3549 comment_list *lc)
3545 { 3550 {
3546 tree_classdef *retval = 0; 3551 tree_classdef *retval = nullptr;
3547 3552
3548 m_lexer.symtab_context.pop (); 3553 m_lexer.symtab_context.pop ();
3549 3554
3550 std::string cls_name = id->name (); 3555 std::string cls_name = id->name ();
3551 3556
3600 tree_classdef_attribute_list *a, 3605 tree_classdef_attribute_list *a,
3601 tree_classdef_property_list *plist, 3606 tree_classdef_property_list *plist,
3602 token *end_tok, 3607 token *end_tok,
3603 comment_list *lc) 3608 comment_list *lc)
3604 { 3609 {
3605 tree_classdef_properties_block *retval = 0; 3610 tree_classdef_properties_block *retval = nullptr;
3606 3611
3607 if (end_token_ok (end_tok, token::properties_end)) 3612 if (end_token_ok (end_tok, token::properties_end))
3608 { 3613 {
3609 comment_list *tc = m_lexer.comment_buf.get_comment (); 3614 comment_list *tc = m_lexer.comment_buf.get_comment ();
3610 3615
3632 tree_classdef_attribute_list *a, 3637 tree_classdef_attribute_list *a,
3633 tree_classdef_methods_list *mlist, 3638 tree_classdef_methods_list *mlist,
3634 token *end_tok, 3639 token *end_tok,
3635 comment_list *lc) 3640 comment_list *lc)
3636 { 3641 {
3637 tree_classdef_methods_block *retval = 0; 3642 tree_classdef_methods_block *retval = nullptr;
3638 3643
3639 if (end_token_ok (end_tok, token::methods_end)) 3644 if (end_token_ok (end_tok, token::methods_end))
3640 { 3645 {
3641 comment_list *tc = m_lexer.comment_buf.get_comment (); 3646 comment_list *tc = m_lexer.comment_buf.get_comment ();
3642 3647
3664 tree_classdef_attribute_list *a, 3669 tree_classdef_attribute_list *a,
3665 tree_classdef_events_list *elist, 3670 tree_classdef_events_list *elist,
3666 token *end_tok, 3671 token *end_tok,
3667 comment_list *lc) 3672 comment_list *lc)
3668 { 3673 {
3669 tree_classdef_events_block *retval = 0; 3674 tree_classdef_events_block *retval = nullptr;
3670 3675
3671 if (end_token_ok (end_tok, token::events_end)) 3676 if (end_token_ok (end_tok, token::events_end))
3672 { 3677 {
3673 comment_list *tc = m_lexer.comment_buf.get_comment (); 3678 comment_list *tc = m_lexer.comment_buf.get_comment ();
3674 3679
3696 tree_classdef_attribute_list *a, 3701 tree_classdef_attribute_list *a,
3697 tree_classdef_enum_list *elist, 3702 tree_classdef_enum_list *elist,
3698 token *end_tok, 3703 token *end_tok,
3699 comment_list *lc) 3704 comment_list *lc)
3700 { 3705 {
3701 tree_classdef_enum_block *retval = 0; 3706 tree_classdef_enum_block *retval = nullptr;
3702 3707
3703 if (end_token_ok (end_tok, token::enumeration_end)) 3708 if (end_token_ok (end_tok, token::enumeration_end))
3704 { 3709 {
3705 comment_list *tc = m_lexer.comment_buf.get_comment (); 3710 comment_list *tc = m_lexer.comment_buf.get_comment ();
3706 3711
3725 3730
3726 octave_user_function* 3731 octave_user_function*
3727 base_parser::start_classdef_external_method (tree_identifier *id, 3732 base_parser::start_classdef_external_method (tree_identifier *id,
3728 tree_parameter_list *pl) 3733 tree_parameter_list *pl)
3729 { 3734 {
3730 octave_user_function* retval = 0; 3735 octave_user_function* retval = nullptr;
3731 3736
3732 // External methods are only allowed within @-folders. In this case, 3737 // External methods are only allowed within @-folders. In this case,
3733 // m_curr_class_name will be non-empty. 3738 // m_curr_class_name will be non-empty.
3734 3739
3735 if (! m_curr_class_name.empty ()) 3740 if (! m_curr_class_name.empty ())
3747 && mname != m_curr_class_name) 3752 && mname != m_curr_class_name)
3748 { 3753 {
3749 // Create a dummy function that is used until the real method 3754 // Create a dummy function that is used until the real method
3750 // is loaded. 3755 // is loaded.
3751 3756
3752 retval = new octave_user_function (0, pl); 3757 retval = new octave_user_function (nullptr, pl);
3753 3758
3754 retval->stash_function_name (mname); 3759 retval->stash_function_name (mname);
3755 3760
3756 int l = id->line (); 3761 int l = id->line ();
3757 int c = id->column (); 3762 int c = id->column ();
3794 tree_index_expression * 3799 tree_index_expression *
3795 base_parser::make_index_expression (tree_expression *expr, 3800 base_parser::make_index_expression (tree_expression *expr,
3796 tree_argument_list *args, 3801 tree_argument_list *args,
3797 char type) 3802 char type)
3798 { 3803 {
3799 tree_index_expression *retval = 0; 3804 tree_index_expression *retval = nullptr;
3800 3805
3801 if (args && args->has_magic_tilde ()) 3806 if (args && args->has_magic_tilde ())
3802 { 3807 {
3803 delete expr; 3808 delete expr;
3804 delete args; 3809 delete args;
3833 3838
3834 tree_index_expression * 3839 tree_index_expression *
3835 base_parser::make_indirect_ref (tree_expression *expr, 3840 base_parser::make_indirect_ref (tree_expression *expr,
3836 const std::string& elt) 3841 const std::string& elt)
3837 { 3842 {
3838 tree_index_expression *retval = 0; 3843 tree_index_expression *retval = nullptr;
3839 3844
3840 int l = expr->line (); 3845 int l = expr->line ();
3841 int c = expr->column (); 3846 int c = expr->column ();
3842 3847
3843 if (! expr->is_postfix_indexed ()) 3848 if (! expr->is_postfix_indexed ())
3863 3868
3864 tree_index_expression * 3869 tree_index_expression *
3865 base_parser::make_indirect_ref (tree_expression *expr, 3870 base_parser::make_indirect_ref (tree_expression *expr,
3866 tree_expression *elt) 3871 tree_expression *elt)
3867 { 3872 {
3868 tree_index_expression *retval = 0; 3873 tree_index_expression *retval = nullptr;
3869 3874
3870 int l = expr->line (); 3875 int l = expr->line ();
3871 int c = expr->column (); 3876 int c = expr->column ();
3872 3877
3873 if (! expr->is_postfix_indexed ()) 3878 if (! expr->is_postfix_indexed ())
3893 3898
3894 tree_decl_command * 3899 tree_decl_command *
3895 base_parser::make_decl_command (int tok, token *tok_val, 3900 base_parser::make_decl_command (int tok, token *tok_val,
3896 tree_decl_init_list *lst) 3901 tree_decl_init_list *lst)
3897 { 3902 {
3898 tree_decl_command *retval = 0; 3903 tree_decl_command *retval = nullptr;
3899 3904
3900 int l = tok_val->line (); 3905 int l = tok_val->line ();
3901 int c = tok_val->column (); 3906 int c = tok_val->column ();
3902 3907
3903 switch (tok) 3908 switch (tok)
4020 } 4025 }
4021 4026
4022 tree_argument_list * 4027 tree_argument_list *
4023 base_parser::validate_matrix_for_assignment (tree_expression *e) 4028 base_parser::validate_matrix_for_assignment (tree_expression *e)
4024 { 4029 {
4025 tree_argument_list *retval = 0; 4030 tree_argument_list *retval = nullptr;
4026 4031
4027 if (e->is_constant ()) 4032 if (e->is_constant ())
4028 { 4033 {
4029 tree_evaluator& tw 4034 tree_evaluator& tw
4030 = __get_evaluator__ ("validate_matrix_for_assignment"); 4035 = __get_evaluator__ ("validate_matrix_for_assignment");
4040 } 4045 }
4041 else 4046 else
4042 { 4047 {
4043 bool is_simple_assign = true; 4048 bool is_simple_assign = true;
4044 4049
4045 tree_argument_list *tmp = 0; 4050 tree_argument_list *tmp = nullptr;
4046 4051
4047 if (e->is_matrix ()) 4052 if (e->is_matrix ())
4048 { 4053 {
4049 tree_matrix *mat = dynamic_cast<tree_matrix *> (e); 4054 tree_matrix *mat = dynamic_cast<tree_matrix *> (e);
4050 4055
4401 { 4406 {
4402 octave_value retval; 4407 octave_value retval;
4403 4408
4404 octave::unwind_protect frame; 4409 octave::unwind_protect frame;
4405 4410
4406 octave_function *fcn_ptr = 0; 4411 octave_function *fcn_ptr = nullptr;
4407 4412
4408 // Open function file and parse. 4413 // Open function file and parse.
4409 4414
4410 FILE *in_stream = octave::command_editor::get_input_stream (); 4415 FILE *in_stream = octave::command_editor::get_input_stream ();
4411 4416
4414 frame.add_fcn (octave::command_history::ignore_entries, 4419 frame.add_fcn (octave::command_history::ignore_entries,
4415 octave::command_history::ignoring_entries ()); 4420 octave::command_history::ignoring_entries ());
4416 4421
4417 octave::command_history::ignore_entries (); 4422 octave::command_history::ignore_entries ();
4418 4423
4419 FILE *ffile = 0; 4424 FILE *ffile = nullptr;
4420 4425
4421 if (! full_file.empty ()) 4426 if (! full_file.empty ())
4422 ffile = std::fopen (full_file.c_str (), "rb"); 4427 ffile = std::fopen (full_file.c_str (), "rb");
4423 4428
4424 if (ffile) 4429 if (ffile)
4467 if (fcn_ptr) 4472 if (fcn_ptr)
4468 retval = octave_value (fcn_ptr); 4473 retval = octave_value (fcn_ptr);
4469 4474
4470 delete (parser.m_classdef_object); 4475 delete (parser.m_classdef_object);
4471 4476
4472 parser.m_classdef_object = 0; 4477 parser.m_classdef_object = nullptr;
4473 } 4478 }
4474 else if (fcn_ptr) 4479 else if (fcn_ptr)
4475 { 4480 {
4476 retval = octave_value (fcn_ptr); 4481 retval = octave_value (fcn_ptr);
4477 4482
5287 5292
5288 if (parse_status == 0) 5293 if (parse_status == 0)
5289 { 5294 {
5290 if (parser.m_stmt_list) 5295 if (parser.m_stmt_list)
5291 { 5296 {
5292 tree_statement *stmt = 0; 5297 tree_statement *stmt = nullptr;
5293 5298
5294 tree_evaluator& tw = __get_evaluator__ ("eval_string"); 5299 tree_evaluator& tw = __get_evaluator__ ("eval_string");
5295 5300
5296 if (parser.m_stmt_list->length () == 1 5301 if (parser.m_stmt_list->length () == 1
5297 && (stmt = parser.m_stmt_list->front ()) 5302 && (stmt = parser.m_stmt_list->front ())
5367 cleanup_statement_list (tree_statement_list **lst) 5372 cleanup_statement_list (tree_statement_list **lst)
5368 { 5373 {
5369 if (*lst) 5374 if (*lst)
5370 { 5375 {
5371 delete *lst; 5376 delete *lst;
5372 *lst = 0; 5377 *lst = nullptr;
5373 } 5378 }
5374 } 5379 }
5375 } 5380 }
5376 5381
5377 DEFUN (eval, args, nargout, 5382 DEFUN (eval, args, nargout,