comparison src/parse.y @ 3371:86873384cd10

[project @ 1999-11-21 17:31:07 by jwe]
author jwe
date Sun, 21 Nov 1999 17:31:10 +0000
parents abdd5ed1bb4e
children 42cb61dd0248
comparison
equal deleted inserted replaced
3370:0b88d26ed552 3371:86873384cd10
3070 3070
3071 return script_file_executed; 3071 return script_file_executed;
3072 } 3072 }
3073 3073
3074 DEFUN (source, args, , 3074 DEFUN (source, args, ,
3075 "source (FILE)\n\ 3075 "-*- texinfo -*-\n\
3076 \n\ 3076 @deftypefn {Built-in Function} {} source (@var{file})\n\
3077 Parse and execute the contents of FILE. Like executing commands in a\n\ 3077 Parse and execute the contents of @var{file}. This is equivalent to\n\
3078 script file but without requiring the file to be named `FILE.m'.") 3078 executing commands from a script file, but without requiring the file to\n\
3079 be named @file{@var{file}.m}.\n\
3080 @end deftypefn")
3079 { 3081 {
3080 octave_value_list retval; 3082 octave_value_list retval;
3081 3083
3082 int nargin = args.length (); 3084 int nargin = args.length ();
3083 3085
3154 3156
3155 return retval; 3157 return retval;
3156 } 3158 }
3157 3159
3158 DEFUN (feval, args, nargout, 3160 DEFUN (feval, args, nargout,
3159 "feval (NAME, ARGS, ...)\n\ 3161 "-*- texinfo -*-\n\
3162 @deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\
3163 Evaluate the function named @var{name}. Any arguments after the first\n\
3164 are passed on to the named function. For example,\n\
3160 \n\ 3165 \n\
3161 evaluate NAME as a function, passing ARGS as its arguments") 3166 @example\n\
3167 feval (\"acos\", -1)\n\
3168 @result{} 3.1416\n\
3169 @end example\n\
3170 \n\
3171 @noindent\n\
3172 calls the function @code{acos} with the argument @samp{-1}.\n\
3173 \n\
3174 The function @code{feval} is necessary in order to be able to write\n\
3175 functions that call user-supplied functions, because Octave does not\n\
3176 have a way to declare a pointer to a function (like C) or to declare a\n\
3177 special kind of variable that can be used to hold the name of a function\n\
3178 (like @code{EXTERNAL} in Fortran). Instead, you must refer to functions\n\
3179 by name, and use @code{feval} to call them.\n\
3180 @end deftypefn")
3162 { 3181 {
3163 octave_value_list retval; 3182 octave_value_list retval;
3164 3183
3165 int nargin = args.length (); 3184 int nargin = args.length ();
3166 3185
3246 3265
3247 return eval_string (s, silent, parse_status, nargout); 3266 return eval_string (s, silent, parse_status, nargout);
3248 } 3267 }
3249 3268
3250 DEFUN (eval, args, nargout, 3269 DEFUN (eval, args, nargout,
3251 "eval (TRY, CATCH)\n\ 3270 "-*- texinfo -*-\n\
3271 @deftypefn {Built-in Function} {} eval (@var{try}, @var{catch})\n\
3272 Parse the string @var{try} and evaluate it as if it were an Octave\n\
3273 program, returning the last value computed. If that fails, evaluate\n\
3274 the string @var{catch}. The string @var{try} is evaluated in the\n\
3275 current context, so any results remain available after @code{eval}\n\
3276 returns. For example,\n\
3252 \n\ 3277 \n\
3253 Evaluate the string TRY as octave code. If that fails, evaluate the\n\ 3278 @example\n\
3254 string CATCH.") 3279 @group\n\
3280 eval (\"a = 13\")\n\
3281 @print{} a = 13\n\
3282 @result{} 13\n\
3283 @end group\n\
3284 @end example\n\
3285 \n\
3286 In this case, the value of the evaluated expression is printed and it is\n\
3287 also returned returned from @code{eval}. Just as with any other\n\
3288 expression, you can turn printing off by ending the expression in a\n\
3289 semicolon. For example,\n\
3290 \n\
3291 @example\n\
3292 eval (\"a = 13;\")\n\
3293 @result{} 13\n\
3294 @end example\n\
3295 \n\
3296 In this example, the variable @code{a} has been given the value 13, but\n\
3297 the value of the expression is not printed. You can also turn off\n\
3298 automatic printing for all expressions executed by @code{eval} using the\n\
3299 variable @code{default_eval_print_flag}.\n\
3300 @end deftypefn")
3255 { 3301 {
3256 octave_value_list retval; 3302 octave_value_list retval;
3257 3303
3258 int nargin = args.length (); 3304 int nargin = args.length ();
3259 3305
3348 3394
3349 void 3395 void
3350 symbols_of_parse (void) 3396 symbols_of_parse (void)
3351 { 3397 {
3352 DEFVAR (default_eval_print_flag, 1.0, default_eval_print_flag, 3398 DEFVAR (default_eval_print_flag, 1.0, default_eval_print_flag,
3353 "If the value of this variable is nonzero, Octave will print the\n\ 3399 "-*- texinfo -*-\n\
3354 results of commands executed by eval() that do not end with semicolons."); 3400 @defvr {Built-in Variable} default_eval_print_flag\n\
3401 If the value of this variable is nonzero, Octave prints the results of\n\
3402 commands executed by @code{eval} that do not end with semicolons. If it\n\
3403 is zero, automatic printing is suppressed. The default value is 1.\n\
3404 @end defvr");
3355 3405
3356 DEFVAR (warn_assign_as_truth_value, 1.0, warn_assign_as_truth_value, 3406 DEFVAR (warn_assign_as_truth_value, 1.0, warn_assign_as_truth_value,
3357 "-*- texinfo -*-\n\ 3407 "-*- texinfo -*-\n\
3358 @defvr {Built-in Variable} warn_assign_as_truth_value\n\ 3408 @defvr {Built-in Variable} warn_assign_as_truth_value\n\
3359 If the value of @code{warn_assign_as_truth_value} is nonzero, a\n\ 3409 If the value of @code{warn_assign_as_truth_value} is nonzero, a\n\
3416 \n\ 3466 \n\
3417 The default value of @code{warn_assign_as_truth_value} is 1.\n\ 3467 The default value of @code{warn_assign_as_truth_value} is 1.\n\
3418 @end defvr"); 3468 @end defvr");
3419 3469
3420 DEFVAR (warn_function_name_clash, 1.0, warn_function_name_clash, 3470 DEFVAR (warn_function_name_clash, 1.0, warn_function_name_clash,
3421 "produce warning if function name conflicts with file name"); 3471 "-*- texinfo -*-\n\
3472 @defvr {Built-in Variable} warn_function_name_clash\n\
3473 If the value of @code{warn_function_name_clash} is nonzero, a warning is\n\
3474 issued when Octave finds that the name of a function defined in a\n\
3475 function file differs from the name of the file. (If the names\n\
3476 disagree, the name declared inside the file is ignored.) If the value\n\
3477 is 0, the warning is omitted. The default value is 1.\n\
3478 @end defvr");
3422 3479
3423 DEFVAR (warn_future_time_stamp, 1.0, warn_future_time_stamp, 3480 DEFVAR (warn_future_time_stamp, 1.0, warn_future_time_stamp,
3424 "warn if a function file has a time stamp that is in the future"); 3481 "warn if a function file has a time stamp that is in the future");
3425 3482
3426 DEFVAR (warn_missing_semicolon, 0.0, warn_missing_semicolon, 3483 DEFVAR (warn_missing_semicolon, 0.0, warn_missing_semicolon,
3427 "produce a warning if a statement in a function file is not\n\ 3484 "-*- texinfo -*-\n\
3428 terminated with a semicolon"); 3485 @defvr {Built-in Variable} warn_missing_semicolon\n\
3486 If the value of this variable is nonzero, Octave will warn when\n\
3487 statements in function definitions don't end in semicolons. The default\n\
3488 value is 0.\n\
3489 @end defvr");
3429 3490
3430 DEFVAR (warn_variable_switch_label, 0.0, warn_variable_switch_label, 3491 DEFVAR (warn_variable_switch_label, 0.0, warn_variable_switch_label,
3431 "-*- texinfo -*-\n\ 3492 "-*- texinfo -*-\n\
3432 @defvr {Built-in Variable} warn_variable_switch_label\n\ 3493 @defvr {Built-in Variable} warn_variable_switch_label\n\
3433 If the value of this variable is nonzero, Octave will print a warning if\n\ 3494 If the value of this variable is nonzero, Octave will print a warning if\n\