1
|
1 // help.cc -*- C++ -*- |
|
2 /* |
|
3 |
389
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
1
|
26 #endif |
|
27 |
|
28 #include <iostream.h> |
240
|
29 |
1
|
30 #include "builtins.h" |
242
|
31 #include "utils.h" |
1
|
32 #include "help.h" |
|
33 |
|
34 static help_list operators[] = |
|
35 { |
|
36 { "!", |
|
37 "Logical not operator. See also `~'.\n", }, |
|
38 |
|
39 { "!=", |
|
40 "Logical not equals operator. See also `~' and `<>'.\n", }, |
|
41 |
|
42 { "\"", |
|
43 "String delimiter.\n", }, |
|
44 |
|
45 { "#", |
|
46 "Begin comment character. See also `%'.\n", }, |
|
47 |
|
48 { "%", |
|
49 "Begin comment charcter. See also `#'.\n", }, |
|
50 |
|
51 { "&", |
|
52 "Logical and operator. See also `&&'.\n", }, |
|
53 |
|
54 { "&&", |
|
55 "Logical and operator. See also `&'.\n", }, |
|
56 |
|
57 { "'", |
|
58 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
59 complex conjugate (Hermitian) transpose. See also `.''\n\ |
|
60 \n\ |
|
61 The single quote character may also be used to delimit strings, but\n\ |
|
62 it is better to use the double quote character, since that is never\n\ |
|
63 ambiguous\n", }, |
|
64 |
|
65 { "(", |
|
66 "Array index or function argument delimiter.\n", }, |
|
67 |
|
68 { ")", |
|
69 "Array index or function argument delimiter.\n", }, |
|
70 |
|
71 { "*", |
|
72 "Multiplication operator. See also `.*'\n", }, |
|
73 |
|
74 { "**", |
|
75 "Power operator. See also `^', `.**', and `.^'\n", }, |
|
76 |
|
77 { "+", |
|
78 "Addition operator.\n", }, |
|
79 |
|
80 { "++", |
|
81 "Increment operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
82 |
|
83 { ",", |
|
84 "Array index, function argument, or command separator.\n", }, |
|
85 |
|
86 { "-", |
|
87 "Subtraction or unary negation operator.\n", }, |
|
88 |
|
89 { "--", |
|
90 "Decrement operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
91 |
|
92 { ".'", |
|
93 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
94 transpose, *not* the complex conjugate transpose. See also `''.\n", }, |
|
95 |
|
96 { ".*", |
|
97 "Element by element multiplication operator. See also `*'.\n", }, |
|
98 |
|
99 { ".**", |
|
100 "Element by element power operator. See also `**', `^', and `.^'.\n", }, |
|
101 |
|
102 { "./", |
|
103 "Element by element division operator. See also `/' and `\\'.\n", }, |
|
104 |
|
105 { ".^", |
389
|
106 "Element by element power operator. See also `**', `^', and `.^'.\n", }, |
1
|
107 |
|
108 { "/", |
|
109 "Right division. See also `\\' and `./'.\n", }, |
|
110 |
|
111 { ":", |
|
112 "Select entire rows or columns of matrices.\n", }, |
|
113 |
|
114 { ";", |
|
115 "Array row or command separator. See also `,'.\n", }, |
|
116 |
|
117 { "<", |
|
118 "Less than operator.\n", }, |
|
119 |
|
120 { "<=", |
|
121 "Less than or equals operator.\n", }, |
|
122 |
|
123 { "<>", |
|
124 "Logical not equals operator. See also `!=' and `~='.\n", }, |
|
125 |
|
126 { "=", |
|
127 "Assignment operator.\n", }, |
|
128 |
|
129 { "==", |
|
130 "Equality test operator.\n", }, |
|
131 |
|
132 { ">", |
|
133 "Greater than operator.\n", }, |
|
134 |
|
135 { ">=", |
|
136 "Greater than or equals operator.\n", }, |
|
137 |
|
138 { "[", |
|
139 "Return list delimiter. See also `]'.\n", }, |
|
140 |
|
141 { "\\", |
|
142 "Left division operator. See also `/' and `./'.\n", }, |
|
143 |
|
144 { "]", |
|
145 "Return list delimiter. See also `['.\n", }, |
|
146 |
|
147 { "^", |
|
148 "Power operator. See also `**', `.^', and `.**.'\n", }, |
|
149 |
|
150 { "|", |
|
151 "Logical or operator. See also `||'.\n", }, |
|
152 |
|
153 { "||", |
|
154 "Logical or operator. See also `|'.\n", }, |
|
155 |
|
156 { "~", |
|
157 "Logical not operator. See also `!' and `~'.\n", }, |
|
158 |
|
159 { "~=", |
|
160 "Logical not equals operator. See also `<>' and `!='.\n", }, |
|
161 |
|
162 { (char *) NULL, (char *) NULL, }, |
|
163 }; |
|
164 |
|
165 static help_list keywords[] = |
|
166 { |
|
167 { "break", |
|
168 "Exit the innermost enclosing while or for loop.\n", }, |
|
169 |
|
170 { "continue", |
|
171 "Jump to the end of the innermost enclosing while or for loop.\n", }, |
|
172 |
|
173 { "else", |
|
174 "Alternate action for an if block.\n", }, |
|
175 |
|
176 { "elseif", |
|
177 "Alternate conditional test for an if block.\n", }, |
|
178 |
|
179 { "end", |
|
180 "Mark the end of any for, if, while, or function block.\n", }, |
|
181 |
|
182 { "endfor", |
|
183 "Mark the end of a for loop.\n", }, |
|
184 |
|
185 { "endfunction", |
|
186 "Mark the end of a function.\n", }, |
|
187 |
|
188 { "endif", |
|
189 "Mark the end of an if block.\n", }, |
|
190 |
|
191 { "endwhile", |
|
192 "Mark the end of a while loop.\n", }, |
|
193 |
|
194 { "for", |
|
195 "Begin a for loop.\n", }, |
|
196 |
|
197 { "function", |
|
198 "Begin a function body.\n", }, |
|
199 |
|
200 { "global", |
|
201 "Declare variables to have global scope.\n", }, |
|
202 |
|
203 { "gplot", |
|
204 "Produce 2-D plots using gnuplot-like command syntax.\n", }, |
|
205 |
|
206 { "gsplot", |
|
207 "Produce 3-D plots using gnuplot-like command syntax.\n", }, |
|
208 |
|
209 { "if", |
|
210 "Begin an if block.\n", }, |
|
211 |
|
212 { "return", |
|
213 "Return from a function.\n", }, |
|
214 |
|
215 { "while", |
|
216 "Begin a while loop.\n", }, |
|
217 |
|
218 { (char *) NULL, (char *) NULL, }, |
|
219 }; |
|
220 |
242
|
221 /* |
|
222 * Return a copy of the operator or keyword names. |
|
223 */ |
1
|
224 char ** |
|
225 names (help_list *lst, int& count) |
|
226 { |
|
227 count = 0; |
|
228 help_list *ptr = lst; |
|
229 while (ptr->name != (char *) NULL) |
|
230 { |
|
231 count++; |
|
232 ptr++; |
|
233 } |
|
234 |
|
235 if (count == 0) |
|
236 return (char **) NULL; |
|
237 |
|
238 char **name_list = new char * [count+1]; |
|
239 |
|
240 ptr = lst; |
|
241 int i = 0; |
|
242 while (ptr->name != (char *) NULL) |
|
243 { |
242
|
244 name_list[i++] = strsave (ptr->name); |
1
|
245 ptr++; |
|
246 } |
|
247 |
244
|
248 name_list[i] = (char *) NULL; |
1
|
249 return name_list; |
|
250 } |
|
251 |
|
252 help_list * |
|
253 operator_help (void) |
|
254 { |
|
255 return operators; |
|
256 } |
|
257 |
|
258 help_list * |
|
259 keyword_help (void) |
|
260 { |
|
261 return keywords; |
|
262 } |
|
263 |
|
264 /* |
|
265 ;;; Local Variables: *** |
|
266 ;;; mode: C++ *** |
|
267 ;;; page-delimiter: "^/\\*" *** |
|
268 ;;; End: *** |
|
269 */ |