Mercurial > hg > octave-nkf
diff src/lex.l @ 4264:4e2d2516da22
[project @ 2003-01-03 05:30:34 by jwe]
author | jwe |
---|---|
date | Fri, 03 Jan 2003 05:30:34 +0000 |
parents | eef64f3f9a4c |
children | 115bffcecfd3 |
line wrap: on
line diff
--- a/src/lex.l +++ b/src/lex.l @@ -54,6 +54,7 @@ // because it may not be protected to allow it to be included multiple // times. +#include "Cell.h" #include "comment-list.h" #include "defun.h" #include "error.h" @@ -2574,6 +2575,44 @@ quote_is_transpose = false; } +DEFCMD (iskeyword, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} iskeyword (@var{name})\n\ +Return true if @var{name} is an Octave keyword. If @var{name}\n\ +is omitted, return a list of keywords.\n\ +@end deftypefn") +{ + octave_value retval; + + int argc = args.length () + 1; + + string_vector argv = args.make_argv ("help"); + + if (error_state) + return retval; + + if (argc == 1) + { + string_vector lst (TOTAL_KEYWORDS); + + for (int i = 0; i < TOTAL_KEYWORDS; i++) + lst[i] = wordlist[i].name; + + retval = Cell (lst.qsort ()); + } + else if (argc == 2) + { + std::string s = argv[1]; + + retval = (octave_kw_lookup (s.c_str (), s.length ()) != 0); + } + else + print_usage ("iskeyword"); + + return retval; +} + + static void maybe_warn_separator_insert (char sep) {