comparison src/oct-parse.yy @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents 7d6d8c1e471f
children 91fa3871e9bf
comparison
equal deleted inserted replaced
11585:1473d0cf86d2 11586:12df7854fa7c
635 635
636 superclass_identifier 636 superclass_identifier
637 : SUPERCLASSREF 637 : SUPERCLASSREF
638 { $$ = new tree_identifier ($1->line (), $1->column ()); } 638 { $$ = new tree_identifier ($1->line (), $1->column ()); }
639 ; 639 ;
640 640
641 meta_identifier : METAQUERY 641 meta_identifier : METAQUERY
642 { $$ = new tree_identifier ($1->line (), $1->column ()); } 642 { $$ = new tree_identifier ($1->line (), $1->column ()); }
643 ; 643 ;
644 644
645 string : DQ_STRING 645 string : DQ_STRING
646 { $$ = make_constant (DQ_STRING, $1); } 646 { $$ = make_constant (DQ_STRING, $1); }
647 | SQ_STRING 647 | SQ_STRING
648 { $$ = make_constant (SQ_STRING, $1); } 648 { $$ = make_constant (SQ_STRING, $1); }
735 ; 735 ;
736 736
737 anon_fcn_handle : '@' param_list statement 737 anon_fcn_handle : '@' param_list statement
738 { $$ = make_anon_fcn_handle ($2, $3); } 738 { $$ = make_anon_fcn_handle ($2, $3); }
739 ; 739 ;
740 740
741 primary_expr : identifier 741 primary_expr : identifier
742 { $$ = $1; } 742 { $$ = $1; }
743 | constant 743 | constant
744 { $$ = $1; } 744 { $$ = $1; }
745 | fcn_handle 745 | fcn_handle
1106 { $$ = $1; } 1106 { $$ = $1; }
1107 | case_list1 default_case 1107 | case_list1 default_case
1108 { 1108 {
1109 $1->append ($2); 1109 $1->append ($2);
1110 $$ = $1; 1110 $$ = $1;
1111 } 1111 }
1112 ; 1112 ;
1113 1113
1114 case_list1 : switch_case 1114 case_list1 : switch_case
1115 { $$ = new tree_switch_case_list ($1); } 1115 { $$ = new tree_switch_case_list ($1); }
1116 | case_list1 switch_case 1116 | case_list1 switch_case
1353 1353
1354 function_beg : push_fcn_symtab FCN stash_comment 1354 function_beg : push_fcn_symtab FCN stash_comment
1355 { 1355 {
1356 $$ = $3; 1356 $$ = $3;
1357 1357
1358 if (reading_classdef_file || lexer_flags.parsing_classdef) 1358 if (reading_classdef_file || lexer_flags.parsing_classdef)
1359 lexer_flags.maybe_classdef_get_set_method = true; 1359 lexer_flags.maybe_classdef_get_set_method = true;
1360 } 1360 }
1361 ; 1361 ;
1362 1362
1363 function : function_beg function1 1363 function : function_beg function1
1364 { 1364 {
1376 { 1376 {
1377 std::string id_name = $1->name (); 1377 std::string id_name = $1->name ();
1378 1378
1379 lexer_flags.parsed_function_name.top () = true; 1379 lexer_flags.parsed_function_name.top () = true;
1380 lexer_flags.maybe_classdef_get_set_method = false; 1380 lexer_flags.maybe_classdef_get_set_method = false;
1381 1381
1382 $$ = $1; 1382 $$ = $1;
1383 } 1383 }
1384 | GET '.' identifier 1384 | GET '.' identifier
1385 { 1385 {
1386 lexer_flags.maybe_classdef_get_set_method = false; 1386 lexer_flags.maybe_classdef_get_set_method = false;
1585 ; 1585 ;
1586 1586
1587 class_event : identifier 1587 class_event : identifier
1588 { $$ = 0; } 1588 { $$ = 0; }
1589 ; 1589 ;
1590 1590
1591 // ============= 1591 // =============
1592 // Miscellaneous 1592 // Miscellaneous
1593 // ============= 1593 // =============
1594 1594
1595 stash_comment : // empty 1595 stash_comment : // empty
1715 case token::if_end: 1715 case token::if_end:
1716 error (fmt, type, "endif", l, c); 1716 error (fmt, type, "endif", l, c);
1717 break; 1717 break;
1718 1718
1719 case token::switch_end: 1719 case token::switch_end:
1720 error (fmt, type, "endswitch", l, c); 1720 error (fmt, type, "endswitch", l, c);
1721 break; 1721 break;
1722 1722
1723 case token::while_end: 1723 case token::while_end:
1724 error (fmt, type, "endwhile", l, c); 1724 error (fmt, type, "endwhile", l, c);
1725 break; 1725 break;
1726 1726
1727 case token::try_catch_end: 1727 case token::try_catch_end:
1728 error (fmt, type, "end_try_catch", l, c); 1728 error (fmt, type, "end_try_catch", l, c);
1729 break; 1729 break;
1730 1730
1731 case token::unwind_protect_end: 1731 case token::unwind_protect_end:
1732 error (fmt, type, "end_unwind_protect", l, c); 1732 error (fmt, type, "end_unwind_protect", l, c);
1733 break; 1733 break;
1734 1734
1735 default: 1735 default:
1736 panic_impossible (); 1736 panic_impossible ();
1737 break; 1737 break;
2918 } 2918 }
2919 2919
2920 if (reading_fcn_file && current_function_depth == 1 2920 if (reading_fcn_file && current_function_depth == 1
2921 && ! parsing_subfunctions) 2921 && ! parsing_subfunctions)
2922 primary_fcn_ptr = fcn; 2922 primary_fcn_ptr = fcn;
2923 2923
2924 return fcn; 2924 return fcn;
2925 } 2925 }
2926 2926
2927 static tree_function_def * 2927 static tree_function_def *
2928 finish_function (tree_parameter_list *ret_list, 2928 finish_function (tree_parameter_list *ret_list,
3007 static tree_index_expression * 3007 static tree_index_expression *
3008 make_index_expression (tree_expression *expr, tree_argument_list *args, 3008 make_index_expression (tree_expression *expr, tree_argument_list *args,
3009 char type) 3009 char type)
3010 { 3010 {
3011 tree_index_expression *retval = 0; 3011 tree_index_expression *retval = 0;
3012 3012
3013 if (args && args->has_magic_tilde ()) 3013 if (args && args->has_magic_tilde ())
3014 { 3014 {
3015 yyerror ("invalid use of empty argument (~) in index expression"); 3015 yyerror ("invalid use of empty argument (~) in index expression");
3016 return retval; 3016 return retval;
3017 } 3017 }
3275 bool retval = false; 3275 bool retval = false;
3276 3276
3277 if (! s.empty ()) 3277 if (! s.empty ())
3278 { 3278 {
3279 size_t offset = s.find_first_not_of (" \t"); 3279 size_t offset = s.find_first_not_of (" \t");
3280 3280
3281 retval = (s.substr (offset, 9) == "Copyright"); 3281 retval = (s.substr (offset, 9) == "Copyright");
3282 } 3282 }
3283 3283
3284 return retval; 3284 return retval;
3285 } 3285 }
3320 if (c == '\n') 3320 if (c == '\n')
3321 input_line_number--; 3321 input_line_number--;
3322 3322
3323 return ::ungetc (c, f); 3323 return ::ungetc (c, f);
3324 } 3324 }
3325 3325
3326 private: 3326 private:
3327 FILE *f; 3327 FILE *f;
3328 }; 3328 };
3329 3329
3330 static bool 3330 static bool
3557 3557
3558 reset_parser (); 3558 reset_parser ();
3559 3559
3560 // Do this with an unwind-protect cleanup function so that 3560 // Do this with an unwind-protect cleanup function so that
3561 // the forced variables will be unmarked in the event of an 3561 // the forced variables will be unmarked in the event of an
3562 // interrupt. 3562 // interrupt.
3563 symbol_table::scope_id scope = symbol_table::top_scope (); 3563 symbol_table::scope_id scope = symbol_table::top_scope ();
3564 frame.add_fcn (symbol_table::unmark_forced_variables, scope); 3564 frame.add_fcn (symbol_table::unmark_forced_variables, scope);
3565 3565
3566 if (! help_txt.empty ()) 3566 if (! help_txt.empty ())
3567 help_buf.push (help_txt); 3567 help_buf.push (help_txt);
3603 } 3603 }
3604 } 3604 }
3605 else if (require_file) 3605 else if (require_file)
3606 error ("no such file, `%s'", ff.c_str ()); 3606 error ("no such file, `%s'", ff.c_str ());
3607 else if (! warn_for.empty ()) 3607 else if (! warn_for.empty ())
3608 error ("%s: unable to open file `%s'", warn_for.c_str (), ff.c_str ()); 3608 error ("%s: unable to open file `%s'", warn_for.c_str (), ff.c_str ());
3609 3609
3610 return fcn_ptr; 3610 return fcn_ptr;
3611 } 3611 }
3612 3612
3613 std::string 3613 std::string
3669 retval = load_path::find_file (p->second); 3669 retval = load_path::find_file (p->second);
3670 3670
3671 return retval; 3671 return retval;
3672 } 3672 }
3673 3673
3674 string_vector 3674 string_vector
3675 autoloaded_functions (void) 3675 autoloaded_functions (void)
3676 { 3676 {
3677 string_vector names (autoload_map.size()); 3677 string_vector names (autoload_map.size());
3678 3678
3679 octave_idx_type i = 0; 3679 octave_idx_type i = 0;
3757 frame.protect_var (curr_fcn_file_full_name); 3757 frame.protect_var (curr_fcn_file_full_name);
3758 3758
3759 curr_fcn_file_name = nm; 3759 curr_fcn_file_name = nm;
3760 curr_fcn_file_full_name = file.substr (0, len - 2); 3760 curr_fcn_file_full_name = file.substr (0, len - 2);
3761 3761
3762 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), 3762 octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2),
3763 dispatch_type, autoloading, 3763 dispatch_type, autoloading,
3764 false); 3764 false);
3765 3765
3766 retval = octave_dynamic_loader::load_mex (nm, file, fcn_file_from_relative_lookup); 3766 retval = octave_dynamic_loader::load_mex (nm, file, fcn_file_from_relative_lookup);
3767 3767
3768 if (tmpfcn) 3768 if (tmpfcn)
3976 else 3976 else
3977 error ("source: context must be \"caller\" or \"base\""); 3977 error ("source: context must be \"caller\" or \"base\"");
3978 3978
3979 if (! error_state) 3979 if (! error_state)
3980 frame.add_fcn (octave_call_stack::pop); 3980 frame.add_fcn (octave_call_stack::pop);
3981 } 3981 }
3982 3982
3983 if (! error_state) 3983 if (! error_state)
3984 { 3984 {
3985 octave_function *fcn = parse_fcn_file (file_full_name, "", true, 3985 octave_function *fcn = parse_fcn_file (file_full_name, "", true,
3986 require_file, warn_for); 3986 require_file, warn_for);
4119 } 4119 }
4120 4120
4121 // Evaluate an Octave function (built-in or interpreted) and return 4121 // Evaluate an Octave function (built-in or interpreted) and return
4122 // the list of result values. NAME is the name of the function to 4122 // the list of result values. NAME is the name of the function to
4123 // call. ARGS are the arguments to the function. NARGOUT is the 4123 // call. ARGS are the arguments to the function. NARGOUT is the
4124 // number of output arguments expected. 4124 // number of output arguments expected.
4125 4125
4126 octave_value_list 4126 octave_value_list
4127 feval (const std::string& name, const octave_value_list& args, int nargout) 4127 feval (const std::string& name, const octave_value_list& args, int nargout)
4128 { 4128 {
4129 octave_value_list retval; 4129 octave_value_list retval;
4242 @deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\ 4242 @deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\
4243 Call the base function @var{f} even if @var{f} is overloaded to\n\ 4243 Call the base function @var{f} even if @var{f} is overloaded to\n\
4244 another function for the given type signature.\n\ 4244 another function for the given type signature.\n\
4245 @end deftypefn") 4245 @end deftypefn")
4246 { 4246 {
4247 octave_value_list retval; 4247 octave_value_list retval;
4248 4248
4249 int nargin = args.length (); 4249 int nargin = args.length ();
4250 4250
4251 if (nargin > 0) 4251 if (nargin > 0)
4252 { 4252 {
4253 const std::string name (args(0).string_value ()); 4253 const std::string name (args(0).string_value ());
4254 4254
4255 if (! error_state) 4255 if (! error_state)
4256 { 4256 {
4257 octave_value fcn = symbol_table::builtin_find (name); 4257 octave_value fcn = symbol_table::builtin_find (name);
4258 4258
4259 if (fcn.is_defined ()) 4259 if (fcn.is_defined ())