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