1994
|
1 /* |
1
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with GNU CC; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
|
23 %s TEXT_FCN |
|
24 %s MATRIX |
|
25 |
|
26 %{ |
240
|
27 #ifdef HAVE_CONFIG_H |
1220
|
28 #include <config.h> |
240
|
29 #endif |
|
30 |
1341
|
31 #include <cctype> |
|
32 #include <cstring> |
|
33 |
3503
|
34 #include <strstream> |
1823
|
35 #include <string> |
|
36 |
1
|
37 #include "SLStack.h" |
|
38 |
2926
|
39 #include "cmd-edit.h" |
|
40 |
1497
|
41 // These would be alphabetical, but y.tab.h must be included before |
|
42 // oct-gperf.h and y.tab.h must be included after token.h and the tree |
|
43 // class declarations. We can't include y.tab.h in oct-gperf.h |
|
44 // because it may not be protected to allow it to be included multiple |
|
45 // times. |
|
46 |
3665
|
47 #include "comment-list.h" |
2181
|
48 #include "defun.h" |
1355
|
49 #include "error.h" |
1351
|
50 #include "input.h" |
1355
|
51 #include "lex.h" |
2891
|
52 #include "ov.h" |
1355
|
53 #include "parse.h" |
2987
|
54 #include "pt-all.h" |
2891
|
55 #include "symtab.h" |
|
56 #include "token.h" |
|
57 #include "toplev.h" |
1355
|
58 #include "utils.h" |
|
59 #include "variables.h" |
2492
|
60 #include <y.tab.h> |
|
61 #include <oct-gperf.h> |
1
|
62 |
2716
|
63 #if ! (defined (FLEX_SCANNER) \ |
|
64 && defined (YY_FLEX_MAJOR_VERSION) && YY_FLEX_MAJOR_VERSION >= 2 \ |
|
65 && defined (YY_FLEX_MINOR_VERSION) && YY_FLEX_MINOR_VERSION >= 5) |
|
66 #error lex.l requires flex version 2.5.4 or later |
|
67 #endif |
|
68 |
3883
|
69 // TRUE means that we have encountered EOF on the input stream. |
|
70 bool parser_end_of_input = false; |
|
71 |
1826
|
72 // Flags that need to be shared between the lexer and parser. |
|
73 lexical_feedback lexer_flags; |
|
74 |
1351
|
75 // Stack to hold tokens so that we can delete them when the parser is |
|
76 // reset and avoid growing forever just because we are stashing some |
|
77 // information. This has to appear before lex.h is included, because |
|
78 // one of the macros defined there uses token_stack. |
2614
|
79 // |
|
80 // XXX FIXME XXX -- this should really be static, but that causes |
|
81 // problems on some systems. |
|
82 SLStack <token*> token_stack; |
1351
|
83 |
1826
|
84 // Did eat_whitespace() eat a space or tab, or a newline, or both? |
1
|
85 |
1826
|
86 typedef int yum_yum; |
1
|
87 |
1826
|
88 const yum_yum ATE_NOTHING = 0; |
|
89 const yum_yum ATE_SPACE_OR_TAB = 1; |
|
90 const yum_yum ATE_NEWLINE = 2; |
1088
|
91 |
3351
|
92 // Is the closest nesting level a square bracket, squiggly brace or a paren? |
1826
|
93 |
3351
|
94 class bracket_brace_paren_nesting_level : public SLStack <int> |
1826
|
95 { |
|
96 public: |
|
97 |
3351
|
98 bracket_brace_paren_nesting_level (void) : SLStack<int> () { } |
1826
|
99 |
3351
|
100 ~bracket_brace_paren_nesting_level (void) { } |
|
101 |
|
102 void bracket (void) { push (BRACKET); } |
|
103 bool is_bracket (void) { return ! empty () && top () == BRACKET; } |
1826
|
104 |
|
105 void brace (void) { push (BRACE); } |
|
106 bool is_brace (void) { return ! empty () && top () == BRACE; } |
|
107 |
|
108 void paren (void) { push (PAREN); } |
|
109 bool is_paren (void) { return ! empty () && top () == PAREN; } |
985
|
110 |
1826
|
111 bool none (void) { return empty (); } |
|
112 |
|
113 void remove (void) { if (! empty ()) SLStack<int>::pop (); } |
|
114 |
|
115 private: |
|
116 |
3351
|
117 enum { BRACKET = 1, BRACE = 2, PAREN = 3 }; |
1826
|
118 |
3351
|
119 bracket_brace_paren_nesting_level (const bracket_brace_paren_nesting_level&); |
1826
|
120 |
3351
|
121 bracket_brace_paren_nesting_level& |
|
122 operator = (const bracket_brace_paren_nesting_level&); |
1826
|
123 }; |
|
124 |
3351
|
125 static bracket_brace_paren_nesting_level nesting_level; |
1
|
126 |
2167
|
127 // Should whitespace in a literal matrix list be automatically |
|
128 // converted to commas and semicolons? |
|
129 // |
|
130 // user specifies value of var |
|
131 // -------------- ------------ |
|
132 // "ignore" 2 |
|
133 // "traditional" 1 |
|
134 // anything else 0 |
|
135 // |
|
136 // Octave will never insert a comma in a literal matrix list if the |
|
137 // user specifies "ignore". For example, the statement [1 2] will |
|
138 // result in an error instead of being treated the same as [1, 2], and |
|
139 // the statement |
|
140 // |
|
141 // [ 1, 2, |
|
142 // 3, 4 ] |
|
143 // |
|
144 // will result in the vector [1 2 3 4] instead of a matrix. |
|
145 // |
|
146 // Traditional behavior makes Octave convert spaces to a comma between |
|
147 // identifiers and `('. For example, the statement |
|
148 // |
|
149 // [eye (2)] |
|
150 // |
|
151 // will be parsed as |
|
152 // |
|
153 // [eye, (2)] |
|
154 // |
|
155 // and will result in an error since the `eye' function will be |
|
156 // called with no arguments. To get around this, you would have to |
|
157 // omit the space between `eye' and the `('. |
|
158 // |
|
159 // The default value is 0, which results in behavior that is the same |
|
160 // as traditional, except that Octave does not convert spaces to a |
|
161 // comma between identifiers and `('. For example, the statement |
|
162 // |
|
163 // [eye (2)] |
|
164 // |
|
165 // will result in a call to `eye' with the argument `2'. |
|
166 |
|
167 static int Vwhitespace_in_literal_matrix; |
|
168 |
3388
|
169 static bool Vwarn_separator_insert = false; |
|
170 |
3400
|
171 static bool Vwarn_single_quote_string = false; |
|
172 |
146
|
173 // Forward declarations for functions defined at the bottom of this |
|
174 // file. |
|
175 |
1
|
176 static void fixup_column_count (char *s); |
146
|
177 static void do_comma_insert_check (void); |
3523
|
178 static int is_plot_keyword (const std::string& s); |
|
179 static int is_keyword (const std::string& s); |
|
180 static std::string plot_style_token (const std::string& s); |
|
181 static symbol_record *lookup_identifier (const std::string& s); |
1
|
182 static void grab_help_text (void); |
2857
|
183 static bool match_any (char c, const char *s); |
3263
|
184 static bool next_token_is_sep_op (void); |
3246
|
185 static bool next_token_is_bin_op (bool spc_prev); |
|
186 static bool next_token_is_postfix_unary_op (bool spc_prev); |
3523
|
187 static std::string strip_trailing_whitespace (char *s); |
3246
|
188 static void handle_number (void); |
975
|
189 static int handle_string (char delim, int text_style = 0); |
3351
|
190 static int handle_close_bracket (int spc_gobbled); |
3974
|
191 static int handle_identifier (void); |
3096
|
192 static bool have_continuation (bool trailing_comments_ok = true); |
|
193 static bool have_ellipsis_continuation (bool trailing_comments_ok = true); |
3665
|
194 static void scan_for_comments (const char *); |
1826
|
195 static yum_yum eat_whitespace (void); |
|
196 static yum_yum eat_continuation (void); |
3388
|
197 static void maybe_warn_separator_insert (char sep); |
3400
|
198 static void gripe_single_quote_string (void); |
1
|
199 |
|
200 %} |
|
201 |
|
202 D [0-9] |
|
203 S [ \t] |
2042
|
204 NL ((\n)|(\r\n)) |
|
205 SNL ({S}|{NL}) |
1
|
206 EL (\.\.\.) |
967
|
207 BS (\\) |
|
208 CONT ({EL}|{BS}) |
1
|
209 Im [iIjJ] |
967
|
210 CCHAR [#%] |
|
211 COMMENT ({CCHAR}.*{NL}) |
|
212 SNLCMT ({SNL}|{COMMENT}) |
|
213 NOTEQ ((~=)|(!=)|(<>)) |
|
214 POW ((\*\*)|(\^)) |
|
215 EPOW (\.{POW}) |
|
216 NOT ((\~)|(\!)) |
1
|
217 IDENT ([_a-zA-Z][_a-zA-Z0-9]*) |
|
218 EXPON ([DdEe][+-]?{D}+) |
3220
|
219 NUMBER (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+)) |
1
|
220 %% |
|
221 |
968
|
222 %{ |
|
223 // Help and other text-style functions are a pain in the ass. This |
|
224 // stuff needs to be simplified. May require some changes in the |
|
225 // parser too. |
|
226 %} |
|
227 |
967
|
228 <TEXT_FCN>{NL} { |
|
229 BEGIN 0; |
|
230 current_input_column = 1; |
2857
|
231 lexer_flags.quote_is_transpose = false; |
|
232 lexer_flags.cant_be_identifier = false; |
|
233 lexer_flags.convert_spaces_to_comma = true; |
967
|
234 return '\n'; |
|
235 } |
1
|
236 |
967
|
237 <TEXT_FCN>[\;\,] { |
1826
|
238 if (lexer_flags.doing_set && strcmp (yytext, ",") == 0) |
967
|
239 { |
1060
|
240 TOK_PUSH_AND_RETURN (yytext, TEXT); |
967
|
241 } |
|
242 else |
|
243 { |
|
244 BEGIN 0; |
|
245 if (strcmp (yytext, ",") == 0) |
|
246 TOK_RETURN (','); |
|
247 else |
|
248 TOK_RETURN (';'); |
|
249 } |
|
250 } |
1
|
251 |
975
|
252 <TEXT_FCN>[\"\'] { |
|
253 current_input_column++; |
3246
|
254 return handle_string (yytext[0], true); |
975
|
255 } |
|
256 |
3079
|
257 <TEXT_FCN>[^ \t\n\;\,\"\'][^ \t\n\;\,]*{S}* { |
3523
|
258 std::string tok = strip_trailing_whitespace (yytext); |
1060
|
259 TOK_PUSH_AND_RETURN (tok, TEXT); |
967
|
260 } |
1
|
261 |
968
|
262 %{ |
1
|
263 // For this and the next two rules, we're looking at ']', and we |
971
|
264 // need to know if the next token is `=' or `=='. |
1
|
265 // |
|
266 // It would have been so much easier if the delimiters were simply |
|
267 // different for the expression on the left hand side of the equals |
|
268 // operator. |
971
|
269 // |
|
270 // It's also a pain in the ass to decide whether to insert a comma |
|
271 // after seeing a ']' character... |
968
|
272 %} |
|
273 |
2119
|
274 <MATRIX>{SNLCMT}*\]{S}* { |
3665
|
275 scan_for_comments (yytext); |
1001
|
276 fixup_column_count (yytext); |
|
277 int c = yytext[yyleng-1]; |
|
278 int cont_is_spc = eat_continuation (); |
|
279 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); |
3351
|
280 return handle_close_bracket (spc_gobbled); |
967
|
281 } |
1
|
282 |
968
|
283 %{ |
1088
|
284 // Commas are element separators in matrix constants. If we don't |
|
285 // check for continuations here we can end up inserting too many |
|
286 // commas. |
968
|
287 %} |
|
288 |
967
|
289 <MATRIX>{S}*\,{S}* { |
1088
|
290 current_input_column += yyleng; |
3388
|
291 |
1088
|
292 int tmp = eat_continuation (); |
3388
|
293 |
2857
|
294 lexer_flags.quote_is_transpose = false; |
|
295 lexer_flags.cant_be_identifier = false; |
|
296 lexer_flags.convert_spaces_to_comma = true; |
3388
|
297 |
|
298 if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) |
|
299 { |
|
300 maybe_warn_separator_insert (';'); |
|
301 |
|
302 if (Vwhitespace_in_literal_matrix != 2) |
|
303 unput (';'); |
|
304 } |
|
305 |
1088
|
306 return (','); |
967
|
307 } |
1
|
308 |
968
|
309 %{ |
|
310 // In some cases, spaces in matrix constants can turn into commas. |
|
311 // If commas are required, spaces are not important in matrix |
1088
|
312 // constants so we just eat them. If we don't check for continuations |
|
313 // here we can end up inserting too many commas. |
968
|
314 %} |
430
|
315 |
968
|
316 <MATRIX>{S}+ { |
1088
|
317 current_input_column += yyleng; |
3388
|
318 |
|
319 int tmp = eat_continuation (); |
|
320 int bin_op = next_token_is_bin_op (true); |
|
321 int postfix_un_op = next_token_is_postfix_unary_op (true); |
|
322 |
|
323 if (! (postfix_un_op || bin_op) |
|
324 && nesting_level.is_bracket () |
|
325 && lexer_flags.convert_spaces_to_comma) |
967
|
326 { |
3388
|
327 if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) |
|
328 { |
|
329 maybe_warn_separator_insert (';'); |
967
|
330 |
3388
|
331 if (Vwhitespace_in_literal_matrix != 2) |
|
332 unput (';'); |
|
333 } |
|
334 |
|
335 if (Vwhitespace_in_literal_matrix != 2) |
1088
|
336 { |
2857
|
337 lexer_flags.quote_is_transpose = false; |
|
338 lexer_flags.cant_be_identifier = false; |
|
339 lexer_flags.convert_spaces_to_comma = true; |
3388
|
340 |
|
341 maybe_warn_separator_insert (','); |
|
342 |
1088
|
343 return (','); |
|
344 } |
967
|
345 } |
|
346 } |
430
|
347 |
968
|
348 %{ |
1088
|
349 // Semicolons are handled as row seprators in matrix constants. If we |
|
350 // don't eat whitespace here we can end up inserting too many |
|
351 // semicolons. |
968
|
352 %} |
|
353 |
985
|
354 <MATRIX>{SNLCMT}*;{SNLCMT}* { |
3665
|
355 scan_for_comments (yytext); |
967
|
356 fixup_column_count (yytext); |
1001
|
357 eat_whitespace (); |
2857
|
358 lexer_flags.quote_is_transpose = false; |
|
359 lexer_flags.cant_be_identifier = false; |
|
360 lexer_flags.convert_spaces_to_comma = true; |
967
|
361 return ';'; |
|
362 } |
|
363 |
968
|
364 %{ |
1088
|
365 // In some cases, new lines can also become row separators. If we |
|
366 // don't eat whitespace here we can end up inserting too many |
|
367 // semicolons. |
985
|
368 %} |
|
369 |
3180
|
370 <MATRIX>{S}*{COMMENT}{SNLCMT}* | |
|
371 <MATRIX>{S}*{NL}{SNLCMT}* { |
3665
|
372 scan_for_comments (yytext); |
1082
|
373 fixup_column_count (yytext); |
1088
|
374 eat_whitespace (); |
3388
|
375 |
2167
|
376 if (Vwhitespace_in_literal_matrix != 2) |
985
|
377 { |
2857
|
378 lexer_flags.quote_is_transpose = false; |
|
379 lexer_flags.cant_be_identifier = false; |
|
380 lexer_flags.convert_spaces_to_comma = true; |
985
|
381 |
1826
|
382 if (nesting_level.none ()) |
985
|
383 return LEXICAL_ERROR; |
3388
|
384 } |
985
|
385 |
3388
|
386 if (nesting_level.is_bracket ()) |
|
387 { |
|
388 maybe_warn_separator_insert (';'); |
|
389 |
|
390 if (Vwhitespace_in_literal_matrix != 2) |
985
|
391 return ';'; |
|
392 } |
|
393 } |
|
394 |
|
395 %{ |
3351
|
396 // Open and close bracket are handled differently if we are in the range |
968
|
397 // part of a plot command. |
975
|
398 // |
968
|
399 %} |
1
|
400 |
967
|
401 \[{S}* { |
3351
|
402 nesting_level.bracket (); |
975
|
403 |
1082
|
404 current_input_column += yyleng; |
2857
|
405 lexer_flags.quote_is_transpose = false; |
|
406 lexer_flags.cant_be_identifier = false; |
|
407 lexer_flags.convert_spaces_to_comma = true; |
975
|
408 |
|
409 promptflag--; |
|
410 eat_whitespace (); |
|
411 |
1826
|
412 if (lexer_flags.plotting && ! lexer_flags.past_plot_range) |
967
|
413 { |
2857
|
414 lexer_flags.in_plot_range = true; |
1082
|
415 return OPEN_BRACE; |
967
|
416 } |
|
417 else |
|
418 { |
3351
|
419 lexer_flags.bracketflag++; |
975
|
420 BEGIN MATRIX; |
1082
|
421 return '['; |
967
|
422 } |
|
423 } |
1
|
424 |
968
|
425 \] { |
1826
|
426 nesting_level.remove (); |
968
|
427 |
1826
|
428 if (lexer_flags.plotting && ! lexer_flags.past_plot_range) |
968
|
429 { |
2857
|
430 lexer_flags.in_plot_range = false; |
968
|
431 TOK_RETURN (CLOSE_BRACE); |
|
432 } |
|
433 else |
|
434 TOK_RETURN (']'); |
|
435 } |
|
436 |
|
437 %{ |
|
438 // Imaginary numbers. |
|
439 %} |
|
440 |
|
441 {NUMBER}{Im} { |
3246
|
442 handle_number (); |
968
|
443 return IMAG_NUM; |
|
444 } |
|
445 |
|
446 %{ |
|
447 // Real numbers. Don't grab the `.' part of a dot operator as part of |
|
448 // the constant. |
|
449 %} |
|
450 |
|
451 {D}+/\.[\*/\\^'] | |
|
452 {NUMBER} { |
3246
|
453 handle_number (); |
968
|
454 return NUM; |
|
455 } |
|
456 |
|
457 %{ |
|
458 // Eat whitespace. Whitespace inside matrix constants is handled by |
|
459 // the <MATRIX> start state code above. |
|
460 %} |
|
461 |
967
|
462 {S}* { |
|
463 current_input_column += yyleng; |
|
464 } |
|
465 |
968
|
466 %{ |
|
467 // Continuation lines. Allow comments after continuations. |
|
468 %} |
|
469 |
967
|
470 {CONT}{S}*{NL} | |
|
471 {CONT}{S}*{COMMENT} { |
3665
|
472 scan_for_comments (yytext); |
967
|
473 promptflag--; |
|
474 current_input_column = 1; |
|
475 } |
1
|
476 |
968
|
477 %{ |
|
478 // An ellipsis not at the end of a line is not a continuation, but |
|
479 // does have another meaning. |
|
480 %} |
|
481 |
967
|
482 {EL} { |
3973
|
483 if (lexer_flags.looking_at_parameter_list) |
3974
|
484 { |
|
485 warning ("`...' is deprecated; use varargin instead"); |
|
486 return VARARGIN; |
|
487 } |
3973
|
488 else if (lexer_flags.looking_at_return_list) |
3974
|
489 { |
|
490 warning ("`...' is deprecated; use varargout instead"); |
|
491 return VARARGOUT; |
|
492 } |
3973
|
493 else |
|
494 return LEXICAL_ERROR; |
967
|
495 } |
1
|
496 |
968
|
497 %{ |
|
498 // End of file. |
|
499 %} |
|
500 |
967
|
501 <<EOF>> { |
|
502 TOK_RETURN (END_OF_INPUT); |
|
503 } |
1
|
504 |
968
|
505 %{ |
970
|
506 // Identifiers. Truncate the token at the first space or tab but |
|
507 // don't write directly on yytext. |
968
|
508 %} |
|
509 |
967
|
510 {IDENT}{S}* { |
3974
|
511 return handle_identifier (); |
967
|
512 } |
1
|
513 |
968
|
514 %{ |
|
515 // A new line character. New line characters inside matrix constants |
985
|
516 // are handled by the <MATRIX> start state code above. If closest |
|
517 // nesting is inside parentheses, don't return a row separator. |
968
|
518 %} |
|
519 |
967
|
520 {NL} { |
|
521 current_input_column = 1; |
2857
|
522 lexer_flags.quote_is_transpose = false; |
|
523 lexer_flags.cant_be_identifier = false; |
|
524 lexer_flags.convert_spaces_to_comma = true; |
985
|
525 |
1826
|
526 if (nesting_level.none ()) |
985
|
527 return '\n'; |
|
528 |
3351
|
529 if (nesting_level.is_bracket ()) |
985
|
530 return LEXICAL_ERROR; |
967
|
531 } |
1
|
532 |
968
|
533 %{ |
|
534 // Single quote can either be the beginning of a string or a transpose |
|
535 // operator. |
|
536 %} |
|
537 |
967
|
538 "'" { |
|
539 current_input_column++; |
2857
|
540 lexer_flags.convert_spaces_to_comma = true; |
1
|
541 |
1826
|
542 if (lexer_flags.quote_is_transpose) |
967
|
543 { |
|
544 do_comma_insert_check (); |
|
545 return QUOTE; |
|
546 } |
|
547 else |
973
|
548 return handle_string ('\''); |
967
|
549 } |
1
|
550 |
968
|
551 %{ |
971
|
552 // Double quotes always begin strings. |
|
553 %} |
|
554 |
973
|
555 \" { |
|
556 current_input_column++; |
|
557 return handle_string ('"'); |
|
558 } |
971
|
559 |
|
560 %{ |
|
561 // The colon operator is handled differently if we are in the range |
|
562 // part of a plot command. |
968
|
563 %} |
|
564 |
967
|
565 ":" { |
1826
|
566 if (lexer_flags.plotting |
|
567 && (lexer_flags.in_plot_range || lexer_flags.in_plot_using)) |
2857
|
568 BIN_OP_RETURN (COLON, true); |
967
|
569 else |
2857
|
570 BIN_OP_RETURN (':', false); |
967
|
571 } |
1
|
572 |
968
|
573 %{ |
985
|
574 // Gobble comments. If closest nesting is inside parentheses, don't |
|
575 // return a new line. |
|
576 %} |
968
|
577 |
967
|
578 {CCHAR} { |
1826
|
579 if (help_buf.empty () |
|
580 && lexer_flags.beginning_of_function |
|
581 && nesting_level.none ()) |
967
|
582 { |
3665
|
583 lexer_flags.beginning_of_function = false; |
|
584 |
967
|
585 grab_help_text (); |
3665
|
586 |
|
587 octave_comment_buffer::append (help_buf); |
967
|
588 } |
|
589 else |
|
590 { |
3665
|
591 std::string buf; |
|
592 |
|
593 bool begin_comment = true; |
|
594 |
967
|
595 int c; |
|
596 while ((c = yyinput ()) != EOF && c != '\n') |
3665
|
597 { |
|
598 if (begin_comment && (c == '#' || c == '%')) |
|
599 ; /* Skip leading comment characters. */ |
|
600 else |
3802
|
601 buf += static_cast<char> (c); |
3665
|
602 } |
|
603 |
|
604 octave_comment_buffer::append (buf); |
967
|
605 } |
440
|
606 |
967
|
607 current_input_column = 1; |
2857
|
608 lexer_flags.quote_is_transpose = false; |
|
609 lexer_flags.cant_be_identifier = false; |
|
610 lexer_flags.convert_spaces_to_comma = true; |
985
|
611 |
1826
|
612 if (nesting_level.none ()) |
985
|
613 return '\n'; |
3351
|
614 else if (nesting_level.is_bracket ()) |
1566
|
615 return ';'; |
967
|
616 } |
440
|
617 |
968
|
618 %{ |
|
619 // Other operators. |
|
620 %} |
|
621 |
2857
|
622 ".+" { BIN_OP_RETURN (EPLUS, false); } |
|
623 ".-" { BIN_OP_RETURN (EMINUS, false); } |
|
624 ".*" { BIN_OP_RETURN (EMUL, false); } |
|
625 "./" { BIN_OP_RETURN (EDIV, false); } |
|
626 ".\\" { BIN_OP_RETURN (ELEFTDIV, false); } |
|
627 {EPOW} { BIN_OP_RETURN (EPOW, false); } |
|
628 ".'" { do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, true); } |
|
629 "++" { do_comma_insert_check (); BIN_OP_RETURN (PLUS_PLUS, true); } |
|
630 "--" { do_comma_insert_check (); BIN_OP_RETURN (MINUS_MINUS, true); } |
|
631 "<=" { BIN_OP_RETURN (EXPR_LE, false); } |
|
632 "==" { BIN_OP_RETURN (EXPR_EQ, false); } |
|
633 {NOTEQ} { BIN_OP_RETURN (EXPR_NE, false); } |
|
634 ">=" { BIN_OP_RETURN (EXPR_GE, false); } |
2877
|
635 "&" { BIN_OP_RETURN (EXPR_AND, false); } |
2857
|
636 "|" { BIN_OP_RETURN (EXPR_OR, false); } |
|
637 "<" { BIN_OP_RETURN (EXPR_LT, false); } |
|
638 ">" { BIN_OP_RETURN (EXPR_GT, false); } |
|
639 "*" { BIN_OP_RETURN ('*', false); } |
|
640 "/" { BIN_OP_RETURN ('/', false); } |
|
641 "\\" { BIN_OP_RETURN (LEFTDIV, false); } |
|
642 ";" { BIN_OP_RETURN (';', true); } |
|
643 "," { BIN_OP_RETURN (',', true); } |
|
644 {POW} { BIN_OP_RETURN (POW, false); } |
|
645 "=" { BIN_OP_RETURN ('=', true); } |
2877
|
646 "&&" { BIN_OP_RETURN (EXPR_AND_AND, false); } |
2857
|
647 "||" { BIN_OP_RETURN (EXPR_OR_OR, false); } |
2900
|
648 "<<" { BIN_OP_RETURN (LSHIFT, false); } |
|
649 ">>" { BIN_OP_RETURN (RSHIFT, false); } |
967
|
650 |
|
651 {NOT} { |
1826
|
652 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
653 lexer_flags.past_plot_range = true; |
|
654 BIN_OP_RETURN (EXPR_NOT, false); |
967
|
655 } |
1
|
656 |
1276
|
657 "+" { |
1826
|
658 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
659 lexer_flags.past_plot_range = true; |
|
660 BIN_OP_RETURN ('+', false); |
967
|
661 } |
|
662 |
1276
|
663 "-" { |
1826
|
664 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
665 lexer_flags.past_plot_range = true; |
|
666 BIN_OP_RETURN ('-', false); |
967
|
667 } |
|
668 |
|
669 "(" { |
1826
|
670 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
671 lexer_flags.past_plot_range = true; |
1826
|
672 nesting_level.paren (); |
985
|
673 promptflag--; |
967
|
674 TOK_RETURN ('('); |
|
675 } |
|
676 |
|
677 ")" { |
1826
|
678 nesting_level.remove (); |
1001
|
679 |
967
|
680 current_input_column++; |
2857
|
681 lexer_flags.cant_be_identifier = true; |
|
682 lexer_flags.quote_is_transpose = true; |
3351
|
683 lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket (); |
1001
|
684 do_comma_insert_check (); |
967
|
685 return ')'; |
|
686 } |
|
687 |
2066
|
688 "." { |
|
689 TOK_RETURN ('.'); |
|
690 } |
|
691 |
3988
|
692 "@" { |
|
693 current_input_column++; |
|
694 lexer_flags.cant_be_identifier = false; |
|
695 lexer_flags.quote_is_transpose = false; |
|
696 lexer_flags.convert_spaces_to_comma = false; |
|
697 return '@'; |
|
698 } |
|
699 |
2877
|
700 "+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
701 "-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
702 "*=" { BIN_OP_RETURN (MUL_EQ, false); } |
|
703 "/=" { BIN_OP_RETURN (DIV_EQ, false); } |
3204
|
704 "\\=" { BIN_OP_RETURN (LEFTDIV_EQ, false); } |
2877
|
705 ".+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
706 ".-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
707 ".*=" { BIN_OP_RETURN (EMUL_EQ, false); } |
|
708 "./=" { BIN_OP_RETURN (EDIV_EQ, false); } |
3204
|
709 ".\\=" { BIN_OP_RETURN (ELEFTDIV_EQ, false); } |
4018
|
710 {POW}= { BIN_OP_RETURN (POW_EQ, false); } |
|
711 {EPOW}= { BIN_OP_RETURN (EPOW_EQ, false); } |
2877
|
712 "&=" { BIN_OP_RETURN (AND_EQ, false); } |
|
713 "|=" { BIN_OP_RETURN (OR_EQ, false); } |
2900
|
714 "<<=" { BIN_OP_RETURN (LSHIFT_EQ, false); } |
|
715 ">>=" { BIN_OP_RETURN (RSHIFT_EQ, false); } |
2877
|
716 |
3351
|
717 "{" { |
|
718 nesting_level.brace (); |
|
719 promptflag--; |
|
720 TOK_RETURN ('{'); |
|
721 } |
|
722 |
|
723 "}" { |
|
724 nesting_level.remove (); |
|
725 |
|
726 current_input_column++; |
|
727 lexer_flags.cant_be_identifier = true; |
|
728 lexer_flags.quote_is_transpose = true; |
|
729 lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket (); |
|
730 do_comma_insert_check (); // Is this really necessary? |
|
731 |
|
732 return '}'; |
|
733 } |
|
734 |
968
|
735 %{ |
2066
|
736 // Unrecognized input is a lexical error. |
968
|
737 %} |
1
|
738 |
2042
|
739 . { |
2066
|
740 current_input_column++; |
|
741 |
3867
|
742 // EOF can't happen here (we catch it above). |
|
743 |
|
744 error ("invalid character `%s' (ASCII %d) near line %d, column %d", |
|
745 undo_string_escape (yytext[0]), static_cast<int> (yytext[0]), |
|
746 input_line_number, current_input_column); |
2066
|
747 |
|
748 return LEXICAL_ERROR; |
|
749 } |
1
|
750 |
|
751 %% |
|
752 |
767
|
753 // GAG. |
|
754 // |
|
755 // If we're reading a matrix and the next character is '[', make sure |
|
756 // that we insert a comma ahead of it. |
|
757 |
146
|
758 void |
1
|
759 do_comma_insert_check (void) |
|
760 { |
1001
|
761 int spc_gobbled = eat_continuation (); |
2970
|
762 |
1
|
763 int c = yyinput (); |
2970
|
764 |
3246
|
765 unput (c); |
2970
|
766 |
1001
|
767 if (spc_gobbled) |
3246
|
768 unput (' '); |
2970
|
769 |
3351
|
770 lexer_flags.do_comma_insert = (lexer_flags.bracketflag && c == '['); |
1
|
771 } |
|
772 |
767
|
773 // Fix things up for errors or interrupts. The parser is never called |
|
774 // recursively, so it is always safe to reinitialize its state before |
|
775 // doing any parsing. |
|
776 |
1
|
777 void |
|
778 reset_parser (void) |
|
779 { |
1826
|
780 // Start off on the right foot. |
1
|
781 BEGIN 0; |
166
|
782 error_state = 0; |
3489
|
783 warning_state = 0; |
3883
|
784 parser_end_of_input = false; |
287
|
785 |
1826
|
786 // We do want a prompt by default. |
1
|
787 promptflag = 1; |
287
|
788 |
3351
|
789 // Error may have occurred inside some brackets, braces, or parentheses. |
985
|
790 nesting_level.clear (); |
287
|
791 |
1826
|
792 // Clear out the stack of token info used to track line and column |
|
793 // numbers. |
143
|
794 while (! token_stack.empty ()) |
|
795 delete token_stack.pop (); |
287
|
796 |
1826
|
797 // Can be reset by defining a function. |
985
|
798 if (! (reading_script_file || reading_fcn_file)) |
|
799 { |
|
800 current_input_column = 1; |
2926
|
801 input_line_number = command_editor::current_command_number () - 1; |
985
|
802 } |
287
|
803 |
1826
|
804 // Only ask for input from stdin if we are expecting interactive |
|
805 // input. |
3174
|
806 if ((interactive || forced_interactive) |
3880
|
807 && ! (reading_fcn_file |
|
808 || reading_script_file |
|
809 || get_input_from_eval_string |
3174
|
810 || input_from_startup_file)) |
287
|
811 yyrestart (stdin); |
991
|
812 |
1826
|
813 // Clear the buffer for help text. |
|
814 help_buf.resize (0); |
1755
|
815 |
1826
|
816 // Reset other flags. |
|
817 lexer_flags.init (); |
1
|
818 } |
|
819 |
767
|
820 // If we read some newlines, we need figure out what column we're |
|
821 // really looking at. |
|
822 |
1
|
823 static void |
|
824 fixup_column_count (char *s) |
|
825 { |
|
826 char c; |
|
827 while ((c = *s++) != '\0') |
|
828 { |
|
829 if (c == '\n') |
143
|
830 current_input_column = 1; |
1
|
831 else |
|
832 current_input_column++; |
|
833 } |
|
834 } |
|
835 |
767
|
836 // Include these so that we don't have to link to libfl.a. |
246
|
837 |
1
|
838 #ifdef yywrap |
|
839 #undef yywrap |
|
840 #endif |
3332
|
841 int |
1
|
842 yywrap (void) |
|
843 { |
287
|
844 return 1; |
1
|
845 } |
|
846 |
767
|
847 // Tell us all what the current buffer is. |
|
848 |
1
|
849 YY_BUFFER_STATE |
|
850 current_buffer (void) |
|
851 { |
|
852 return YY_CURRENT_BUFFER; |
|
853 } |
|
854 |
767
|
855 // Create a new buffer. |
|
856 |
1
|
857 YY_BUFFER_STATE |
|
858 create_buffer (FILE *f) |
|
859 { |
|
860 return yy_create_buffer (f, YY_BUF_SIZE); |
|
861 } |
|
862 |
767
|
863 // Start reading a new buffer. |
|
864 |
1
|
865 void |
|
866 switch_to_buffer (YY_BUFFER_STATE buf) |
|
867 { |
|
868 yy_switch_to_buffer (buf); |
|
869 } |
|
870 |
767
|
871 // Delete a buffer. |
|
872 |
1
|
873 void |
|
874 delete_buffer (YY_BUFFER_STATE buf) |
|
875 { |
|
876 yy_delete_buffer (buf); |
|
877 } |
|
878 |
767
|
879 // Restore a buffer (for unwind-prot). |
|
880 |
1
|
881 void |
|
882 restore_input_buffer (void *buf) |
|
883 { |
2861
|
884 switch_to_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
885 } |
|
886 |
767
|
887 // Delete a buffer (for unwind-prot). |
|
888 |
1
|
889 void |
|
890 delete_input_buffer (void *buf) |
|
891 { |
2861
|
892 delete_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
893 } |
|
894 |
767
|
895 // Check to see if a character string matches any of the possible line |
|
896 // styles for plots. |
|
897 |
3536
|
898 static std::string |
3523
|
899 plot_style_token (const std::string& s) |
1
|
900 { |
3523
|
901 std::string retval; |
1823
|
902 |
3575
|
903 // XXX FIXME XXX -- specify minimum match length for these. |
2804
|
904 static const char *plot_styles[] = |
146
|
905 { |
925
|
906 "boxes", |
924
|
907 "boxerrorbars", |
2542
|
908 "boxxyerrorbars", |
|
909 "candlesticks", |
146
|
910 "dots", |
|
911 "errorbars", |
2542
|
912 "financebars", |
|
913 "fsteps", |
|
914 "histeps", |
146
|
915 "impulses", |
|
916 "lines", |
|
917 "linespoints", |
|
918 "points", |
926
|
919 "steps", |
2542
|
920 "vector", |
|
921 "xerrorbars", |
|
922 "xyerrorbars", |
|
923 "yerrorbars", |
522
|
924 0, |
146
|
925 }; |
|
926 |
2804
|
927 const char * const *tmp = plot_styles; |
522
|
928 while (*tmp) |
1
|
929 { |
1823
|
930 if (almost_match (*tmp, s.c_str ())) |
|
931 { |
|
932 retval = *tmp; |
|
933 break; |
|
934 } |
1
|
935 |
|
936 tmp++; |
|
937 } |
|
938 |
1823
|
939 return retval; |
1
|
940 } |
|
941 |
3165
|
942 // Check to see if a character string matches any of the possible axes |
|
943 // tags for plots. |
|
944 |
3536
|
945 static std::string |
3523
|
946 plot_axes_token (const std::string& s) |
3165
|
947 { |
3523
|
948 std::string retval; |
3165
|
949 |
3575
|
950 // XXX FIXME XXX -- specify minimum match length for these. |
3561
|
951 static const char *plot_axes[] = |
3165
|
952 { |
|
953 "x1y1", |
|
954 "x1y2", |
|
955 "x2y1", |
|
956 "x2y2", |
|
957 0, |
|
958 }; |
|
959 |
3561
|
960 const char **tmp = plot_axes; |
3165
|
961 while (*tmp) |
|
962 { |
|
963 if (almost_match (*tmp, s.c_str ())) |
|
964 { |
|
965 retval = *tmp; |
|
966 break; |
|
967 } |
|
968 |
|
969 tmp++; |
|
970 } |
|
971 |
|
972 return retval; |
|
973 } |
|
974 |
767
|
975 // Check to see if a character string matches any one of the plot |
941
|
976 // option keywords. Don't match abbreviations for clear, since that's |
|
977 // not a gnuplot keyword (users will probably only expect to be able |
|
978 // to abbreviate actual gnuplot keywords). |
767
|
979 |
1
|
980 static int |
3523
|
981 is_plot_keyword (const std::string& s) |
1
|
982 { |
1823
|
983 const char *t = s.c_str (); |
3575
|
984 if (almost_match ("title", t, 1)) |
146
|
985 { |
|
986 return TITLE; |
|
987 } |
3575
|
988 else if (almost_match ("using", t, 1)) |
146
|
989 { |
2857
|
990 lexer_flags.in_plot_using = true; |
146
|
991 return USING; |
|
992 } |
3575
|
993 else if (almost_match ("with", t, 1)) |
146
|
994 { |
2857
|
995 lexer_flags.in_plot_style = true; |
146
|
996 return WITH; |
|
997 } |
3575
|
998 else if (almost_match ("axes", t, 2) || almost_match ("axis", t, 2)) |
3165
|
999 { |
|
1000 lexer_flags.in_plot_axes = true; |
|
1001 return AXES; |
|
1002 } |
1823
|
1003 else if (strcmp ("clear", t) == 0) |
883
|
1004 { |
|
1005 return CLEAR; |
|
1006 } |
1
|
1007 else |
146
|
1008 { |
|
1009 return 0; |
|
1010 } |
1
|
1011 } |
|
1012 |
2877
|
1013 // Handle keywords. |
767
|
1014 |
1
|
1015 static int |
3523
|
1016 is_keyword (const std::string& s) |
1
|
1017 { |
3805
|
1018 int l = input_line_number; |
|
1019 int c = current_input_column; |
|
1020 |
3165
|
1021 if (lexer_flags.plotting) |
1
|
1022 { |
3165
|
1023 if (lexer_flags.in_plot_style) |
1
|
1024 { |
3523
|
1025 std::string sty = plot_style_token (s); |
3165
|
1026 |
|
1027 if (! sty.empty ()) |
|
1028 { |
|
1029 lexer_flags.in_plot_style = false; |
3805
|
1030 yylval.tok_val = new token (sty, l, c); |
3165
|
1031 token_stack.push (yylval.tok_val); |
|
1032 return STYLE; |
|
1033 } |
1
|
1034 } |
3165
|
1035 else if (lexer_flags.in_plot_axes) |
|
1036 { |
3523
|
1037 std::string axes = plot_axes_token (s); |
3165
|
1038 |
|
1039 if (! axes.empty ()) |
|
1040 { |
|
1041 lexer_flags.in_plot_axes = false; |
3805
|
1042 yylval.tok_val = new token (axes, l, c); |
3165
|
1043 token_stack.push (yylval.tok_val); |
|
1044 return AXES_TAG; |
|
1045 } |
|
1046 } |
1
|
1047 } |
|
1048 |
1823
|
1049 int len = s.length (); |
922
|
1050 |
1823
|
1051 const octave_kw *kw = octave_kw_lookup (s.c_str (), len); |
191
|
1052 |
1497
|
1053 if (kw) |
143
|
1054 { |
1497
|
1055 yylval.tok_val = 0; |
|
1056 |
|
1057 switch (kw->kw_id) |
|
1058 { |
|
1059 case all_va_args_kw: |
|
1060 case break_kw: |
2764
|
1061 case case_kw: |
1497
|
1062 case catch_kw: |
|
1063 case continue_kw: |
|
1064 case else_kw: |
|
1065 case elseif_kw: |
|
1066 case global_kw: |
2764
|
1067 case otherwise_kw: |
1497
|
1068 case return_kw: |
2846
|
1069 case static_kw: |
3484
|
1070 case until_kw: |
1497
|
1071 case unwind_protect_cleanup_kw: |
|
1072 break; |
|
1073 |
|
1074 case end_kw: |
|
1075 yylval.tok_val = new token (token::simple_end, l, c); |
|
1076 break; |
|
1077 |
|
1078 case end_try_catch_kw: |
|
1079 yylval.tok_val = new token (token::try_catch_end, l, c); |
|
1080 break; |
|
1081 |
|
1082 case end_unwind_protect_kw: |
|
1083 yylval.tok_val = new token (token::unwind_protect_end, l, c); |
|
1084 break; |
|
1085 |
|
1086 case endfor_kw: |
|
1087 yylval.tok_val = new token (token::for_end, l, c); |
|
1088 break; |
|
1089 |
|
1090 case endfunction_kw: |
|
1091 yylval.tok_val = new token (token::function_end, l, c); |
|
1092 break; |
|
1093 |
|
1094 case endif_kw: |
|
1095 yylval.tok_val = new token (token::if_end, l, c); |
|
1096 break; |
|
1097 |
2764
|
1098 case endswitch_kw: |
|
1099 yylval.tok_val = new token (token::switch_end, l, c); |
|
1100 break; |
|
1101 |
1497
|
1102 case endwhile_kw: |
|
1103 yylval.tok_val = new token (token::while_end, l, c); |
|
1104 break; |
|
1105 |
3484
|
1106 case do_kw: |
1497
|
1107 case for_kw: |
|
1108 case while_kw: |
|
1109 promptflag--; |
1826
|
1110 lexer_flags.looping++; |
1497
|
1111 break; |
|
1112 |
|
1113 case if_kw: |
|
1114 case try_kw: |
2764
|
1115 case switch_kw: |
1497
|
1116 case unwind_protect_kw: |
|
1117 promptflag--; |
|
1118 break; |
|
1119 |
|
1120 case gplot_kw: |
2857
|
1121 lexer_flags.plotting = true; |
1497
|
1122 yylval.tok_val = new token (token::two_dee, l, c); |
|
1123 break; |
|
1124 |
|
1125 case gsplot_kw: |
2857
|
1126 lexer_flags.plotting = true; |
1497
|
1127 yylval.tok_val = new token (token::three_dee, l, c); |
|
1128 break; |
|
1129 |
|
1130 case replot_kw: |
2857
|
1131 lexer_flags.plotting = true; |
1497
|
1132 yylval.tok_val = new token (token::replot, l, c); |
|
1133 break; |
|
1134 |
|
1135 case function_kw: |
1826
|
1136 if (lexer_flags.defining_func) |
1497
|
1137 { |
|
1138 error ("function keyword invalid within a function body"); |
|
1139 |
|
1140 if ((reading_fcn_file || reading_script_file) |
1755
|
1141 && ! curr_fcn_file_name.empty ()) |
1497
|
1142 error ("defining new function near line %d of file `%s.m'", |
1755
|
1143 input_line_number, curr_fcn_file_name.c_str ()); |
1497
|
1144 else |
1755
|
1145 error ("defining new function near line %d", |
|
1146 input_line_number); |
1497
|
1147 |
|
1148 return LEXICAL_ERROR; |
|
1149 } |
|
1150 else |
|
1151 { |
2877
|
1152 // Prepare for local symbols. |
|
1153 |
1497
|
1154 tmp_local_sym_tab = new symbol_table (); |
2877
|
1155 |
|
1156 promptflag--; |
|
1157 |
2857
|
1158 lexer_flags.defining_func = true; |
2877
|
1159 lexer_flags.parsed_function_name = false; |
2857
|
1160 lexer_flags.beginning_of_function = true; |
2877
|
1161 |
1497
|
1162 if (! (reading_fcn_file || reading_script_file)) |
|
1163 input_line_number = 1; |
|
1164 } |
|
1165 break; |
|
1166 |
3174
|
1167 case magic_file_kw: |
|
1168 { |
|
1169 if ((reading_fcn_file || reading_script_file) |
|
1170 && ! curr_fcn_file_full_name.empty ()) |
|
1171 yylval.tok_val = new token (curr_fcn_file_full_name, l, c); |
|
1172 else |
|
1173 yylval.tok_val = new token ("stdin", l, c); |
|
1174 } |
|
1175 break; |
|
1176 |
|
1177 case magic_line_kw: |
|
1178 yylval.tok_val = new token (static_cast<double> (l), "", l, c); |
|
1179 break; |
|
1180 |
3974
|
1181 case varargin_kw: |
|
1182 if (! lexer_flags.looking_at_parameter_list) |
|
1183 return 0; |
|
1184 break; |
|
1185 |
|
1186 case varargout_kw: |
|
1187 if (! lexer_flags.looking_at_return_list) |
|
1188 return 0; |
|
1189 break; |
|
1190 |
1497
|
1191 default: |
|
1192 panic_impossible (); |
|
1193 } |
|
1194 |
|
1195 if (! yylval.tok_val) |
|
1196 yylval.tok_val = new token (l, c); |
|
1197 |
476
|
1198 token_stack.push (yylval.tok_val); |
1497
|
1199 |
|
1200 return kw->tok; |
143
|
1201 } |
1
|
1202 |
|
1203 return 0; |
|
1204 } |
|
1205 |
767
|
1206 // Try to find an identifier. All binding to global or builtin |
|
1207 // variables occurs when expressions are evaluated. |
|
1208 |
1
|
1209 static symbol_record * |
3523
|
1210 lookup_identifier (const std::string& name) |
1
|
1211 { |
2856
|
1212 return curr_sym_tab->lookup (name, true); |
1
|
1213 } |
|
1214 |
2702
|
1215 static bool |
3523
|
1216 is_variable (const std::string& name) |
2702
|
1217 { |
2856
|
1218 symbol_record *sr = curr_sym_tab->lookup (name); |
2702
|
1219 |
|
1220 return sr && sr->is_variable (); |
|
1221 } |
|
1222 |
|
1223 static void |
3523
|
1224 force_local_variable (const std::string& name) |
2702
|
1225 { |
2856
|
1226 symbol_record *sr = curr_sym_tab->lookup (name, true); |
2702
|
1227 |
|
1228 if (sr) |
|
1229 sr->define (octave_value ()); |
|
1230 } |
|
1231 |
1019
|
1232 // Grab the help text from an function file. Always overwrites the |
|
1233 // current contents of help_buf. |
767
|
1234 |
3427
|
1235 // XXX FIXME XXX -- gobble_leading_white_space() in parse.y |
2300
|
1236 // duplicates some of this code! |
|
1237 |
1
|
1238 static void |
|
1239 grab_help_text (void) |
|
1240 { |
1755
|
1241 help_buf.resize (0); |
1019
|
1242 |
2300
|
1243 bool begin_comment = true; |
|
1244 bool in_comment = true; |
3427
|
1245 bool discard_space = true; |
3665
|
1246 |
1019
|
1247 int c = 0; |
1
|
1248 |
1019
|
1249 while ((c = yyinput ()) != EOF) |
|
1250 { |
2300
|
1251 if (begin_comment) |
|
1252 { |
|
1253 if (c == '%' || c == '#') |
|
1254 continue; |
3427
|
1255 else if (discard_space && c == ' ') |
|
1256 { |
|
1257 discard_space = false; |
|
1258 continue; |
|
1259 } |
2300
|
1260 else |
|
1261 begin_comment = false; |
|
1262 } |
|
1263 |
1019
|
1264 if (in_comment) |
1
|
1265 { |
3802
|
1266 help_buf += static_cast<char> (c); |
1755
|
1267 |
1019
|
1268 if (c == '\n') |
3427
|
1269 { |
|
1270 in_comment = false; |
|
1271 discard_space = true; |
|
1272 } |
1019
|
1273 } |
|
1274 else |
|
1275 { |
|
1276 switch (c) |
991
|
1277 { |
1019
|
1278 case '%': |
|
1279 case '#': |
2300
|
1280 in_comment = true; |
|
1281 begin_comment = true; |
1019
|
1282 break; |
777
|
1283 |
1019
|
1284 case ' ': |
|
1285 case '\t': |
|
1286 break; |
777
|
1287 |
1019
|
1288 default: |
|
1289 goto done; |
1
|
1290 } |
|
1291 } |
1019
|
1292 } |
991
|
1293 |
1019
|
1294 done: |
991
|
1295 |
1019
|
1296 if (c) |
3246
|
1297 unput (c); |
1
|
1298 } |
|
1299 |
767
|
1300 // Return 1 if the given character matches any character in the given |
|
1301 // string. |
|
1302 |
2857
|
1303 static bool |
2804
|
1304 match_any (char c, const char *s) |
1
|
1305 { |
|
1306 char tmp; |
|
1307 while ((tmp = *s++) != '\0') |
|
1308 { |
|
1309 if (c == tmp) |
2857
|
1310 return true; |
1
|
1311 } |
2857
|
1312 return false; |
1
|
1313 } |
|
1314 |
767
|
1315 // Given information about the spacing surrounding an operator, |
|
1316 // return 1 if it looks like it should be treated as a binary |
|
1317 // operator. For example, |
|
1318 // |
3774
|
1319 // [ 1 + 2 ] or [ 1+ 2] or [ 1+2 ] ==> binary |
|
1320 // |
|
1321 // [ 1 +2 ] ==> unary |
767
|
1322 |
2857
|
1323 static bool |
3246
|
1324 looks_like_bin_op (bool spc_prev, int next_char) |
1
|
1325 { |
3246
|
1326 bool spc_next = (next_char == ' ' || next_char == '\t'); |
|
1327 |
608
|
1328 return ((spc_prev && spc_next) || ! spc_prev); |
1
|
1329 } |
|
1330 |
3263
|
1331 // Recognize separators. If the separator is a CRLF pair, it is |
|
1332 // replaced by a single LF. |
|
1333 |
|
1334 static bool |
|
1335 next_token_is_sep_op (void) |
|
1336 { |
|
1337 bool retval = false; |
|
1338 |
|
1339 int c1 = yyinput (); |
|
1340 |
|
1341 if (c1 == '\r') |
|
1342 { |
|
1343 int c2 = yyinput (); |
|
1344 |
|
1345 if (c2 == '\n') |
|
1346 { |
|
1347 c1 = '\n'; |
|
1348 |
|
1349 retval = true; |
|
1350 } |
|
1351 else |
|
1352 unput (c2); |
|
1353 } |
|
1354 else |
|
1355 retval = match_any (c1, ",;\n]"); |
|
1356 |
|
1357 unput (c1); |
|
1358 |
|
1359 return retval; |
|
1360 } |
|
1361 |
767
|
1362 // Try to determine if the next token should be treated as a postfix |
|
1363 // unary operator. This is ugly, but it seems to do the right thing. |
|
1364 |
2857
|
1365 static bool |
3246
|
1366 next_token_is_postfix_unary_op (bool spc_prev) |
1
|
1367 { |
2857
|
1368 bool un_op = false; |
1
|
1369 |
|
1370 int c0 = yyinput (); |
|
1371 |
3246
|
1372 if (c0 == '\'' && ! spc_prev) |
|
1373 { |
|
1374 un_op = true; |
|
1375 } |
|
1376 else if (c0 == '.') |
|
1377 { |
|
1378 int c1 = yyinput (); |
|
1379 un_op = (c1 == '\''); |
|
1380 unput (c1); |
|
1381 } |
1
|
1382 |
3246
|
1383 unput (c0); |
1
|
1384 |
|
1385 return un_op; |
|
1386 } |
|
1387 |
767
|
1388 // Try to determine if the next token should be treated as a binary |
3246
|
1389 // operator. |
1521
|
1390 // |
3246
|
1391 // This kluge exists because whitespace is not always ignored inside |
3774
|
1392 // the square brackets that are used to create matrix objects (though |
|
1393 // spacing only really matters in the cases that can be interpreted |
|
1394 // either as binary ops or prefix unary ops: currently just +, -). |
|
1395 // |
3779
|
1396 // Note that a line continuation directly following a + or - operator |
|
1397 // (e.g., the characters '[' 'a' ' ' '+' '\' LFD 'b' ']') will be |
|
1398 // parsed as a binary operator. |
767
|
1399 |
2857
|
1400 static bool |
3246
|
1401 next_token_is_bin_op (bool spc_prev) |
1
|
1402 { |
2857
|
1403 bool bin_op = false; |
1
|
1404 |
|
1405 int c0 = yyinput (); |
|
1406 |
|
1407 switch (c0) |
|
1408 { |
777
|
1409 case '+': |
|
1410 case '-': |
3774
|
1411 { |
|
1412 int c1 = yyinput (); |
|
1413 |
|
1414 switch (c1) |
|
1415 { |
|
1416 case '+': |
|
1417 case '-': |
|
1418 // Unary ops, spacing doesn't matter. |
|
1419 break; |
|
1420 |
|
1421 case '=': |
|
1422 // Binary ops, spacing doesn't matter. |
|
1423 bin_op = true; |
|
1424 break; |
|
1425 |
|
1426 default: |
|
1427 // Could be either, spacing matters. |
|
1428 bin_op = looks_like_bin_op (spc_prev, c1); |
|
1429 break; |
|
1430 } |
|
1431 |
|
1432 unput (c1); |
|
1433 } |
|
1434 break; |
|
1435 |
|
1436 case ':': |
3246
|
1437 case '/': |
|
1438 case '\\': |
|
1439 case '^': |
3774
|
1440 // Always a binary op (may also include /=, \=, and ^=). |
|
1441 bin_op = true; |
1276
|
1442 break; |
|
1443 |
3246
|
1444 // .+ .- ./ .\ .^ .* .** |
1554
|
1445 case '.': |
|
1446 { |
|
1447 int c1 = yyinput (); |
3246
|
1448 |
3774
|
1449 if (match_any (c1, "+-/\\^*")) |
|
1450 // Always a binary op (may also include .+=, .-=, ./=, ...). |
|
1451 bin_op = true; |
3698
|
1452 else if (! isdigit (c1) && c1 != ' ' && c1 != '\t' && c1 != '.') |
3774
|
1453 // A structure element reference is a binary op. |
|
1454 bin_op = true; |
3246
|
1455 |
|
1456 unput (c1); |
1554
|
1457 } |
|
1458 break; |
|
1459 |
3246
|
1460 // = == & && | || * ** |
|
1461 case '=': |
1
|
1462 case '&': |
3246
|
1463 case '|': |
1
|
1464 case '*': |
3774
|
1465 // Always a binary op (may also include ==, &&, ||, **). |
|
1466 bin_op = true; |
3246
|
1467 break; |
|
1468 |
3774
|
1469 // < <= <> > >= |
1
|
1470 case '<': |
|
1471 case '>': |
3774
|
1472 // Always a binary op (may also include <=, <>, >=). |
|
1473 bin_op = true; |
|
1474 break; |
|
1475 |
|
1476 // ~= != |
777
|
1477 case '~': |
|
1478 case '!': |
3246
|
1479 { |
|
1480 int c1 = yyinput (); |
|
1481 |
3774
|
1482 // ~ and ! can be unary ops, so require following =. |
|
1483 if (c1 == '=') |
|
1484 bin_op = true; |
3246
|
1485 |
|
1486 unput (c1); |
|
1487 } |
1
|
1488 break; |
|
1489 |
|
1490 default: |
1276
|
1491 break; |
1
|
1492 } |
|
1493 |
3246
|
1494 unput (c0); |
1
|
1495 |
|
1496 return bin_op; |
|
1497 } |
|
1498 |
767
|
1499 // Used to delete trailing white space from tokens. |
|
1500 |
3536
|
1501 static std::string |
1
|
1502 strip_trailing_whitespace (char *s) |
|
1503 { |
3523
|
1504 std::string retval = s; |
1
|
1505 |
1823
|
1506 size_t pos = retval.find_first_of (" \t"); |
1
|
1507 |
1823
|
1508 if (pos != NPOS) |
|
1509 retval.resize (pos); |
1
|
1510 |
|
1511 return retval; |
|
1512 } |
|
1513 |
3665
|
1514 static void |
|
1515 scan_for_comments (const char *text) |
|
1516 { |
|
1517 std::string comment_buf; |
|
1518 |
|
1519 bool in_comment = false; |
|
1520 bool beginning_of_comment = false; |
|
1521 |
|
1522 int len = strlen (text); |
|
1523 int i = 0; |
|
1524 |
|
1525 while (i < len) |
|
1526 { |
|
1527 char c = text[i++]; |
|
1528 |
|
1529 switch (c) |
|
1530 { |
|
1531 case '%': |
|
1532 case '#': |
|
1533 if (in_comment) |
|
1534 { |
|
1535 if (! beginning_of_comment) |
3802
|
1536 comment_buf += static_cast<char> (c); |
3665
|
1537 } |
|
1538 else |
|
1539 { |
|
1540 in_comment = true; |
|
1541 beginning_of_comment = true; |
|
1542 } |
|
1543 break; |
|
1544 |
|
1545 case '\n': |
|
1546 if (in_comment) |
|
1547 { |
3802
|
1548 comment_buf += static_cast<char> (c); |
3665
|
1549 octave_comment_buffer::append (comment_buf); |
|
1550 comment_buf.resize (0); |
|
1551 in_comment = false; |
|
1552 beginning_of_comment = false; |
|
1553 } |
|
1554 break; |
|
1555 |
|
1556 case '\r': |
|
1557 if (in_comment) |
3802
|
1558 comment_buf += static_cast<char> (c); |
3665
|
1559 if (i < len) |
|
1560 { |
|
1561 c = text[i++]; |
|
1562 |
|
1563 if (c == '\n') |
|
1564 { |
|
1565 if (in_comment) |
|
1566 { |
3802
|
1567 comment_buf += static_cast<char> (c); |
3665
|
1568 octave_comment_buffer::append (comment_buf); |
|
1569 in_comment = false; |
|
1570 beginning_of_comment = false; |
|
1571 } |
|
1572 } |
|
1573 } |
|
1574 |
|
1575 default: |
|
1576 if (in_comment) |
|
1577 { |
3802
|
1578 comment_buf += static_cast<char> (c); |
3665
|
1579 beginning_of_comment = false; |
|
1580 } |
|
1581 break; |
|
1582 } |
|
1583 } |
|
1584 |
|
1585 if (! comment_buf.empty ()) |
|
1586 octave_comment_buffer::append (comment_buf); |
|
1587 } |
|
1588 |
1001
|
1589 // Discard whitespace, including comments and continuations. |
1088
|
1590 // |
|
1591 // Return value is logical OR of the following values: |
|
1592 // |
1826
|
1593 // ATE_NOTHING : no spaces to eat |
1088
|
1594 // ATE_SPACE_OR_TAB : space or tab in input |
|
1595 // ATE_NEWLINE : bare new line in input |
1001
|
1596 |
1826
|
1597 static yum_yum |
975
|
1598 eat_whitespace (void) |
|
1599 { |
1826
|
1600 yum_yum retval = ATE_NOTHING; |
3665
|
1601 |
|
1602 std::string comment_buf; |
|
1603 |
2857
|
1604 bool in_comment = false; |
3665
|
1605 bool beginning_of_comment = false; |
|
1606 |
|
1607 int c = 0; |
|
1608 |
975
|
1609 while ((c = yyinput ()) != EOF) |
|
1610 { |
|
1611 current_input_column++; |
|
1612 |
|
1613 switch (c) |
|
1614 { |
|
1615 case ' ': |
|
1616 case '\t': |
3665
|
1617 if (in_comment) |
|
1618 { |
3802
|
1619 comment_buf += static_cast<char> (c); |
3665
|
1620 beginning_of_comment = false; |
|
1621 } |
1088
|
1622 retval |= ATE_SPACE_OR_TAB; |
975
|
1623 break; |
|
1624 |
|
1625 case '\n': |
1088
|
1626 retval |= ATE_NEWLINE; |
3665
|
1627 if (in_comment) |
|
1628 { |
3802
|
1629 comment_buf += static_cast<char> (c); |
3665
|
1630 octave_comment_buffer::append (comment_buf); |
|
1631 comment_buf.resize (0); |
|
1632 in_comment = false; |
|
1633 beginning_of_comment = false; |
|
1634 } |
975
|
1635 current_input_column = 0; |
|
1636 break; |
|
1637 |
|
1638 case '#': |
|
1639 case '%': |
3665
|
1640 if (in_comment) |
|
1641 { |
|
1642 if (! beginning_of_comment) |
3802
|
1643 comment_buf += static_cast<char> (c); |
3665
|
1644 } |
|
1645 else |
|
1646 { |
|
1647 in_comment = true; |
|
1648 beginning_of_comment = true; |
|
1649 } |
975
|
1650 break; |
|
1651 |
1001
|
1652 case '.': |
|
1653 if (in_comment) |
3665
|
1654 { |
3802
|
1655 comment_buf += static_cast<char> (c); |
3665
|
1656 beginning_of_comment = false; |
|
1657 break; |
|
1658 } |
1001
|
1659 else |
|
1660 { |
|
1661 if (have_ellipsis_continuation ()) |
|
1662 break; |
|
1663 else |
|
1664 goto done; |
|
1665 } |
|
1666 |
|
1667 case '\\': |
|
1668 if (in_comment) |
3665
|
1669 { |
3802
|
1670 comment_buf += static_cast<char> (c); |
3665
|
1671 beginning_of_comment = false; |
|
1672 break; |
|
1673 } |
1001
|
1674 else |
|
1675 { |
3105
|
1676 if (have_continuation ()) |
1001
|
1677 break; |
|
1678 else |
|
1679 goto done; |
|
1680 } |
|
1681 |
975
|
1682 default: |
|
1683 if (in_comment) |
3665
|
1684 { |
3802
|
1685 comment_buf += static_cast<char> (c); |
3665
|
1686 beginning_of_comment = false; |
|
1687 break; |
|
1688 } |
975
|
1689 else |
|
1690 goto done; |
|
1691 } |
|
1692 } |
|
1693 |
3665
|
1694 if (! comment_buf.empty ()) |
|
1695 octave_comment_buffer::append (comment_buf); |
|
1696 |
975
|
1697 done: |
3246
|
1698 unput (c); |
1082
|
1699 current_input_column--; |
1001
|
1700 return retval; |
975
|
1701 } |
|
1702 |
3220
|
1703 static inline bool |
|
1704 looks_like_hex (const char *s, int len) |
|
1705 { |
|
1706 return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')); |
|
1707 } |
|
1708 |
975
|
1709 static void |
3246
|
1710 handle_number (void) |
972
|
1711 { |
3220
|
1712 double value = 0.0; |
|
1713 int nread = 0; |
|
1714 |
3598
|
1715 if (looks_like_hex (yytext, strlen (yytext))) |
3220
|
1716 { |
|
1717 unsigned long ival; |
3598
|
1718 |
|
1719 nread = sscanf (yytext, "%lx", &ival); |
|
1720 |
3220
|
1721 value = static_cast<double> (ival); |
|
1722 } |
|
1723 else |
3598
|
1724 { |
|
1725 char *tmp = strsave (yytext); |
|
1726 |
|
1727 char *idx = strpbrk (tmp, "Dd"); |
2621
|
1728 |
3598
|
1729 if (idx) |
|
1730 *idx = 'e'; |
|
1731 |
|
1732 nread = sscanf (tmp, "%lf", &value); |
|
1733 |
|
1734 delete [] tmp; |
|
1735 } |
972
|
1736 |
1826
|
1737 // If yytext doesn't contain a valid number, we are in deep doo doo. |
985
|
1738 |
972
|
1739 assert (nread == 1); |
|
1740 |
3988
|
1741 lexer_flags.quote_is_transpose = true; |
|
1742 lexer_flags.cant_be_identifier = true; |
|
1743 lexer_flags.convert_spaces_to_comma = true; |
972
|
1744 |
1826
|
1745 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
3575
|
1746 lexer_flags.past_plot_range = true; |
972
|
1747 |
|
1748 yylval.tok_val = new token (value, yytext, input_line_number, |
|
1749 current_input_column); |
|
1750 |
|
1751 token_stack.push (yylval.tok_val); |
|
1752 |
|
1753 current_input_column += yyleng; |
|
1754 |
|
1755 do_comma_insert_check (); |
|
1756 } |
|
1757 |
1001
|
1758 // We have seen a backslash and need to find out if it should be |
|
1759 // treated as a continuation character. If so, this eats it, up to |
|
1760 // and including the new line character. |
|
1761 // |
973
|
1762 // Match whitespace only, followed by a comment character or newline. |
|
1763 // Once a comment character is found, discard all input until newline. |
|
1764 // If non-whitespace characters are found before comment |
|
1765 // characters, return 0. Otherwise, return 1. |
|
1766 |
2857
|
1767 static bool |
3096
|
1768 have_continuation (bool trailing_comments_ok) |
973
|
1769 { |
3523
|
1770 std::ostrstream buf; |
973
|
1771 |
3665
|
1772 std::string comment_buf; |
|
1773 |
2857
|
1774 bool in_comment = false; |
3665
|
1775 bool beginning_of_comment = false; |
|
1776 |
|
1777 int c = 0; |
|
1778 |
973
|
1779 while ((c = yyinput ()) != EOF) |
|
1780 { |
3802
|
1781 buf << static_cast<char> (c); |
973
|
1782 |
|
1783 switch (c) |
|
1784 { |
|
1785 case ' ': |
|
1786 case '\t': |
3665
|
1787 if (in_comment) |
|
1788 { |
3802
|
1789 comment_buf += static_cast<char> (c); |
3665
|
1790 beginning_of_comment = false; |
|
1791 } |
973
|
1792 break; |
|
1793 |
|
1794 case '%': |
|
1795 case '#': |
1091
|
1796 if (trailing_comments_ok) |
3665
|
1797 { |
|
1798 if (in_comment) |
|
1799 { |
|
1800 if (! beginning_of_comment) |
3802
|
1801 comment_buf += static_cast<char> (c); |
3665
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 in_comment = true; |
|
1806 beginning_of_comment = true; |
|
1807 } |
|
1808 } |
1091
|
1809 else |
|
1810 goto cleanup; |
973
|
1811 break; |
|
1812 |
|
1813 case '\n': |
3665
|
1814 if (in_comment) |
|
1815 { |
3802
|
1816 comment_buf += static_cast<char> (c); |
3665
|
1817 octave_comment_buffer::append (comment_buf); |
|
1818 } |
975
|
1819 current_input_column = 0; |
1001
|
1820 promptflag--; |
2857
|
1821 return true; |
973
|
1822 |
3263
|
1823 case '\r': |
3665
|
1824 if (in_comment) |
3802
|
1825 comment_buf += static_cast<char> (c); |
3263
|
1826 c = yyinput (); |
|
1827 if (c == EOF) |
|
1828 break; |
|
1829 else if (c == '\n') |
|
1830 { |
3665
|
1831 if (in_comment) |
|
1832 { |
3802
|
1833 comment_buf += static_cast<char> (c); |
3665
|
1834 octave_comment_buffer::append (comment_buf); |
|
1835 } |
3263
|
1836 current_input_column = 0; |
|
1837 promptflag--; |
|
1838 return true; |
3665
|
1839 } |
3263
|
1840 |
3802
|
1841 // Fall through... |
|
1842 |
973
|
1843 default: |
3665
|
1844 if (in_comment) |
|
1845 { |
3802
|
1846 comment_buf += static_cast<char> (c); |
3665
|
1847 beginning_of_comment = false; |
|
1848 } |
|
1849 else |
1091
|
1850 goto cleanup; |
|
1851 break; |
973
|
1852 } |
|
1853 } |
|
1854 |
3246
|
1855 unput (c); |
2857
|
1856 return false; |
973
|
1857 |
3096
|
1858 cleanup: |
3538
|
1859 buf << std::ends; |
1091
|
1860 char *s = buf.str (); |
|
1861 if (s) |
|
1862 { |
|
1863 int len = strlen (s); |
|
1864 while (len--) |
3246
|
1865 unput (s[len]); |
1091
|
1866 } |
|
1867 delete [] s; |
3096
|
1868 |
2857
|
1869 return false; |
973
|
1870 } |
|
1871 |
1001
|
1872 // We have seen a `.' and need to see if it is the start of a |
|
1873 // continuation. If so, this eats it, up to and including the new |
|
1874 // line character. |
|
1875 |
2857
|
1876 static bool |
3096
|
1877 have_ellipsis_continuation (bool trailing_comments_ok) |
973
|
1878 { |
|
1879 char c1 = yyinput (); |
|
1880 if (c1 == '.') |
|
1881 { |
|
1882 char c2 = yyinput (); |
1091
|
1883 if (c2 == '.' && have_continuation (trailing_comments_ok)) |
2857
|
1884 return true; |
973
|
1885 else |
|
1886 { |
3246
|
1887 unput (c2); |
|
1888 unput (c1); |
973
|
1889 } |
|
1890 } |
|
1891 else |
3246
|
1892 unput (c1); |
973
|
1893 |
2857
|
1894 return false; |
973
|
1895 } |
|
1896 |
1001
|
1897 // See if we have a continuation line. If so, eat it and the leading |
|
1898 // whitespace on the next line. |
1088
|
1899 // |
|
1900 // Return value is the same as described for eat_whitespace(). |
1001
|
1901 |
1826
|
1902 static yum_yum |
1001
|
1903 eat_continuation (void) |
|
1904 { |
1826
|
1905 int retval = ATE_NOTHING; |
3665
|
1906 |
1001
|
1907 int c = yyinput (); |
3665
|
1908 |
1001
|
1909 if ((c == '.' && have_ellipsis_continuation ()) |
3105
|
1910 || (c == '\\' && have_continuation ())) |
1001
|
1911 retval = eat_whitespace (); |
|
1912 else |
3246
|
1913 unput (c); |
1001
|
1914 |
|
1915 return retval; |
|
1916 } |
|
1917 |
973
|
1918 static int |
975
|
1919 handle_string (char delim, int text_style) |
973
|
1920 { |
3523
|
1921 std::ostrstream buf; |
973
|
1922 |
3805
|
1923 int bos_line = input_line_number; |
|
1924 int bos_col = current_input_column; |
|
1925 |
973
|
1926 int c; |
1031
|
1927 int escape_pending = 0; |
973
|
1928 |
|
1929 while ((c = yyinput ()) != EOF) |
|
1930 { |
|
1931 current_input_column++; |
|
1932 |
3105
|
1933 if (c == '\\') |
973
|
1934 { |
1053
|
1935 if (escape_pending) |
|
1936 { |
3802
|
1937 buf << static_cast<char> (c); |
1053
|
1938 escape_pending = 0; |
|
1939 } |
|
1940 else |
|
1941 { |
3096
|
1942 if (have_continuation (false)) |
1053
|
1943 escape_pending = 0; |
|
1944 else |
|
1945 { |
3802
|
1946 buf << static_cast<char> (c); |
1053
|
1947 escape_pending = 1; |
|
1948 } |
|
1949 } |
1031
|
1950 continue; |
973
|
1951 } |
|
1952 else if (c == '.') |
|
1953 { |
3096
|
1954 if (! have_ellipsis_continuation (false)) |
3802
|
1955 buf << static_cast<char> (c); |
973
|
1956 } |
|
1957 else if (c == '\n') |
|
1958 { |
1053
|
1959 error ("unterminated string constant"); |
973
|
1960 break; |
|
1961 } |
|
1962 else if (c == delim) |
|
1963 { |
1031
|
1964 if (escape_pending) |
3802
|
1965 buf << static_cast<char> (c); |
973
|
1966 else |
|
1967 { |
|
1968 c = yyinput (); |
|
1969 if (c == delim) |
3802
|
1970 buf << static_cast<char> (c); |
973
|
1971 else |
|
1972 { |
3246
|
1973 unput (c); |
3538
|
1974 buf << std::ends; |
3105
|
1975 char *t = buf.str (); |
3523
|
1976 std::string s = do_string_escapes (t); |
3105
|
1977 delete [] t; |
975
|
1978 |
1826
|
1979 if (text_style && lexer_flags.doing_set) |
975
|
1980 { |
3523
|
1981 s = std::string (1, delim) + s + std::string (1, delim); |
975
|
1982 } |
|
1983 else |
|
1984 { |
2857
|
1985 lexer_flags.quote_is_transpose = true; |
|
1986 lexer_flags.cant_be_identifier = true; |
|
1987 lexer_flags.convert_spaces_to_comma = true; |
975
|
1988 } |
|
1989 |
3805
|
1990 yylval.tok_val = new token (s, bos_line, bos_col); |
973
|
1991 token_stack.push (yylval.tok_val); |
3400
|
1992 |
|
1993 if (delim == '\'') |
|
1994 gripe_single_quote_string (); |
|
1995 |
973
|
1996 return TEXT; |
|
1997 } |
|
1998 } |
|
1999 } |
|
2000 else |
|
2001 { |
3802
|
2002 buf << static_cast<char> (c); |
973
|
2003 } |
|
2004 |
1031
|
2005 escape_pending = 0; |
973
|
2006 } |
|
2007 |
|
2008 return LEXICAL_ERROR; |
|
2009 } |
|
2010 |
3208
|
2011 static bool |
|
2012 next_token_is_assign_op (void) |
|
2013 { |
|
2014 bool retval = false; |
|
2015 |
|
2016 int c0 = yyinput (); |
|
2017 |
|
2018 switch (c0) |
|
2019 { |
|
2020 case '=': |
|
2021 { |
|
2022 int c1 = yyinput (); |
|
2023 unput (c1); |
|
2024 if (c1 != '=') |
|
2025 retval = true; |
|
2026 } |
|
2027 break; |
|
2028 |
|
2029 case '+': |
|
2030 case '-': |
|
2031 case '*': |
|
2032 case '/': |
|
2033 case '\\': |
|
2034 case '&': |
|
2035 case '|': |
|
2036 { |
|
2037 int c1 = yyinput (); |
|
2038 unput (c1); |
|
2039 if (c1 == '=') |
|
2040 retval = true; |
|
2041 } |
|
2042 break; |
|
2043 |
|
2044 case '.': |
|
2045 { |
|
2046 int c1 = yyinput (); |
|
2047 if (match_any (c1, "+-*/\\")) |
|
2048 { |
|
2049 int c2 = yyinput (); |
|
2050 unput (c2); |
|
2051 if (c2 == '=') |
|
2052 retval = true; |
|
2053 } |
|
2054 unput (c1); |
|
2055 } |
|
2056 break; |
|
2057 |
|
2058 case '>': |
|
2059 { |
|
2060 int c1 = yyinput (); |
|
2061 if (c1 == '>') |
|
2062 { |
|
2063 int c2 = yyinput (); |
|
2064 unput (c2); |
|
2065 if (c2 == '=') |
|
2066 retval = true; |
|
2067 } |
|
2068 unput (c1); |
|
2069 } |
|
2070 break; |
|
2071 |
|
2072 case '<': |
|
2073 { |
|
2074 int c1 = yyinput (); |
|
2075 if (c1 == '<') |
|
2076 { |
|
2077 int c2 = yyinput (); |
|
2078 unput (c2); |
|
2079 if (c2 == '=') |
|
2080 retval = true; |
|
2081 } |
|
2082 unput (c1); |
|
2083 } |
|
2084 break; |
|
2085 |
|
2086 default: |
|
2087 break; |
|
2088 } |
|
2089 |
|
2090 unput (c0); |
|
2091 |
|
2092 return retval; |
|
2093 } |
|
2094 |
971
|
2095 static int |
3351
|
2096 handle_close_bracket (int spc_gobbled) |
971
|
2097 { |
3208
|
2098 int retval = ']'; |
|
2099 |
1826
|
2100 if (! nesting_level.none ()) |
971
|
2101 { |
1826
|
2102 nesting_level.remove (); |
3351
|
2103 lexer_flags.bracketflag--; |
971
|
2104 } |
|
2105 |
3351
|
2106 if (lexer_flags.bracketflag == 0) |
1001
|
2107 BEGIN 0; |
|
2108 |
3208
|
2109 if (next_token_is_assign_op () && ! lexer_flags.looking_at_return_list) |
971
|
2110 { |
3208
|
2111 retval = CLOSE_BRACE; |
971
|
2112 } |
|
2113 else |
|
2114 { |
3208
|
2115 int c1 = yyinput (); |
971
|
2116 unput (c1); |
|
2117 |
3388
|
2118 if (lexer_flags.bracketflag) |
971
|
2119 { |
3246
|
2120 int bin_op = next_token_is_bin_op (spc_gobbled); |
3263
|
2121 |
3246
|
2122 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
971
|
2123 |
3263
|
2124 int sep_op = next_token_is_sep_op (); |
971
|
2125 |
3263
|
2126 if (! (postfix_un_op || bin_op || sep_op) |
3351
|
2127 && nesting_level.is_bracket () |
1826
|
2128 && lexer_flags.convert_spaces_to_comma) |
971
|
2129 { |
3388
|
2130 maybe_warn_separator_insert (','); |
|
2131 |
|
2132 if (Vwhitespace_in_literal_matrix != 2) |
|
2133 { |
|
2134 unput (','); |
|
2135 return ']'; |
|
2136 } |
971
|
2137 } |
|
2138 } |
|
2139 } |
|
2140 |
2857
|
2141 lexer_flags.quote_is_transpose = true; |
|
2142 lexer_flags.cant_be_identifier = false; |
|
2143 lexer_flags.convert_spaces_to_comma = true; |
3208
|
2144 |
|
2145 return retval; |
971
|
2146 } |
|
2147 |
1072
|
2148 static void |
|
2149 maybe_unput_comma (int spc_gobbled) |
|
2150 { |
3388
|
2151 if (nesting_level.is_bracket ()) |
1072
|
2152 { |
3246
|
2153 int bin_op = next_token_is_bin_op (spc_gobbled); |
1072
|
2154 |
3246
|
2155 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
1072
|
2156 |
|
2157 int c1 = yyinput (); |
|
2158 int c2 = yyinput (); |
2970
|
2159 |
1072
|
2160 unput (c2); |
|
2161 unput (c1); |
2970
|
2162 |
3263
|
2163 int sep_op = next_token_is_sep_op (); |
2970
|
2164 |
1072
|
2165 int dot_op = (c1 == '.' |
|
2166 && (isalpha (c2) || isspace (c2) || c2 == '_')); |
2970
|
2167 |
3388
|
2168 if (postfix_un_op || bin_op || sep_op || dot_op) |
|
2169 return; |
|
2170 |
3985
|
2171 int index_op = (c1 == '(' || c1 == '{'); |
3388
|
2172 |
|
2173 if (index_op) |
|
2174 { |
3985
|
2175 // If there is no space before the indexing op, we don't |
|
2176 // insert a comma. |
3388
|
2177 if (! spc_gobbled) |
|
2178 return; |
|
2179 |
|
2180 maybe_warn_separator_insert (','); |
1072
|
2181 |
3388
|
2182 // If there is a space, we only insert a comma if we are |
|
2183 // trying to be Matlab-like. |
|
2184 if (Vwhitespace_in_literal_matrix == 1) |
|
2185 unput (','); |
|
2186 } |
|
2187 else |
|
2188 { |
|
2189 maybe_warn_separator_insert (','); |
|
2190 |
|
2191 if (Vwhitespace_in_literal_matrix != 2) |
|
2192 unput (','); |
|
2193 } |
1072
|
2194 } |
|
2195 } |
|
2196 |
767
|
2197 // Figure out exactly what kind of token to return when we have seen |
|
2198 // an identifier. Handles keywords. |
|
2199 |
146
|
2200 static int |
3974
|
2201 handle_identifier (void) |
146
|
2202 { |
3974
|
2203 std::string tok = strip_trailing_whitespace (yytext); |
|
2204 |
|
2205 int c = yytext[yyleng-1]; |
|
2206 |
|
2207 int cont_is_spc = eat_continuation (); |
|
2208 |
|
2209 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); |
|
2210 |
1826
|
2211 // It is almost always an error for an identifier to be followed |
|
2212 // directly by another identifier. Special cases are handled |
|
2213 // below. |
883
|
2214 |
2857
|
2215 lexer_flags.cant_be_identifier = true; |
883
|
2216 |
2970
|
2217 // If we are expecting a structure element, avoid recognizing |
|
2218 // keywords and other special names and return STRUCT_ELT, which is |
|
2219 // a string that is also a valid identifier. But first, we have to |
|
2220 // decide whether to insert a comma. |
747
|
2221 |
1826
|
2222 if (lexer_flags.looking_at_indirect_ref) |
1072
|
2223 { |
2970
|
2224 do_comma_insert_check (); |
|
2225 |
1072
|
2226 maybe_unput_comma (spc_gobbled); |
2819
|
2227 |
|
2228 yylval.tok_val = new token (tok, input_line_number, |
|
2229 current_input_column); |
|
2230 |
|
2231 token_stack.push (yylval.tok_val); |
|
2232 |
2857
|
2233 lexer_flags.cant_be_identifier = false; |
|
2234 lexer_flags.quote_is_transpose = true; |
|
2235 lexer_flags.convert_spaces_to_comma = true; |
2819
|
2236 |
|
2237 current_input_column += yyleng; |
|
2238 |
2970
|
2239 return STRUCT_ELT; |
1072
|
2240 } |
747
|
2241 |
1826
|
2242 // If we have a regular keyword, or a plot STYLE, return it. |
|
2243 // Keywords can be followed by identifiers (TOK_RETURN handles |
|
2244 // that). |
146
|
2245 |
|
2246 int kw_token = is_keyword (tok); |
2970
|
2247 |
146
|
2248 if (kw_token) |
|
2249 { |
|
2250 if (kw_token == STYLE) |
|
2251 { |
1060
|
2252 current_input_column += yyleng; |
2857
|
2253 lexer_flags.quote_is_transpose = false; |
|
2254 lexer_flags.convert_spaces_to_comma = true; |
146
|
2255 return kw_token; |
|
2256 } |
|
2257 else |
|
2258 TOK_RETURN (kw_token); |
|
2259 } |
|
2260 |
1826
|
2261 // See if we have a plot keyword (title, using, with, or clear). |
146
|
2262 |
1826
|
2263 if (lexer_flags.plotting) |
941
|
2264 { |
1826
|
2265 // Yes, we really do need both of these plot_range variables. |
|
2266 // One is used to mark when we are past all possiblity of a plot |
|
2267 // range, the other is used to mark when we are actually between |
|
2268 // the square brackets that surround the range. |
146
|
2269 |
1826
|
2270 if (! lexer_flags.in_plot_range) |
2857
|
2271 lexer_flags.past_plot_range = true; |
941
|
2272 |
3351
|
2273 // Option keywords can't appear in brackets, braces, or parentheses. |
1273
|
2274 |
|
2275 int plot_option_kw = 0; |
2970
|
2276 |
1826
|
2277 if (nesting_level.none ()) |
1273
|
2278 plot_option_kw = is_plot_keyword (tok); |
3575
|
2279 |
1826
|
2280 if (lexer_flags.cant_be_identifier && plot_option_kw) |
941
|
2281 TOK_RETURN (plot_option_kw); |
|
2282 } |
146
|
2283 |
3480
|
2284 int c1 = yyinput (); |
|
2285 |
|
2286 bool next_tok_is_dot = (c1 == '.'); |
|
2287 bool next_tok_is_paren = (c1 == '('); |
|
2288 |
|
2289 bool next_tok_is_eq = false; |
|
2290 if (c1 == '=') |
|
2291 { |
|
2292 int c2 = yyinput (); |
|
2293 unput (c2); |
|
2294 |
|
2295 if (c2 != '=') |
|
2296 next_tok_is_eq = true; |
|
2297 } |
|
2298 |
|
2299 unput (c1); |
1001
|
2300 |
1826
|
2301 // Make sure we put the return values of a function in the symbol |
|
2302 // table that is local to the function. |
146
|
2303 |
2877
|
2304 // If we are defining a function and we have not seen the function |
|
2305 // name yet and the next token is `=', then this identifier must be |
|
2306 // the only return value for the function and it belongs in the |
|
2307 // local symbol table. |
|
2308 |
1826
|
2309 if (next_tok_is_eq |
2877
|
2310 && lexer_flags.defining_func |
|
2311 && ! lexer_flags.parsed_function_name) |
146
|
2312 curr_sym_tab = tmp_local_sym_tab; |
|
2313 |
2702
|
2314 // Kluge alert. |
|
2315 // |
|
2316 // If we are looking at a text style function, set up to gobble its |
2745
|
2317 // arguments. |
|
2318 // |
|
2319 // If the following token is `=', or if we are parsing a function |
3189
|
2320 // return list or function parameter list, or if we are looking at |
|
2321 // something like [ab,cd] = foo (), force the symbol to be inserted |
|
2322 // as a variable in the current symbol table. |
2702
|
2323 |
|
2324 if (is_text_function_name (tok) && ! is_variable (tok)) |
|
2325 { |
2745
|
2326 if (next_tok_is_eq |
|
2327 || lexer_flags.looking_at_return_list |
3189
|
2328 || lexer_flags.looking_at_parameter_list |
3246
|
2329 || lexer_flags.looking_at_matrix_or_assign_lhs |
|
2330 || (next_tok_is_dot && next_token_is_bin_op (spc_gobbled))) |
2745
|
2331 { |
|
2332 force_local_variable (tok); |
|
2333 } |
2702
|
2334 else if (! next_tok_is_paren) |
|
2335 { |
|
2336 if (tok == "gset") |
2857
|
2337 lexer_flags.doing_set = true; |
2702
|
2338 |
|
2339 BEGIN TEXT_FCN; |
|
2340 } |
|
2341 } |
|
2342 |
1826
|
2343 // Find the token in the symbol table. |
146
|
2344 |
|
2345 yylval.tok_val = new token (lookup_identifier (tok), |
|
2346 input_line_number, |
|
2347 current_input_column); |
|
2348 |
|
2349 token_stack.push (yylval.tok_val); |
|
2350 |
1826
|
2351 // After seeing an identifer, it is ok to convert spaces to a comma |
|
2352 // (if needed). |
146
|
2353 |
2857
|
2354 lexer_flags.convert_spaces_to_comma = true; |
146
|
2355 |
2877
|
2356 if (! next_tok_is_eq) |
|
2357 { |
|
2358 lexer_flags.quote_is_transpose = true; |
146
|
2359 |
2877
|
2360 do_comma_insert_check (); |
|
2361 |
|
2362 maybe_unput_comma (spc_gobbled); |
146
|
2363 } |
|
2364 |
2877
|
2365 current_input_column += yyleng; |
146
|
2366 |
|
2367 return NAME; |
|
2368 } |
|
2369 |
767
|
2370 // Print a warning if a function file that defines a function has |
|
2371 // anything other than comments and whitespace following the END token |
|
2372 // that matches the FUNCTION statement. |
|
2373 |
1
|
2374 void |
|
2375 check_for_garbage_after_fcn_def (void) |
|
2376 { |
1826
|
2377 // By making a newline be the next character to be read, we will |
|
2378 // force the parser to return after reading the function. Calling |
3246
|
2379 // unput with EOF does not work. |
1
|
2380 |
3665
|
2381 std::string comment_buf; |
|
2382 |
2857
|
2383 bool in_comment = false; |
3665
|
2384 bool beginning_of_comment = true; |
|
2385 |
1
|
2386 int lineno = input_line_number; |
3665
|
2387 |
|
2388 int c = 0; |
|
2389 |
1
|
2390 while ((c = yyinput ()) != EOF) |
|
2391 { |
|
2392 switch (c) |
|
2393 { |
|
2394 case ' ': |
|
2395 case '\t': |
|
2396 case ';': |
|
2397 case ',': |
3665
|
2398 if (in_comment) |
|
2399 { |
3802
|
2400 comment_buf += static_cast<char> (c); |
3665
|
2401 beginning_of_comment = false; |
|
2402 } |
1
|
2403 break; |
777
|
2404 |
1
|
2405 case '%': |
|
2406 case '#': |
3665
|
2407 if (in_comment) |
|
2408 { |
|
2409 if (! beginning_of_comment) |
3802
|
2410 comment_buf += static_cast<char> (c); |
3665
|
2411 } |
|
2412 else |
|
2413 { |
|
2414 in_comment = true; |
|
2415 beginning_of_comment = true; |
|
2416 } |
1
|
2417 break; |
777
|
2418 |
3802
|
2419 case '\n': |
|
2420 if (in_comment) |
|
2421 { |
|
2422 comment_buf += static_cast<char> (c); |
|
2423 octave_comment_buffer::append (comment_buf); |
|
2424 comment_buf.resize (0); |
|
2425 in_comment = false; |
|
2426 beginning_of_comment = false; |
|
2427 } |
|
2428 break; |
|
2429 |
|
2430 case '\r': |
|
2431 if (in_comment) |
|
2432 comment_buf += static_cast<char> (c); |
|
2433 c = yyinput (); |
|
2434 if (c == EOF) |
|
2435 break; |
|
2436 else if (c == '\n') |
|
2437 { |
|
2438 if (in_comment) |
|
2439 { |
|
2440 comment_buf += static_cast<char> (c); |
|
2441 octave_comment_buffer::append (comment_buf); |
|
2442 comment_buf.resize (0); |
|
2443 in_comment = false; |
|
2444 beginning_of_comment = false; |
|
2445 } |
|
2446 break; |
|
2447 } |
|
2448 |
|
2449 // Fall through... |
|
2450 |
1
|
2451 default: |
|
2452 if (in_comment) |
3665
|
2453 { |
3802
|
2454 comment_buf += static_cast<char> (c); |
3665
|
2455 beginning_of_comment = false; |
|
2456 break; |
|
2457 } |
1
|
2458 else |
|
2459 { |
|
2460 warning ("ignoring trailing garbage after end of function\n\ |
1755
|
2461 near line %d of file `%s.m'", lineno, curr_fcn_file_name.c_str ()); |
1
|
2462 |
3246
|
2463 unput ('\n'); |
1
|
2464 return; |
|
2465 } |
|
2466 } |
|
2467 } |
3665
|
2468 |
|
2469 if (! comment_buf.empty ()) |
|
2470 octave_comment_buffer::append (comment_buf); |
|
2471 |
3246
|
2472 unput ('\n'); |
1
|
2473 } |
|
2474 |
1826
|
2475 void |
|
2476 lexical_feedback::init (void) |
|
2477 { |
|
2478 // Not initially defining a matrix list. |
3351
|
2479 bracketflag = 0; |
1826
|
2480 |
|
2481 // Not initially inside a loop or if statement. |
|
2482 looping = 0; |
|
2483 |
2857
|
2484 // Not initially defining a function. |
|
2485 beginning_of_function = false; |
|
2486 defining_func = false; |
2877
|
2487 parsed_function_name = false; |
2857
|
2488 |
|
2489 // Not parsing a function return or parameter list. |
|
2490 looking_at_return_list = false; |
|
2491 looking_at_parameter_list = false; |
|
2492 |
3796
|
2493 // Not parsing a matrix or the left hand side of multi-value |
|
2494 // assignment statement. |
|
2495 looking_at_matrix_or_assign_lhs = false; |
|
2496 |
2857
|
2497 // Next token can be identifier. |
|
2498 cant_be_identifier = false; |
|
2499 |
|
2500 // No need to do comma insert or convert spaces to comma at |
|
2501 // beginning of input. |
|
2502 convert_spaces_to_comma = true; |
|
2503 do_comma_insert = false; |
|
2504 |
|
2505 // Not initially doing any plotting or setting of plot attributes. |
|
2506 doing_set = false; |
|
2507 in_plot_range = false; |
|
2508 in_plot_style = false; |
3165
|
2509 in_plot_axes = false; |
2857
|
2510 in_plot_using = false; |
|
2511 past_plot_range = false; |
|
2512 plotting = false; |
|
2513 |
1826
|
2514 // Not initially looking at indirect references. |
2857
|
2515 looking_at_indirect_ref = false; |
1826
|
2516 |
|
2517 // Quote marks strings intially. |
2857
|
2518 quote_is_transpose = false; |
1826
|
2519 } |
|
2520 |
3388
|
2521 static void |
|
2522 maybe_warn_separator_insert (char sep) |
|
2523 { |
3523
|
2524 std::string nm = curr_fcn_file_full_name; |
3388
|
2525 |
|
2526 if (Vwarn_separator_insert) |
|
2527 { |
|
2528 if (nm.empty ()) |
|
2529 warning ("potential auto-insertion of `%c' near line %d", |
|
2530 sep, input_line_number); |
|
2531 else |
|
2532 warning ("potential auto-insertion of `%c' near line %d of file %s", |
|
2533 sep, input_line_number, nm.c_str ()); |
|
2534 } |
|
2535 } |
|
2536 |
3400
|
2537 static void |
|
2538 gripe_single_quote_string (void) |
|
2539 { |
3523
|
2540 std::string nm = curr_fcn_file_full_name; |
3400
|
2541 |
|
2542 if (Vwarn_single_quote_string) |
|
2543 { |
|
2544 if (nm.empty ()) |
|
2545 warning ("single quote delimited string near line %d", |
|
2546 input_line_number); |
|
2547 else |
|
2548 warning ("single quote delimited string near line %d of file %s", |
|
2549 input_line_number, nm.c_str ()); |
|
2550 } |
|
2551 } |
|
2552 |
3388
|
2553 static int |
|
2554 warn_separator_insert (void) |
|
2555 { |
|
2556 Vwarn_separator_insert = check_preference ("warn_separator_insert"); |
|
2557 |
|
2558 return 0; |
|
2559 } |
|
2560 |
3246
|
2561 static int |
3400
|
2562 warn_single_quote_string (void) |
|
2563 { |
|
2564 Vwarn_single_quote_string = check_preference ("warn_single_quote_string"); |
|
2565 |
|
2566 return 0; |
|
2567 } |
|
2568 |
|
2569 static int |
2167
|
2570 whitespace_in_literal_matrix (void) |
|
2571 { |
|
2572 int pref = 0; |
3009
|
2573 |
3523
|
2574 std::string val = builtin_string_variable ("whitespace_in_literal_matrix"); |
3009
|
2575 |
2167
|
2576 if (! val.empty ()) |
|
2577 { |
3565
|
2578 if (val == "ignore") |
2167
|
2579 pref = 2; |
3565
|
2580 else if (val == "traditional") |
2167
|
2581 pref = 1; |
|
2582 } |
3009
|
2583 |
2167
|
2584 Vwhitespace_in_literal_matrix = pref; |
3009
|
2585 |
2167
|
2586 return 0; |
|
2587 } |
|
2588 |
|
2589 void |
|
2590 symbols_of_lex (void) |
|
2591 { |
3388
|
2592 DEFVAR (warn_separator_insert, 0.0, warn_separator_insert, |
3428
|
2593 "-*- texinfo -*-\n\ |
|
2594 @defvr {Built-in Variable} warn_separator_insert\n\ |
3567
|
2595 Print warning if commas or semicolons might be inserted\n\ |
3428
|
2596 automatically in literal matrices.\n\ |
|
2597 @end defvr"); |
3388
|
2598 |
3400
|
2599 DEFVAR (warn_single_quote_string, 0.0, warn_single_quote_string, |
3428
|
2600 "-*- texinfo -*-\n\ |
|
2601 @defvr {Built-in Variable} warn_single_quote_string\n\ |
|
2602 Print warning if a signle quote character is used to introduce a\n\ |
|
2603 string constant.\n\ |
|
2604 @end defvr"); |
3400
|
2605 |
3258
|
2606 DEFVAR (whitespace_in_literal_matrix, "", whitespace_in_literal_matrix, |
3428
|
2607 "-*- texinfo -*-\n\ |
|
2608 @defvr {Built-in Variable} whitespace_in_literal_matrix\n\ |
|
2609 Control auto-insertion of commas and semicolons in literal matrices.\n\ |
|
2610 @end defvr"); |
|
2611 |
2167
|
2612 } |
|
2613 |
1994
|
2614 /* |
|
2615 ;;; Local Variables: *** |
|
2616 ;;; mode: C++ *** |
|
2617 ;;; End: *** |
|
2618 */ |