GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
lex.cc
Go to the documentation of this file.
1 #line 40 "../../libinterp/parse-tree/lex.ll"
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5 
6 
7 
8 
9 #line 10 "parse-tree/lex.cc"
10 
11 #define YY_INT_ALIGNED short int
12 
13 /* A lexical scanner generated by flex */
14 
15 #define FLEX_SCANNER
16 #define YY_FLEX_MAJOR_VERSION 2
17 #define YY_FLEX_MINOR_VERSION 5
18 #define YY_FLEX_SUBMINOR_VERSION 35
19 #if YY_FLEX_SUBMINOR_VERSION > 0
20 #define FLEX_BETA
21 #endif
22 
23 /* First, we deal with platform-specific or compiler-specific issues. */
24 
25 /* begin standard C headers. */
26 #include <stdio.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <stdlib.h>
30 
31 /* end standard C headers. */
32 
33 /* flex integer type definitions */
34 
35 #ifndef FLEXINT_H
36 #define FLEXINT_H
37 
38 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
39 
40 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
41 
42 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
43  * if you want the limit (max/min) macros for int types.
44  */
45 #ifndef __STDC_LIMIT_MACROS
46 #define __STDC_LIMIT_MACROS 1
47 #endif
48 
49 #include <inttypes.h>
50 typedef int8_t flex_int8_t;
51 typedef uint8_t flex_uint8_t;
52 typedef int16_t flex_int16_t;
53 typedef uint16_t flex_uint16_t;
54 typedef int32_t flex_int32_t;
55 typedef uint32_t flex_uint32_t;
56 #else
57 typedef signed char flex_int8_t;
58 typedef short int flex_int16_t;
59 typedef int flex_int32_t;
60 typedef unsigned char flex_uint8_t;
61 typedef unsigned short int flex_uint16_t;
62 typedef unsigned int flex_uint32_t;
63 
64 /* Limits of integral types. */
65 #ifndef INT8_MIN
66 #define INT8_MIN (-128)
67 #endif
68 #ifndef INT16_MIN
69 #define INT16_MIN (-32767-1)
70 #endif
71 #ifndef INT32_MIN
72 #define INT32_MIN (-2147483647-1)
73 #endif
74 #ifndef INT8_MAX
75 #define INT8_MAX (127)
76 #endif
77 #ifndef INT16_MAX
78 #define INT16_MAX (32767)
79 #endif
80 #ifndef INT32_MAX
81 #define INT32_MAX (2147483647)
82 #endif
83 #ifndef UINT8_MAX
84 #define UINT8_MAX (255U)
85 #endif
86 #ifndef UINT16_MAX
87 #define UINT16_MAX (65535U)
88 #endif
89 #ifndef UINT32_MAX
90 #define UINT32_MAX (4294967295U)
91 #endif
92 
93 #endif /* ! C99 */
94 
95 #endif /* ! FLEXINT_H */
96 
97 #ifdef __cplusplus
98 
99 /* The "const" storage-class-modifier is valid. */
100 #define YY_USE_CONST
101 
102 #else /* ! __cplusplus */
103 
104 /* C99 requires __STDC__ to be defined as 1. */
105 #if defined (__STDC__)
106 
107 #define YY_USE_CONST
108 
109 #endif /* defined (__STDC__) */
110 #endif /* ! __cplusplus */
111 
112 #ifdef YY_USE_CONST
113 #define yyconst const
114 #else
115 #define yyconst
116 #endif
117 
118 /* Returned upon end-of-file. */
119 #define YY_NULL 0
120 
121 /* Promotes a possibly negative, possibly signed char to an unsigned
122  * integer for use as an array index. If the signed char is negative,
123  * we want to instead treat it as an 8-bit unsigned char, hence the
124  * double cast.
125  */
126 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
127 
128 /* An opaque pointer. */
129 #ifndef YY_TYPEDEF_YY_SCANNER_T
130 #define YY_TYPEDEF_YY_SCANNER_T
131 typedef void* yyscan_t;
132 #endif
133 
134 /* For convenience, these vars (plus the bison vars far below)
135  are macros in the reentrant scanner. */
136 #define yyin yyg->yyin_r
137 #define yyout yyg->yyout_r
138 #define yyextra yyg->yyextra_r
139 #define yyleng yyg->yyleng_r
140 #define yytext yyg->yytext_r
141 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
142 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
143 #define yy_flex_debug yyg->yy_flex_debug_r
144 
145 /* Enter a start condition. This macro really ought to take a parameter,
146  * but we do it the disgusting crufty way forced on us by the ()-less
147  * definition of BEGIN.
148  */
149 #define BEGIN yyg->yy_start = 1 + 2 *
150 
151 /* Translate the current start state into a value that can be later handed
152  * to BEGIN to return to the state. The YYSTATE alias is for lex
153  * compatibility.
154  */
155 #define YY_START ((yyg->yy_start - 1) / 2)
156 #define YYSTATE YY_START
157 
158 /* Action number for EOF rule of a given start state. */
159 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
160 
161 /* Special action meaning "start processing a new file". */
162 #define YY_NEW_FILE octave_restart(yyin ,yyscanner )
163 
164 #define YY_END_OF_BUFFER_CHAR 0
165 
166 /* Size of default input buffer. */
167 #ifndef YY_BUF_SIZE
168 #ifdef __ia64__
169 /* On IA-64, the buffer size is 16k, not 8k.
170  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
171  * Ditto for the __ia64__ case accordingly.
172  */
173 #define YY_BUF_SIZE 32768
174 #else
175 #define YY_BUF_SIZE 16384
176 #endif /* __ia64__ */
177 #endif
178 
179 /* The state buf must be large enough to hold one state per character in the main buffer.
180  */
181 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
182 
183 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
184 #define YY_TYPEDEF_YY_BUFFER_STATE
186 #endif
187 
188 #define EOB_ACT_CONTINUE_SCAN 0
189 #define EOB_ACT_END_OF_FILE 1
190 #define EOB_ACT_LAST_MATCH 2
191 
192  #define YY_LESS_LINENO(n)
193 
194 /* Return all but the first "n" matched characters back to the input stream. */
195 #define yyless(n) \
196  do \
197  { \
198  /* Undo effects of setting up yytext. */ \
199  int yyless_macro_arg = (n); \
200  YY_LESS_LINENO(yyless_macro_arg);\
201  *yy_cp = yyg->yy_hold_char; \
202  YY_RESTORE_YY_MORE_OFFSET \
203  yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
204  YY_DO_BEFORE_ACTION; /* set up yytext again */ \
205  } \
206  while ( 0 )
207 
208 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
209 
210 #ifndef YY_TYPEDEF_YY_SIZE_T
211 #define YY_TYPEDEF_YY_SIZE_T
212 typedef size_t yy_size_t;
213 #endif
214 
215 #ifndef YY_STRUCT_YY_BUFFER_STATE
216 #define YY_STRUCT_YY_BUFFER_STATE
217 struct yy_buffer_state
218  {
219  FILE *yy_input_file;
220 
221  char *yy_ch_buf; /* input buffer */
222  char *yy_buf_pos; /* current position in input buffer */
223 
224  /* Size of input buffer in bytes, not including room for EOB
225  * characters.
226  */
228 
229  /* Number of characters read into yy_ch_buf, not including EOB
230  * characters.
231  */
232  int yy_n_chars;
233 
234  /* Whether we "own" the buffer - i.e., we know we created it,
235  * and can realloc() it to grow it, and should free() it to
236  * delete it.
237  */
238  int yy_is_our_buffer;
239 
240  /* Whether this is an "interactive" input source; if so, and
241  * if we're using stdio for input, then we want to use getc()
242  * instead of fread(), to make sure we stop fetching input after
243  * each newline.
244  */
245  int yy_is_interactive;
246 
247  /* Whether we're considered to be at the beginning of a line.
248  * If so, '^' rules will be active on the next match, otherwise
249  * not.
250  */
251  int yy_at_bol;
252 
253  int yy_bs_lineno; /**< The line count. */
254  int yy_bs_column; /**< The column count. */
255 
256  /* Whether to try to fill the input buffer when we reach the
257  * end of it.
258  */
259  int yy_fill_buffer;
260 
261  int yy_buffer_status;
262 
263 #define YY_BUFFER_NEW 0
264 #define YY_BUFFER_NORMAL 1
265  /* When an EOF's been seen but there's still some text to process
266  * then we mark the buffer as YY_EOF_PENDING, to indicate that we
267  * shouldn't try reading from the input source any more. We might
268  * still have a bunch of tokens to match, though, because of
269  * possible backing-up.
270  *
271  * When we actually see the EOF, we change the status to "new"
272  * (via octave_restart()), so that the user can continue scanning by
273  * just pointing yyin at a new input file.
274  */
275 #define YY_BUFFER_EOF_PENDING 2
276 
277  };
278 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
279 
280 /* We provide macros for accessing buffer states in case in the
281  * future we want to put the buffer states in a more general
282  * "scanner state".
283  *
284  * Returns the top of the stack, or NULL.
285  */
286 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
287  ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
288  : NULL)
289 
290 /* Same as previous macro, but useful when we know that the buffer stack is not
291  * NULL or when we need an lvalue. For internal use only.
292  */
293 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
294 
295 void octave_restart (FILE *input_file ,yyscan_t yyscanner );
296 void octave__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
297 YY_BUFFER_STATE octave__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
298 void octave__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
299 void octave__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
300 void octave_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
301 void octave_pop_buffer_state (yyscan_t yyscanner );
302 
303 static void octave_ensure_buffer_stack (yyscan_t yyscanner );
304 static void octave__load_buffer_state (yyscan_t yyscanner );
305 static void octave__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
306 
307 #define YY_FLUSH_BUFFER octave__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
308 
309 YY_BUFFER_STATE octave__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
310 YY_BUFFER_STATE octave__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
311 YY_BUFFER_STATE octave__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
312 
313 void *octave_alloc (yy_size_t ,yyscan_t yyscanner );
314 void *octave_realloc (void *,yy_size_t ,yyscan_t yyscanner );
315 void octave_free (void * ,yyscan_t yyscanner );
316 
317 #define yy_new_buffer octave__create_buffer
318 
319 #define yy_set_interactive(is_interactive) \
320  { \
321  if ( ! YY_CURRENT_BUFFER ){ \
322  octave_ensure_buffer_stack (yyscanner); \
323  YY_CURRENT_BUFFER_LVALUE = \
324  octave__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
325  } \
326  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
327  }
328 
329 #define yy_set_bol(at_bol) \
330  { \
331  if ( ! YY_CURRENT_BUFFER ){\
332  octave_ensure_buffer_stack (yyscanner); \
333  YY_CURRENT_BUFFER_LVALUE = \
334  octave__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
335  } \
336  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
337  }
338 
339 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
340 
341 /* Begin user sect3 */
342 
343 #define octave_wrap(n) 1
344 #define YY_SKIP_YYWRAP
345 
346 typedef unsigned char YY_CHAR;
347 
348 typedef int yy_state_type;
349 
350 #define yytext_ptr yytext_r
351 
352 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
353 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
354 static int yy_get_next_buffer (yyscan_t yyscanner );
355 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
356 
357 /* Done after the current pattern has been matched and before the
358  * corresponding action - sets up yytext.
359  */
360 #define YY_DO_BEFORE_ACTION \
361  yyg->yytext_ptr = yy_bp; \
362  yyleng = (size_t) (yy_cp - yy_bp); \
363  yyg->yy_hold_char = *yy_cp; \
364  *yy_cp = '\0'; \
365  yyg->yy_c_buf_p = yy_cp;
366 
367 #define YY_NUM_RULES 119
368 #define YY_END_OF_BUFFER 120
369 /* This struct is not used in this scanner,
370  but its presence is necessary. */
371 struct yy_trans_info
372  {
375  };
377  { 0,
378  0, 0, 0, 0, 6, 6, 0, 0, 0, 0,
379  0, 0, 0, 0, 0, 0, 120, 118, 46, 56,
380  56, 89, 58, 118, 50, 72, 57, 94, 95, 76,
381  86, 90, 87, 96, 77, 45, 45, 59, 85, 74,
382  97, 75, 118, 55, 10, 78, 11, 79, 116, 73,
383  117, 88, 46, 118, 5, 2, 2, 5, 4, 5,
384  5, 4, 5, 5, 5, 5, 3, 5, 5, 5,
385  5, 5, 5, 3, 5, 5, 5, 5, 5, 5,
386  5, 5, 5, 5, 5, 5, 5, 6, 7, 7,
387  8, 9, 6, 1, 1, 119, 15, 15, 119, 119,
388 
389  18, 18, 18, 18, 37, 38, 38, 20, 36, 119,
390  41, 42, 42, 40, 46, 0, 56, 70, 0, 16,
391  16, 50, 0, 81, 112, 80, 100, 92, 98, 93,
392  99, 91, 62, 60, 61, 0, 63, 45, 64, 65,
393  101, 45, 45, 0, 43, 0, 83, 67, 68, 71,
394  84, 53, 0, 48, 48, 0, 102, 108, 113, 82,
395  69, 46, 0, 0, 5, 5, 2, 5, 5, 5,
396  5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
397  5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
398  5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
399 
400  5, 5, 5, 5, 5, 5, 6, 7, 6, 1,
401  0, 15, 15, 15, 0, 0, 0, 0, 0, 0,
402  18, 0, 17, 17, 37, 38, 19, 0, 35, 35,
403  34, 34, 35, 21, 23, 24, 25, 26, 27, 28,
404  29, 35, 41, 42, 39, 16, 51, 109, 66, 105,
405  103, 104, 0, 106, 0, 107, 110, 44, 45, 0,
406  45, 45, 114, 115, 53, 0, 0, 49, 49, 0,
407  12, 12, 5, 5, 5, 5, 5, 5, 5, 5,
408  5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
409  5, 5, 5, 5, 0, 13, 13, 0, 14, 14,
410 
411  17, 0, 0, 32, 32, 0, 0, 33, 33, 21,
412  22, 0, 51, 111, 0, 47, 47, 0, 45, 54,
413  49, 12, 5, 5, 5, 5, 5, 5, 5, 5,
414  5, 13, 14, 0, 30, 30, 0, 33, 21, 52,
415  51, 47, 54, 5, 5, 5, 0, 31, 31, 52,
416  51, 51, 5, 5, 5, 31, 0
417  } ;
418 
420  { 0,
421  1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
422  1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
423  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424  1, 2, 5, 6, 7, 8, 7, 9, 10, 11,
425  12, 13, 14, 15, 16, 17, 18, 19, 20, 20,
426  20, 20, 20, 20, 20, 21, 21, 22, 23, 24,
427  25, 26, 27, 28, 29, 29, 29, 30, 30, 29,
428  8, 8, 31, 31, 8, 8, 8, 8, 8, 8,
429  8, 8, 8, 8, 8, 8, 8, 32, 8, 8,
430  33, 34, 35, 36, 8, 1, 37, 38, 29, 30,
431 
432  30, 39, 8, 8, 31, 31, 8, 8, 8, 40,
433  8, 8, 8, 41, 8, 42, 8, 43, 8, 44,
434  8, 8, 45, 46, 47, 48, 1, 1, 1, 1,
435  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
436  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
439  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
441  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 
443  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
444  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
445  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
446  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
447  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
448  1, 1, 1, 1, 1
449  } ;
450 
452  { 0,
453  1, 1, 2, 3, 1, 4, 1, 5, 1, 6,
454  1, 1, 1, 1, 7, 1, 8, 1, 9, 9,
455  9, 1, 7, 1, 1, 1, 1, 10, 11, 11,
456  5, 5, 1, 4, 1, 1, 11, 11, 11, 5,
457  5, 5, 5, 5, 1, 1, 1, 1
458  } ;
459 
461  { 0,
462  0, 47, 54, 101, 102, 107, 809, 808, 47, 113,
463  117, 121, 123, 127, 131, 135, 811, 1250, 105, 1250,
464  807, 784, 1250, 49, 780, 123, 1250, 1250, 1250, 130,
465  122, 1250, 97, 152, 782, 172, 164, 1250, 1250, 126,
466  781, 127, 0, 1250, 1250, 172, 1250, 780, 1250, 121,
467  1250, 779, 156, 156, 801, 1250, 799, 162, 1250, 215,
468  196, 1250, 799, 798, 194, 197, 1250, 204, 258, 175,
469  293, 146, 797, 1250, 206, 207, 212, 336, 796, 795,
470  259, 794, 208, 793, 223, 783, 216, 263, 1250, 781,
471  1250, 1250, 278, 1250, 780, 209, 1250, 223, 279, 246,
472 
473  1250, 294, 779, 236, 0, 1250, 774, 770, 757, 379,
474  0, 1250, 770, 762, 295, 284, 1250, 1250, 286, 1250,
475  295, 743, 0, 1250, 1250, 745, 1250, 1250, 1250, 1250,
476  1250, 1250, 290, 744, 743, 750, 741, 286, 737, 736,
477  1250, 414, 301, 314, 1250, 0, 735, 1250, 1250, 1250,
478  734, 741, 338, 1250, 737, 305, 1250, 1250, 1250, 1250,
479  1250, 341, 343, 347, 736, 728, 1250, 721, 0, 443,
480  709, 694, 226, 635, 616, 598, 584, 579, 560, 359,
481  302, 327, 309, 334, 383, 337, 362, 555, 486, 325,
482  391, 547, 521, 369, 545, 541, 510, 390, 553, 351,
483 
484  426, 506, 501, 496, 492, 460, 388, 1250, 389, 1250,
485  397, 1250, 405, 1250, 435, 422, 450, 453, 429, 443,
486  1250, 455, 1250, 457, 0, 1250, 1250, 423, 1250, 461,
487  1250, 403, 467, 457, 1250, 1250, 1250, 1250, 1250, 1250,
488  1250, 0, 0, 1250, 1250, 1250, 590, 1250, 372, 1250,
489  1250, 1250, 475, 1250, 481, 1250, 1250, 1250, 494, 470,
490  490, 358, 1250, 1250, 353, 0, 489, 1250, 515, 524,
491  1250, 526, 634, 361, 441, 358, 354, 317, 529, 298,
492  585, 271, 265, 262, 535, 535, 544, 211, 222, 213,
493  0, 675, 685, 532, 564, 1250, 535, 574, 1250, 576,
494 
495  1250, 610, 688, 1250, 179, 585, 599, 1250, 604, 596,
496  0, 0, 712, 1250, 620, 1250, 622, 665, 678, 0,
497  1250, 1250, 749, 178, 786, 154, 722, 699, 708, 744,
498  823, 1250, 1250, 732, 1250, 115, 690, 1250, 1250, 0,
499  860, 1250, 0, 897, 934, 0, 718, 1250, 744, 0,
500  0, 0, 0, 0, 0, 1250, 1250, 978, 989, 1000,
501  1011, 1022, 1033, 1040, 1047, 1058, 1069, 1080, 1091, 1102,
502  1113, 1120, 1123, 1130, 1141, 1152, 1163, 1166, 1177, 1188,
503  1195, 1206, 1213, 1220, 1231, 1238
504  } ;
505 
507  { 0,
508  357, 1, 357, 3, 1, 1, 358, 358, 359, 359,
509  360, 360, 361, 361, 362, 362, 357, 357, 357, 357,
510  357, 357, 357, 363, 364, 357, 357, 357, 357, 357,
511  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
512  357, 357, 365, 357, 357, 357, 357, 357, 357, 357,
513  357, 357, 357, 363, 366, 357, 357, 366, 357, 366,
514  366, 357, 366, 366, 366, 366, 357, 366, 366, 366,
515  366, 71, 366, 357, 366, 366, 366, 366, 366, 366,
516  366, 366, 366, 366, 366, 366, 366, 357, 357, 357,
517  357, 357, 357, 357, 357, 367, 357, 367, 367, 367,
518 
519  357, 357, 357, 368, 369, 357, 357, 357, 357, 370,
520  371, 357, 357, 357, 357, 363, 357, 357, 363, 357,
521  363, 364, 372, 357, 357, 357, 357, 357, 357, 357,
522  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
523  357, 357, 357, 357, 357, 373, 357, 357, 357, 357,
524  357, 374, 357, 357, 357, 375, 357, 357, 357, 357,
525  357, 357, 363, 363, 366, 357, 357, 366, 60, 78,
526  366, 366, 366, 366, 366, 366, 366, 366, 366, 366,
527  366, 366, 366, 366, 366, 366, 366, 366, 366, 71,
528  366, 366, 366, 366, 366, 366, 366, 366, 193, 357,
529 
530  376, 366, 366, 366, 366, 366, 357, 357, 357, 357,
531  367, 357, 367, 357, 367, 367, 367, 367, 357, 368,
532  357, 368, 357, 368, 369, 357, 357, 357, 357, 357,
533  357, 357, 377, 357, 357, 357, 357, 357, 357, 357,
534  357, 378, 371, 357, 357, 357, 379, 357, 357, 357,
535  357, 357, 380, 357, 357, 357, 357, 357, 357, 357,
536  357, 373, 357, 357, 374, 381, 375, 357, 375, 363,
537  357, 363, 357, 366, 366, 366, 366, 366, 382, 366,
538  366, 366, 366, 366, 189, 366, 366, 193, 366, 366,
539  199, 78, 376, 375, 367, 357, 367, 367, 357, 367,
540 
541  357, 357, 357, 357, 357, 377, 377, 357, 377, 357,
542  378, 383, 379, 357, 380, 357, 380, 357, 357, 384,
543  357, 357, 78, 383, 273, 366, 382, 380, 366, 366,
544  78, 357, 357, 357, 357, 357, 385, 357, 357, 386,
545  379, 357, 384, 78, 273, 331, 385, 357, 385, 386,
546  341, 341, 344, 345, 345, 357, 0, 357, 357, 357,
547  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
548  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
549  357, 357, 357, 357, 357, 357
550  } ;
551 
553  { 0,
554  18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
555  28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
556  37, 38, 39, 40, 41, 42, 43, 44, 25, 25,
557  25, 25, 45, 46, 47, 48, 25, 25, 25, 25,
558  25, 25, 25, 25, 49, 50, 51, 52, 53, 97,
559  98, 120, 121, 54, 55, 19, 56, 57, 58, 59,
560  24, 60, 61, 62, 63, 64, 65, 66, 67, 68,
561  69, 70, 71, 72, 72, 73, 74, 75, 76, 77,
562  78, 79, 60, 60, 60, 60, 80, 81, 82, 83,
563  60, 60, 60, 60, 60, 60, 60, 60, 84, 85,
564 
565  86, 87, 53, 88, 89, 90, 115, 54, 93, 89,
566  90, 116, 130, 54, 99, 97, 98, 335, 102, 100,
567  103, 131, 102, 104, 103, 106, 107, 104, 108, 106,
568  107, 124, 108, 112, 113, 128, 91, 112, 113, 109,
569  114, 91, 126, 109, 114, 159, 129, 125, 92, 147,
570  148, 150, 151, 92, 127, 166, 110, 162, 120, 121,
571  110, 132, 163, 166, 133, 134, 160, 135, 136, 137,
572  138, 138, 138, 153, 154, 155, 166, 165, 156, 166,
573  142, 304, 143, 143, 143, 139, 168, 140, 142, 165,
574  143, 143, 143, 144, 145, 166, 157, 166, 166, 188,
575 
576  164, 144, 145, 146, 171, 166, 173, 166, 166, 166,
577  175, 212, 213, 166, 166, 146, 166, 166, 174, 177,
578  172, 176, 169, 166, 166, 214, 213, 166, 178, 194,
579  195, 196, 203, 169, 169, 169, 197, 198, 223, 224,
580  206, 192, 170, 169, 169, 169, 169, 204, 212, 213,
581  274, 169, 169, 169, 169, 169, 169, 169, 169, 166,
582  200, 154, 155, 166, 207, 201, 166, 179, 205, 116,
583  180, 181, 166, 182, 183, 184, 185, 185, 185, 209,
584  215, 212, 213, 202, 163, 216, 120, 121, 120, 121,
585  217, 186, 218, 187, 166, 219, 115, 246, 121, 166,
586 
587  220, 116, 249, 166, 138, 138, 138, 268, 269, 189,
588  166, 190, 190, 190, 250, 255, 145, 142, 166, 143,
589  143, 143, 191, 192, 193, 279, 277, 260, 166, 260,
590  144, 145, 261, 261, 261, 166, 193, 166, 166, 153,
591  154, 155, 162, 199, 156, 120, 121, 163, 270, 271,
592  272, 278, 200, 154, 155, 166, 165, 156, 280, 166,
593  166, 282, 166, 166, 199, 199, 199, 199, 165, 266,
594  166, 275, 199, 199, 199, 199, 199, 199, 199, 199,
595  230, 231, 232, 276, 166, 233, 283, 164, 145, 207,
596  209, 166, 166, 289, 116, 163, 314, 234, 234, 212,
597 
598  213, 185, 185, 185, 286, 231, 286, 214, 213, 287,
599  287, 287, 281, 192, 290, 235, 236, 237, 238, 239,
600  240, 241, 242, 258, 212, 213, 258, 294, 268, 269,
601  219, 258, 259, 259, 259, 220, 215, 212, 213, 302,
602  267, 216, 166, 144, 145, 223, 224, 258, 267, 258,
603  273, 295, 296, 297, 298, 299, 300, 223, 224, 301,
604  224, 166, 303, 304, 305, 326, 217, 306, 218, 308,
605  309, 273, 273, 273, 273, 310, 310, 316, 317, 273,
606  273, 273, 273, 273, 273, 273, 273, 166, 261, 261,
607  261, 268, 269, 166, 318, 284, 318, 166, 284, 319,
608 
609  319, 319, 166, 284, 285, 285, 285, 166, 261, 261,
610  261, 166, 259, 259, 259, 191, 192, 321, 269, 284,
611  145, 284, 166, 144, 145, 270, 271, 272, 322, 121,
612  328, 316, 317, 294, 268, 269, 166, 332, 213, 288,
613  288, 288, 166, 315, 165, 166, 166, 165, 166, 288,
614  288, 315, 165, 287, 287, 287, 166, 288, 288, 288,
615  291, 166, 287, 287, 287, 295, 296, 297, 165, 292,
616  165, 291, 291, 291, 192, 298, 299, 300, 333, 213,
617  166, 291, 291, 291, 291, 166, 166, 308, 309, 291,
618  291, 291, 291, 291, 291, 291, 291, 313, 329, 166,
619 
620  329, 308, 309, 330, 330, 330, 338, 309, 313, 313,
621  313, 334, 335, 336, 339, 339, 337, 166, 313, 313,
622  313, 313, 316, 317, 342, 317, 313, 313, 313, 313,
623  313, 313, 313, 313, 323, 324, 166, 312, 323, 323,
624  323, 325, 323, 323, 323, 323, 323, 323, 312, 323,
625  323, 323, 325, 325, 325, 323, 312, 323, 323, 323,
626  323, 323, 325, 325, 325, 325, 323, 323, 323, 323,
627  325, 325, 325, 325, 325, 325, 325, 325, 323, 323,
628  323, 323, 331, 319, 319, 319, 294, 268, 269, 303,
629  304, 305, 348, 349, 306, 166, 319, 319, 319, 267,
630 
631  328, 316, 317, 331, 331, 331, 331, 267, 145, 166,
632  166, 331, 331, 331, 331, 331, 331, 331, 331, 341,
633  348, 349, 166, 328, 316, 317, 330, 330, 330, 166,
634  313, 313, 313, 334, 335, 336, 315, 166, 337, 154,
635  341, 341, 341, 341, 315, 166, 356, 349, 341, 341,
636  341, 341, 341, 341, 341, 341, 344, 266, 264, 263,
637  257, 256, 330, 330, 330, 254, 253, 252, 251, 248,
638  123, 245, 244, 228, 192, 227, 226, 344, 344, 344,
639  344, 221, 210, 208, 166, 344, 344, 344, 344, 344,
640  344, 344, 344, 345, 166, 166, 166, 166, 166, 166,
641 
642  166, 167, 166, 161, 158, 149, 141, 123, 118, 117,
643  357, 95, 95, 357, 345, 345, 345, 345, 357, 357,
644  357, 357, 345, 345, 345, 345, 345, 345, 345, 345,
645  346, 357, 357, 357, 357, 357, 357, 357, 357, 357,
646  357, 346, 346, 346, 357, 357, 357, 357, 357, 357,
647  357, 346, 346, 346, 346, 357, 357, 357, 357, 346,
648  346, 346, 346, 346, 346, 346, 346, 351, 357, 357,
649  357, 357, 357, 357, 357, 357, 357, 357, 352, 352,
650  352, 357, 357, 357, 357, 357, 357, 357, 351, 351,
651  351, 351, 357, 357, 357, 357, 351, 351, 351, 351,
652 
653  351, 351, 351, 351, 353, 357, 357, 357, 357, 357,
654  357, 357, 357, 357, 357, 353, 353, 353, 357, 357,
655  357, 357, 357, 357, 357, 353, 353, 353, 353, 357,
656  357, 357, 357, 353, 353, 353, 353, 353, 353, 353,
657  353, 354, 357, 357, 357, 357, 357, 357, 357, 357,
658  357, 357, 355, 355, 355, 357, 357, 357, 357, 357,
659  357, 357, 354, 354, 354, 354, 357, 357, 357, 357,
660  354, 354, 354, 354, 354, 354, 354, 354, 94, 94,
661  94, 94, 94, 94, 94, 94, 94, 94, 94, 96,
662  96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
663 
664  101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
665  101, 105, 105, 105, 105, 105, 105, 105, 105, 105,
666  105, 105, 111, 111, 111, 111, 111, 111, 111, 111,
667  111, 111, 111, 119, 119, 119, 119, 119, 119, 119,
668  119, 119, 119, 119, 122, 357, 357, 357, 122, 122,
669  122, 152, 357, 357, 357, 357, 357, 152, 165, 357,
670  357, 165, 165, 165, 357, 165, 165, 165, 165, 211,
671  211, 211, 211, 211, 211, 211, 211, 211, 211, 211,
672  222, 222, 222, 222, 222, 222, 222, 222, 222, 222,
673  222, 225, 357, 357, 357, 225, 225, 225, 357, 225,
674 
675  225, 225, 229, 229, 229, 229, 229, 229, 229, 229,
676  229, 229, 229, 243, 357, 357, 243, 243, 357, 243,
677  243, 243, 243, 243, 247, 357, 357, 357, 357, 357,
678  247, 262, 357, 262, 265, 357, 357, 265, 265, 357,
679  265, 267, 267, 267, 267, 267, 267, 267, 267, 267,
680  267, 267, 293, 293, 293, 293, 293, 293, 293, 293,
681  293, 293, 293, 307, 307, 307, 307, 307, 307, 307,
682  307, 307, 307, 307, 311, 357, 311, 312, 357, 312,
683  312, 312, 312, 312, 312, 312, 312, 312, 315, 315,
684  315, 315, 315, 315, 315, 315, 315, 315, 315, 320,
685 
686  357, 357, 357, 357, 357, 320, 327, 327, 327, 327,
687  327, 327, 327, 327, 327, 327, 327, 340, 357, 357,
688  357, 357, 357, 340, 343, 357, 357, 357, 343, 357,
689  343, 347, 347, 347, 347, 347, 347, 347, 347, 347,
690  347, 347, 350, 357, 357, 357, 350, 357, 350, 17,
691  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
692  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
693  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
694  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
695  357, 357, 357, 357, 357, 357, 357, 357
696 
697  } ;
698 
700  { 0,
701  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
702  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
703  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
704  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705  1, 1, 1, 1, 1, 1, 1, 1, 2, 9,
706  9, 24, 24, 2, 3, 3, 3, 3, 3, 3,
707  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
708  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
709  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
710  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
711 
712  3, 3, 4, 5, 5, 5, 19, 4, 6, 6,
713  6, 19, 33, 6, 10, 10, 10, 336, 11, 10,
714  11, 33, 12, 11, 12, 13, 13, 12, 13, 14,
715  14, 26, 14, 15, 15, 31, 5, 16, 16, 13,
716  15, 6, 30, 14, 16, 50, 31, 26, 5, 40,
717  40, 42, 42, 6, 30, 326, 13, 53, 54, 54,
718  14, 34, 53, 58, 34, 34, 50, 34, 34, 34,
719  34, 34, 34, 46, 46, 46, 70, 72, 46, 324,
720  37, 305, 37, 37, 37, 34, 58, 34, 36, 72,
721  36, 36, 36, 37, 37, 65, 46, 61, 66, 70,
722 
723  54, 36, 36, 36, 61, 68, 65, 75, 76, 83,
724  66, 96, 96, 77, 290, 36, 60, 87, 65, 68,
725  61, 66, 60, 289, 85, 98, 98, 173, 68, 75,
726  75, 76, 83, 60, 60, 60, 77, 77, 104, 104,
727  87, 288, 60, 60, 60, 60, 60, 85, 100, 100,
728  173, 60, 60, 60, 60, 60, 60, 60, 60, 69,
729  81, 81, 81, 284, 88, 81, 283, 69, 85, 88,
730  69, 69, 282, 69, 69, 69, 69, 69, 69, 93,
731  99, 99, 99, 81, 93, 99, 116, 116, 119, 119,
732  100, 69, 100, 69, 71, 102, 115, 121, 121, 280,
733 
734  102, 115, 133, 181, 138, 138, 138, 156, 156, 71,
735  183, 71, 71, 71, 133, 138, 138, 143, 278, 143,
736  143, 143, 71, 71, 71, 183, 181, 144, 182, 144,
737  143, 143, 144, 144, 144, 184, 71, 78, 186, 153,
738  153, 153, 162, 78, 153, 163, 163, 162, 164, 164,
739  164, 182, 200, 200, 200, 277, 190, 200, 184, 276,
740  180, 186, 274, 187, 78, 78, 78, 78, 190, 265,
741  194, 180, 78, 78, 78, 78, 78, 78, 78, 78,
742  110, 110, 110, 180, 185, 110, 187, 163, 262, 207,
743  209, 198, 191, 194, 207, 209, 249, 110, 110, 211,
744 
745  211, 185, 185, 185, 191, 232, 191, 213, 213, 191,
746  191, 191, 185, 185, 198, 110, 110, 110, 110, 110,
747  110, 110, 110, 142, 216, 216, 142, 201, 201, 201,
748  219, 142, 142, 142, 142, 219, 215, 215, 215, 228,
749  201, 215, 275, 142, 142, 220, 220, 142, 201, 142,
750  170, 217, 217, 217, 218, 218, 218, 222, 222, 224,
751  224, 206, 230, 230, 230, 275, 216, 230, 216, 233,
752  233, 170, 170, 170, 170, 234, 234, 253, 253, 170,
753  170, 170, 170, 170, 170, 170, 170, 189, 260, 260,
754  260, 267, 267, 205, 255, 189, 255, 204, 189, 255,
755 
756  255, 255, 203, 189, 189, 189, 189, 202, 261, 261,
757  261, 197, 259, 259, 259, 189, 189, 269, 269, 189,
758  261, 189, 193, 259, 259, 270, 270, 270, 272, 272,
759  279, 279, 279, 294, 294, 294, 286, 297, 297, 193,
760  193, 193, 196, 279, 285, 287, 195, 285, 192, 193,
761  193, 279, 285, 286, 286, 286, 188, 193, 193, 193,
762  199, 179, 287, 287, 287, 295, 295, 295, 285, 199,
763  285, 199, 199, 199, 287, 298, 298, 298, 300, 300,
764  178, 199, 199, 199, 199, 177, 281, 306, 306, 199,
765  199, 199, 199, 199, 199, 199, 199, 247, 281, 176,
766 
767  281, 307, 307, 281, 281, 281, 309, 309, 247, 247,
768  247, 302, 302, 302, 310, 310, 302, 175, 247, 247,
769  247, 247, 315, 315, 317, 317, 247, 247, 247, 247,
770  247, 247, 247, 247, 273, 273, 174, 273, 273, 273,
771  273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
772  273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
773  273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
774  273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
775  273, 273, 292, 318, 318, 318, 293, 293, 293, 303,
776  303, 303, 337, 337, 303, 172, 319, 319, 319, 293,
777 
778  328, 328, 328, 292, 292, 292, 292, 293, 319, 329,
779  171, 292, 292, 292, 292, 292, 292, 292, 292, 313,
780  347, 347, 168, 327, 327, 327, 329, 329, 329, 166,
781  313, 313, 313, 334, 334, 334, 327, 165, 334, 155,
782  313, 313, 313, 313, 327, 330, 349, 349, 313, 313,
783  313, 313, 313, 313, 313, 313, 323, 152, 151, 147,
784  140, 139, 330, 330, 330, 137, 136, 135, 134, 126,
785  122, 114, 113, 109, 330, 108, 107, 323, 323, 323,
786  323, 103, 95, 90, 86, 323, 323, 323, 323, 323,
787  323, 323, 323, 325, 84, 82, 80, 79, 73, 64,
788 
789  63, 57, 55, 52, 48, 41, 35, 25, 22, 21,
790  17, 8, 7, 0, 325, 325, 325, 325, 0, 0,
791  0, 0, 325, 325, 325, 325, 325, 325, 325, 325,
792  331, 0, 0, 0, 0, 0, 0, 0, 0, 0,
793  0, 331, 331, 331, 0, 0, 0, 0, 0, 0,
794  0, 331, 331, 331, 331, 0, 0, 0, 0, 331,
795  331, 331, 331, 331, 331, 331, 331, 341, 0, 0,
796  0, 0, 0, 0, 0, 0, 0, 0, 341, 341,
797  341, 0, 0, 0, 0, 0, 0, 0, 341, 341,
798  341, 341, 0, 0, 0, 0, 341, 341, 341, 341,
799 
800  341, 341, 341, 341, 344, 0, 0, 0, 0, 0,
801  0, 0, 0, 0, 0, 344, 344, 344, 0, 0,
802  0, 0, 0, 0, 0, 344, 344, 344, 344, 0,
803  0, 0, 0, 344, 344, 344, 344, 344, 344, 344,
804  344, 345, 0, 0, 0, 0, 0, 0, 0, 0,
805  0, 0, 345, 345, 345, 0, 0, 0, 0, 0,
806  0, 0, 345, 345, 345, 345, 0, 0, 0, 0,
807  345, 345, 345, 345, 345, 345, 345, 345, 358, 358,
808  358, 358, 358, 358, 358, 358, 358, 358, 358, 359,
809  359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
810 
811  360, 360, 360, 360, 360, 360, 360, 360, 360, 360,
812  360, 361, 361, 361, 361, 361, 361, 361, 361, 361,
813  361, 361, 362, 362, 362, 362, 362, 362, 362, 362,
814  362, 362, 362, 363, 363, 363, 363, 363, 363, 363,
815  363, 363, 363, 363, 364, 0, 0, 0, 364, 364,
816  364, 365, 0, 0, 0, 0, 0, 365, 366, 0,
817  0, 366, 366, 366, 0, 366, 366, 366, 366, 367,
818  367, 367, 367, 367, 367, 367, 367, 367, 367, 367,
819  368, 368, 368, 368, 368, 368, 368, 368, 368, 368,
820  368, 369, 0, 0, 0, 369, 369, 369, 0, 369,
821 
822  369, 369, 370, 370, 370, 370, 370, 370, 370, 370,
823  370, 370, 370, 371, 0, 0, 371, 371, 0, 371,
824  371, 371, 371, 371, 372, 0, 0, 0, 0, 0,
825  372, 373, 0, 373, 374, 0, 0, 374, 374, 0,
826  374, 375, 375, 375, 375, 375, 375, 375, 375, 375,
827  375, 375, 376, 376, 376, 376, 376, 376, 376, 376,
828  376, 376, 376, 377, 377, 377, 377, 377, 377, 377,
829  377, 377, 377, 377, 378, 0, 378, 379, 0, 379,
830  379, 379, 379, 379, 379, 379, 379, 379, 380, 380,
831  380, 380, 380, 380, 380, 380, 380, 380, 380, 381,
832 
833  0, 0, 0, 0, 0, 381, 382, 382, 382, 382,
834  382, 382, 382, 382, 382, 382, 382, 383, 0, 0,
835  0, 0, 0, 383, 384, 0, 0, 0, 384, 0,
836  384, 385, 385, 385, 385, 385, 385, 385, 385, 385,
837  385, 385, 386, 0, 0, 0, 386, 0, 386, 357,
838  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
839  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
840  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
841  357, 357, 357, 357, 357, 357, 357, 357, 357, 357,
842  357, 357, 357, 357, 357, 357, 357, 357
843 
844  } ;
845 
846 /* The intent behind this definition is that it'll catch
847  * any uses of REJECT which flex missed.
848  */
849 #define REJECT reject_used_but_not_detected
850 #define yymore() yymore_used_but_not_detected
851 #define YY_MORE_ADJ 0
852 #define YY_RESTORE_YY_MORE_OFFSET
853 #line 1 "../../libinterp/parse-tree/lex.ll"
854 /*
855 
856 Copyright (C) 1993-2013 John W. Eaton
857 
858 This file is part of Octave.
859 
860 Octave is free software; you can redistribute it and/or modify it
861 under the terms of the GNU General Public License as published by the
862 Free Software Foundation; either version 3 of the License, or (at your
863 option) any later version.
864 
865 Octave is distributed in the hope that it will be useful, but WITHOUT
866 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
867 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
868 for more details.
869 
870 You should have received a copy of the GNU General Public License
871 along with Octave; see the file COPYING. If not, see
872 <http://www.gnu.org/licenses/>.
873 
874 */
875 /*
876 We are using the pure parser interface and the reentrant lexer
877 interface but the Octave parser and lexer are NOT properly
878 reentrant because both still use many global variables. It should be
879 safe to create a parser object and call it while anotehr parser
880 object is active (to parse a callback function while the main
881 interactive parser is waiting for input, for example) if you take
882 care to properly save and restore (typically with an unwind_protect
883 object) relevant global values before and after the nested call.
884 */
885 
886 
887 
888 
889 
890 
891 
892 
893 #line 58 "../../libinterp/parse-tree/lex.ll"
894 
895 #include <cctype>
896 #include <cstring>
897 
898 #include <iostream>
899 #include <set>
900 #include <sstream>
901 #include <string>
902 #include <stack>
903 
904 #include <sys/types.h>
905 #include <unistd.h>
906 
907 #include "cmd-edit.h"
908 #include "quit.h"
909 #include "lo-mappers.h"
910 
911 // These would be alphabetical, but oct-parse.h must be included before
912 // oct-gperf.h and oct-parse.h must be included after token.h and the tree
913 // class declarations. We can't include oct-parse.h in oct-gperf.h
914 // because it may not be protected to allow it to be included multiple
915 // times.
916 
917 #include "Cell.h"
918 #include "comment-list.h"
919 #include "defun.h"
920 #include "error.h"
921 #include "gripes.h"
922 #include "input.h"
923 #include "lex.h"
924 #include "ov.h"
925 #include "parse.h"
926 #include "pt-all.h"
927 #include "symtab.h"
928 #include "token.h"
929 #include "toplev.h"
930 #include "utils.h"
931 #include "variables.h"
932 #include <oct-parse.h>
933 #include <oct-gperf.h>
934 
935 #if defined (GNULIB_NAMESPACE)
936 // Calls to the following functions appear in the generated output from
937 // flex without the namespace tag. Redefine them so we will use them
938 // via the gnulib namespace.
939 #define fprintf GNULIB_NAMESPACE::fprintf
940 #define fwrite GNULIB_NAMESPACE::fwrite
941 #define isatty GNULIB_NAMESPACE::isatty
942 #define malloc GNULIB_NAMESPACE::malloc
943 #define realloc GNULIB_NAMESPACE::realloc
944 #endif
945 
946 #if ! (defined (FLEX_SCANNER) \
947  && defined (YY_FLEX_MAJOR_VERSION) && YY_FLEX_MAJOR_VERSION >= 2 \
948  && defined (YY_FLEX_MINOR_VERSION) && YY_FLEX_MINOR_VERSION >= 5)
949 #error lex.l requires flex version 2.5.4 or later
950 #endif
951 
952 #define YY_EXTRA_TYPE octave_base_lexer *
953 #define curr_lexer yyextra
954 
955 // Arrange to get input via readline.
956 
957 #ifdef YY_INPUT
958 #undef YY_INPUT
959 #endif
960 #define YY_INPUT(buf, result, max_size) \
961  result = curr_lexer->fill_flex_buffer (buf, max_size)
962 
963 // Try to avoid crashing out completely on fatal scanner errors.
964 
965 #ifdef YY_FATAL_ERROR
966 #undef YY_FATAL_ERROR
967 #endif
968 #define YY_FATAL_ERROR(msg) \
969  (octave_get_extra (yyscanner))->fatal_error (msg)
970 
971 #define CMD_OR_OP(PATTERN, TOK, COMPAT) \
972  \
973  do \
974  { \
975  curr_lexer->lexer_debug (PATTERN); \
976  \
977  if (curr_lexer->looks_like_command_arg ()) \
978  { \
979  yyless (0); \
980  curr_lexer->push_start_state (COMMAND_START); \
981  } \
982  else \
983  { \
984  return curr_lexer->handle_op_internal (TOK, false, COMPAT); \
985  } \
986  } \
987  while (0)
988 
989 #define CMD_OR_COMPUTED_ASSIGN_OP(PATTERN, TOK) \
990  \
991  do \
992  { \
993  curr_lexer->lexer_debug (PATTERN); \
994  \
995  if (curr_lexer->previous_token_may_be_command ()) \
996  { \
997  yyless (0); \
998  curr_lexer->push_start_state (COMMAND_START); \
999  } \
1000  else \
1001  { \
1002  return curr_lexer->handle_incompatible_op (PATTERN, TOK, false); \
1003  } \
1004  } \
1005  while (0)
1006 
1007 #define CMD_OR_UNARY_OP(PATTERN, TOK, COMPAT) \
1008  \
1009  do \
1010  { \
1011  curr_lexer->lexer_debug (PATTERN); \
1012  \
1013  if (curr_lexer->previous_token_may_be_command ()) \
1014  { \
1015  if (curr_lexer->looks_like_command_arg ()) \
1016  { \
1017  yyless (0); \
1018  curr_lexer->push_start_state (COMMAND_START); \
1019  } \
1020  else \
1021  { \
1022  return curr_lexer->handle_op_internal (TOK, false, COMPAT); \
1023  } \
1024  } \
1025  else \
1026  { \
1027  int tok \
1028  = (COMPAT \
1029  ? curr_lexer->handle_unary_op (TOK) \
1030  : curr_lexer->handle_incompatible_unary_op (TOK)); \
1031  \
1032  if (tok < 0) \
1033  { \
1034  yyless (0); \
1035  curr_lexer->xunput (','); \
1036  /* Adjust for comma that was not really in the input stream. */ \
1037  curr_lexer->current_input_column--; \
1038  } \
1039  else \
1040  { \
1041  return tok; \
1042  } \
1043  } \
1044  } \
1045  while (0)
1046 
1047 // We can't rely on the trick used elsewhere of sticking ASCII 1 in
1048 // the input buffer and recognizing it as a special case because ASCII
1049 // 1 is a valid character for a character string. If we are at the
1050 // end of the buffer, ask for more input. If we are at the end of the
1051 // file, deal with it. Otherwise, just keep going with the text from
1052 // the current buffer.
1053 #define HANDLE_STRING_CONTINUATION \
1054  do \
1055  { \
1056  curr_lexer->decrement_promptflag (); \
1057  curr_lexer->input_line_number++; \
1058  curr_lexer->current_input_column = 1; \
1059  \
1060  if (curr_lexer->is_push_lexer ()) \
1061  { \
1062  if (curr_lexer->at_end_of_buffer ()) \
1063  return -1; \
1064  \
1065  if (curr_lexer->at_end_of_file ()) \
1066  return curr_lexer->handle_end_of_input (); \
1067  } \
1068  } \
1069  while (0)
1070 
1071 
1072 static bool Vdisplay_tokens = false;
1073 
1074 static unsigned int Vtoken_count = 0;
1075 
1076 // Internal variable for lexer debugging state.
1077 static bool lexer_debug_flag = false;
1078 
1079 // Forward declarations for functions defined at the bottom of this
1080 // file that are needed inside the lexer actions.
1081 
1082 static std::string strip_trailing_whitespace (char *s);
1083 
1084 #line 1085 "parse-tree/lex.cc"
1085 
1086 #define INITIAL 0
1087 #define COMMAND_START 1
1088 #define MATRIX_START 2
1089 #define INPUT_FILE_START 3
1090 #define BLOCK_COMMENT_START 4
1091 #define LINE_COMMENT_START 5
1092 #define DQ_STRING_START 6
1093 #define SQ_STRING_START 7
1094 
1095 #ifndef YY_NO_UNISTD_H
1096 /* Special case for "unistd.h", since it is non-ANSI. We include it way
1097  * down here because we want the user's section 1 to have been scanned first.
1098  * The user has a chance to override it with an option.
1099  */
1100 #include <unistd.h>
1101 #endif
1102 
1103 #ifndef YY_EXTRA_TYPE
1104 #define YY_EXTRA_TYPE void *
1105 #endif
1106 
1107 /* Holds the entire state of the reentrant scanner. */
1108 struct yyguts_t
1109  {
1110 
1111  /* User-defined. Not touched by flex. */
1113 
1114  /* The rest are the same as the globals declared in the non-reentrant scanner. */
1115  FILE *yyin_r, *yyout_r;
1116  size_t yy_buffer_stack_top; /**< index of top of stack. */
1117  size_t yy_buffer_stack_max; /**< capacity of stack. */
1118  YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
1119  char yy_hold_char;
1120  int yy_n_chars;
1121  int yyleng_r;
1122  char *yy_c_buf_p;
1123  int yy_init;
1124  int yy_start;
1126  int yy_start_stack_ptr;
1128  int *yy_start_stack;
1130  char* yy_last_accepting_cpos;
1131 
1132  int yylineno_r;
1133  int yy_flex_debug_r;
1134 
1135  char *yytext_r;
1136  int yy_more_flag;
1137  int yy_more_len;
1138 
1139  YYSTYPE * yylval_r;
1140 
1141  }; /* end struct yyguts_t */
1142 
1143 static int yy_init_globals (yyscan_t yyscanner );
1144 
1145  /* This must go here because YYSTYPE and YYLTYPE are included
1146  * from bison output in section 1.*/
1147  # define yylval yyg->yylval_r
1148 
1150 
1152 
1153 /* Accessor methods to globals.
1154  These are made visible to non-reentrant scanners for convenience. */
1155 
1156 int octave_lex_destroy (yyscan_t yyscanner );
1157 
1158 int octave_get_debug (yyscan_t yyscanner );
1159 
1160 void octave_set_debug (int debug_flag ,yyscan_t yyscanner );
1161 
1163 
1164 void octave_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
1165 
1166 FILE *octave_get_in (yyscan_t yyscanner );
1167 
1168 void octave_set_in (FILE * in_str ,yyscan_t yyscanner );
1169 
1170 FILE *octave_get_out (yyscan_t yyscanner );
1171 
1172 void octave_set_out (FILE * out_str ,yyscan_t yyscanner );
1173 
1174 int octave_get_leng (yyscan_t yyscanner );
1175 
1176 char *octave_get_text (yyscan_t yyscanner );
1177 
1178 int octave_get_lineno (yyscan_t yyscanner );
1179 
1180 void octave_set_lineno (int line_number ,yyscan_t yyscanner );
1181 
1182 int octave_get_column (yyscan_t yyscanner );
1183 
1184 void octave_set_column (int column_no ,yyscan_t yyscanner );
1185 
1186 YYSTYPE * octave_get_lval (yyscan_t yyscanner );
1187 
1188 void octave_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
1189 
1190 /* Macros after this point can all be overridden by user definitions in
1191  * section 1.
1192  */
1193 
1194 #ifndef YY_SKIP_YYWRAP
1195 #ifdef __cplusplus
1196 extern "C" int octave_wrap (yyscan_t yyscanner );
1197 #else
1198 extern int octave_wrap (yyscan_t yyscanner );
1199 #endif
1200 #endif
1201 
1202  static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
1203 
1204 #ifndef yytext_ptr
1205 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
1206 #endif
1207 
1208 #ifdef YY_NEED_STRLEN
1209 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
1210 #endif
1211 
1212 #ifndef YY_NO_INPUT
1213 
1214 #ifdef __cplusplus
1215 static int yyinput (yyscan_t yyscanner );
1216 #else
1217 static int input (yyscan_t yyscanner );
1218 #endif
1219 
1220 #endif
1221 
1222 /* Amount of stuff to slurp up with each read. */
1223 #ifndef YY_READ_BUF_SIZE
1224 #ifdef __ia64__
1225 /* On IA-64, the buffer size is 16k, not 8k */
1226 #define YY_READ_BUF_SIZE 16384
1227 #else
1228 #define YY_READ_BUF_SIZE 8192
1229 #endif /* __ia64__ */
1230 #endif
1231 
1232 /* Copy whatever the last rule matched to the standard output. */
1233 #ifndef ECHO
1234 /* This used to be an fputs(), but since the string might contain NUL's,
1235  * we now use fwrite().
1236  */
1237 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
1238 #endif
1239 
1240 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1241  * is returned in "result".
1242  */
1243 #ifndef YY_INPUT
1244 #define YY_INPUT(buf,result,max_size) \
1245  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1246  { \
1247  int c = '*'; \
1248  size_t n; \
1249  for ( n = 0; n < max_size && \
1250  (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1251  buf[n] = (char) c; \
1252  if ( c == '\n' ) \
1253  buf[n++] = (char) c; \
1254  if ( c == EOF && ferror( yyin ) ) \
1255  YY_FATAL_ERROR( "input in flex scanner failed" ); \
1256  result = n; \
1257  } \
1258  else \
1259  { \
1260  errno=0; \
1261  while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
1262  { \
1263  if( errno != EINTR) \
1264  { \
1265  YY_FATAL_ERROR( "input in flex scanner failed" ); \
1266  break; \
1267  } \
1268  errno=0; \
1269  clearerr(yyin); \
1270  } \
1271  }\
1272 \
1273 
1274 #endif
1275 
1276 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1277  * we don't want an extra ';' after the "return" because that will cause
1278  * some compilers to complain about unreachable statements.
1279  */
1280 #ifndef yyterminate
1281 #define yyterminate() return YY_NULL
1282 #endif
1283 
1284 /* Number of entries by which start-condition stack grows. */
1285 #ifndef YY_START_STACK_INCR
1286 #define YY_START_STACK_INCR 25
1287 #endif
1288 
1289 /* Report a fatal error. */
1290 #ifndef YY_FATAL_ERROR
1291 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1292 #endif
1293 
1294 /* end tables serialization structures and prototypes */
1295 
1296 /* Default declaration of generated scanner - a define so the user can
1297  * easily add parameters.
1298  */
1299 #ifndef YY_DECL
1300 #define YY_DECL_IS_OURS 1
1301 
1302 extern int octave_lex \
1303  (YYSTYPE * yylval_param ,yyscan_t yyscanner);
1304 
1305 #define YY_DECL int octave_lex \
1306  (YYSTYPE * yylval_param , yyscan_t yyscanner)
1307 #endif /* !YY_DECL */
1308 
1309 /* Code executed at the beginning of each rule, after yytext and yyleng
1310  * have been set up.
1311  */
1312 #ifndef YY_USER_ACTION
1313 #define YY_USER_ACTION
1314 #endif
1315 
1316 /* Code executed at the end of each rule. */
1317 #ifndef YY_BREAK
1318 #define YY_BREAK break;
1319 #endif
1320 
1321 #define YY_RULE_SETUP \
1322  if ( yyleng > 0 ) \
1323  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
1324  (yytext[yyleng - 1] == '\n'); \
1325  YY_USER_ACTION
1326 
1327 /** The main scanner function which does all the work.
1328  */
1330 {
1331  register yy_state_type yy_current_state;
1332  register char *yy_cp, *yy_bp;
1333  register int yy_act;
1334  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1335 
1336 #line 261 "../../libinterp/parse-tree/lex.ll"
1337 
1338 
1339 
1340 // Make script and function files start with a bogus token. This makes
1341 // the parser go down a special path.
1342 
1343 
1344 #line 1345 "parse-tree/lex.cc"
1345 
1346  yylval = yylval_param;
1347 
1348  if ( !yyg->yy_init )
1349  {
1350  yyg->yy_init = 1;
1351 
1352 #ifdef YY_USER_INIT
1353  YY_USER_INIT;
1354 #endif
1355 
1356  if ( ! yyg->yy_start )
1357  yyg->yy_start = 1; /* first start state */
1358 
1359  if ( ! yyin )
1360  yyin = stdin;
1361 
1362  if ( ! yyout )
1363  yyout = stdout;
1364 
1365  if ( ! YY_CURRENT_BUFFER ) {
1366  octave_ensure_buffer_stack (yyscanner);
1369  }
1370 
1371  octave__load_buffer_state(yyscanner );
1372  }
1373 
1374  while ( 1 ) /* loops until end-of-file is reached */
1375  {
1376  yy_cp = yyg->yy_c_buf_p;
1377 
1378  /* Support of yytext. */
1379  *yy_cp = yyg->yy_hold_char;
1380 
1381  /* yy_bp points to the position in yy_ch_buf of the start of
1382  * the current run.
1383  */
1384  yy_bp = yy_cp;
1385 
1386  yy_current_state = yyg->yy_start;
1387  yy_current_state += YY_AT_BOL();
1388 yy_match:
1389  do
1390  {
1391  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1392  if ( yy_accept[yy_current_state] )
1393  {
1394  yyg->yy_last_accepting_state = yy_current_state;
1395  yyg->yy_last_accepting_cpos = yy_cp;
1396  }
1397  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1398  {
1399  yy_current_state = (int) yy_def[yy_current_state];
1400  if ( yy_current_state >= 358 )
1401  yy_c = yy_meta[(unsigned int) yy_c];
1402  }
1403  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1404  ++yy_cp;
1405  }
1406  while ( yy_base[yy_current_state] != 1250 );
1407 
1408 yy_find_action:
1409  yy_act = yy_accept[yy_current_state];
1410  if ( yy_act == 0 )
1411  { /* have to back up */
1412  yy_cp = yyg->yy_last_accepting_cpos;
1413  yy_current_state = yyg->yy_last_accepting_state;
1414  yy_act = yy_accept[yy_current_state];
1415  }
1416 
1418 
1419 do_action: /* This label is used only to access EOF actions. */
1420 
1421  switch ( yy_act )
1422  { /* beginning of action switch */
1423  case 0: /* must back up */
1424  /* undo the effects of YY_DO_BEFORE_ACTION */
1425  *yy_cp = yyg->yy_hold_char;
1426  yy_cp = yyg->yy_last_accepting_cpos;
1427  yy_current_state = yyg->yy_last_accepting_state;
1428  goto yy_find_action;
1429 
1430 case 1:
1431 /* rule 1 can match eol */
1433 #line 268 "../../libinterp/parse-tree/lex.ll"
1434 {
1435  curr_lexer->lexer_debug ("<INPUT_FILE_START>{ANY_INCLUDING_NL}");
1436 
1437  curr_lexer->xunput (yytext[0]);
1438 
1439  // May be reset later if we see "function" or "classdef" appears
1440  // as the first token.
1441  curr_lexer->reading_script_file = true;
1442 
1443  curr_lexer->pop_start_state ();
1444 
1445  return curr_lexer->show_token (INPUT_FILE);
1446  }
1447  YY_BREAK
1448 
1449 // Help and other command-style functions.
1450 
1451 case 2:
1452 /* rule 2 can match eol */
1454 #line 286 "../../libinterp/parse-tree/lex.ll"
1455 {
1456  curr_lexer->lexer_debug ("<COMMAND_START>{NL}");
1457 
1458  curr_lexer->input_line_number++;
1459  curr_lexer->current_input_column = 1;
1460 
1461  curr_lexer->looking_for_object_index = false;
1462  curr_lexer->at_beginning_of_statement = true;
1463 
1464  curr_lexer->pop_start_state ();
1465 
1466  return curr_lexer->count_token ('\n');
1467  }
1468  YY_BREAK
1469 case 3:
1471 #line 300 "../../libinterp/parse-tree/lex.ll"
1472 {
1473  curr_lexer->lexer_debug ("<COMMAND_START>[\\;\\,]");
1474 
1475  curr_lexer->looking_for_object_index = false;
1476  curr_lexer->at_beginning_of_statement = true;
1477 
1478  curr_lexer->pop_start_state ();
1479 
1480  if (strcmp (yytext, ",") == 0)
1481  return curr_lexer->handle_token (',');
1482  else
1483  return curr_lexer->handle_token (';');
1484  }
1485  YY_BREAK
1486 case 4:
1488 #line 314 "../../libinterp/parse-tree/lex.ll"
1489 {
1490  curr_lexer->lexer_debug ("<COMMAND_START>[\\\"\\']");
1491 
1492  curr_lexer->at_beginning_of_statement = false;
1493 
1494  curr_lexer->current_input_column++;
1495 
1496  curr_lexer->begin_string (yytext[0] == '"'
1498  }
1499  YY_BREAK
1500 case 5:
1502 #line 325 "../../libinterp/parse-tree/lex.ll"
1503 {
1504  curr_lexer->lexer_debug ("<COMMAND_START>[^#% \\t\\r\\n\\;\\,\\\"\\'][^ \\t\\r\\n\\;\\,]*{S}*");
1505 
1506  std::string tok = strip_trailing_whitespace (yytext);
1507 
1508  curr_lexer->looking_for_object_index = false;
1509  curr_lexer->at_beginning_of_statement = false;
1510 
1511  return curr_lexer->handle_token (tok, SQ_STRING);
1512  }
1513  YY_BREAK
1514 case 6:
1516 #line 336 "../../libinterp/parse-tree/lex.ll"
1517 {
1518  curr_lexer->lexer_debug ("<MATRIX_START>{S}*");
1519 
1520  curr_lexer->mark_previous_token_trailing_space ();
1521  }
1522  YY_BREAK
1523 case 7:
1524 /* rule 7 can match eol */
1526 #line 342 "../../libinterp/parse-tree/lex.ll"
1527 {
1528  curr_lexer->lexer_debug ("<MATRIX_START>{NL}");
1529 
1530  curr_lexer->input_line_number++;
1531  curr_lexer->current_input_column = 1;
1532 
1533  if (curr_lexer->nesting_level.is_paren ())
1534  curr_lexer->gripe_matlab_incompatible ("bare newline inside parentheses");
1535  else
1536  {
1537  int tok = curr_lexer->previous_token_value ();
1538 
1539  if (! (tok == ';' || tok == '[' || tok == '{'))
1540  {
1541  curr_lexer->xunput (';');
1542  // Adjust for semicolon that was not really in the input stream.
1543  curr_lexer->current_input_column--;
1544  }
1545  }
1546  }
1547  YY_BREAK
1548 
1549 // For this and the next two rules, we're looking at ']', and we
1550 // need to know if the next token is '=' or '=='.
1551 //
1552 // It would have been so much easier if the delimiters were simply
1553 // different for the expression on the left hand side of the equals
1554 // operator.
1555 //
1556 // It's also a pain in the ass to decide whether to insert a comma
1557 // after seeing a ']' character...
1558 
1559 // FIXME: we need to handle block comments here.
1560 
1561 case 8:
1563 #line 377 "../../libinterp/parse-tree/lex.ll"
1564 {
1565  curr_lexer->lexer_debug ("<MATRIX_START>\\]");
1566 
1567  curr_lexer->looking_at_object_index.pop_front ();
1568 
1569  curr_lexer->looking_for_object_index = true;
1570  curr_lexer->at_beginning_of_statement = false;
1571 
1572  curr_lexer->handle_close_bracket (']');
1573 
1574  return curr_lexer->count_token (']');
1575  }
1576  YY_BREAK
1577 
1578 // FIXME: we need to handle block comments here.
1579 
1580 case 9:
1582 #line 394 "../../libinterp/parse-tree/lex.ll"
1583 {
1584  curr_lexer->lexer_debug ("<MATRIX_START>\\}*");
1585 
1586  curr_lexer->looking_at_object_index.pop_front ();
1587 
1588  curr_lexer->looking_for_object_index = true;
1589  curr_lexer->at_beginning_of_statement = false;
1590 
1591  curr_lexer->handle_close_bracket ('}');
1592 
1593  return curr_lexer->count_token ('}');
1594  }
1595  YY_BREAK
1596 case 10:
1598 #line 407 "../../libinterp/parse-tree/lex.ll"
1599 {
1600  curr_lexer->lexer_debug ("\\[");
1601 
1602  bool unput_comma = false;
1603 
1604  if (curr_lexer->whitespace_is_significant ()
1605  && curr_lexer->space_follows_previous_token ())
1606  {
1607  int tok = curr_lexer->previous_token_value ();
1608 
1609  if (! (tok == '[' || tok == '{'
1610  || curr_lexer->previous_token_is_binop ()))
1611  unput_comma = true;
1612  }
1613 
1614  if (unput_comma)
1615  {
1616  yyless (0);
1617  curr_lexer->xunput (',');
1618  // Adjust for comma that was not really in the input stream.
1619  curr_lexer->current_input_column--;
1620  }
1621  else
1622  {
1623  curr_lexer->nesting_level.bracket ();
1624 
1625  curr_lexer->looking_at_object_index.push_front (false);
1626 
1627  curr_lexer->current_input_column += yyleng;
1628  curr_lexer->looking_for_object_index = false;
1629  curr_lexer->at_beginning_of_statement = false;
1630 
1631  if (curr_lexer->defining_func
1632  && ! curr_lexer->parsed_function_name.top ())
1633  curr_lexer->looking_at_return_list = true;
1634  else
1635  curr_lexer->looking_at_matrix_or_assign_lhs = true;
1636 
1637  curr_lexer->decrement_promptflag ();
1638 
1639  curr_lexer->bracketflag++;
1640 
1641  curr_lexer->push_start_state (MATRIX_START);
1642 
1643  return curr_lexer->count_token ('[');
1644  }
1645  }
1646  YY_BREAK
1647 case 11:
1649 #line 455 "../../libinterp/parse-tree/lex.ll"
1650 {
1651  curr_lexer->lexer_debug ("\\]");
1652 
1653  curr_lexer->nesting_level.remove ();
1654 
1655  curr_lexer->looking_at_object_index.pop_front ();
1656 
1657  curr_lexer->looking_for_object_index = true;
1658  curr_lexer->at_beginning_of_statement = false;
1659 
1660  return curr_lexer->handle_token (']');
1661  }
1662  YY_BREAK
1663 
1664 // Gobble comments.
1665 
1666 
1667 // Start of a block comment. If the comment marker appears immediately
1668 // after a block of full-line comments, finish the full line comment
1669 // block.
1670 
1671 case 12:
1672 /* rule 12 can match eol */
1674 #line 478 "../../libinterp/parse-tree/lex.ll"
1675 {
1676  curr_lexer->lexer_debug ("^{S}*{CCHAR}\\{{S}*{NL}");
1677 
1678  yyless (0);
1679 
1680  if (curr_lexer->start_state () == LINE_COMMENT_START)
1681  {
1682  if (! curr_lexer->comment_text.empty ())
1683  curr_lexer->finish_comment (octave_comment_elt::full_line);
1684 
1685  curr_lexer->pop_start_state ();
1686  }
1687 
1688  curr_lexer->decrement_promptflag ();
1689 
1690  curr_lexer->push_start_state (BLOCK_COMMENT_START);
1691 
1692  }
1693  YY_BREAK
1694 case 13:
1695 /* rule 13 can match eol */
1697 #line 497 "../../libinterp/parse-tree/lex.ll"
1698 {
1699  curr_lexer->lexer_debug ("<BLOCK_COMMENT_START>^{S}*{CCHAR}\\{{S}*{NL}");
1700 
1701  curr_lexer->input_line_number++;
1702  curr_lexer->current_input_column = 1;
1703 
1704  if (curr_lexer->block_comment_nesting_level)
1705  curr_lexer->comment_text = "\n";
1706 
1707  curr_lexer->block_comment_nesting_level++;
1708  }
1709  YY_BREAK
1710 
1711 // End of a block comment. If this block comment is nested inside
1712 // another, wait for the outermost block comment block to be closed
1713 // before storing the comment.
1714 
1715 case 14:
1716 /* rule 14 can match eol */
1718 #line 515 "../../libinterp/parse-tree/lex.ll"
1719 {
1720  curr_lexer->lexer_debug ("<BLOCK_COMMENT_START>^{S}*{CCHAR}\\}{S}*{NL}");
1721 
1722  curr_lexer->input_line_number++;
1723  curr_lexer->current_input_column = 1;
1724 
1725  if (curr_lexer->block_comment_nesting_level > 1)
1726  curr_lexer->comment_text = "\n";
1727  else
1728  curr_lexer->finish_comment (octave_comment_elt::block);
1729 
1730  curr_lexer->block_comment_nesting_level--;
1731 
1732  if (curr_lexer->block_comment_nesting_level == 0)
1733  {
1734  curr_lexer->increment_promptflag ();
1735 
1736  curr_lexer->pop_start_state ();
1737  }
1738  }
1739  YY_BREAK
1740 
1741 // Body of a block comment.
1742 
1743 case 15:
1744 /* rule 15 can match eol */
1746 #line 540 "../../libinterp/parse-tree/lex.ll"
1747 {
1748  curr_lexer->lexer_debug ("<BLOCK_COMMENT_START>.*{NL}");
1749 
1750  curr_lexer->input_line_number++;
1751  curr_lexer->current_input_column = 1;
1752  curr_lexer->comment_text += yytext;
1753  }
1754  YY_BREAK
1755 
1756 // Full-line or end-of-line comment.
1757 
1758 case 16:
1759 /* rule 16 can match eol */
1761 #line 552 "../../libinterp/parse-tree/lex.ll"
1762 {
1763  curr_lexer->lexer_debug ("{S}*{CCHAR}.*{NL}");
1764 
1765  curr_lexer->push_start_state (LINE_COMMENT_START);
1766  yyless (0);
1767  }
1768  YY_BREAK
1769 case 17:
1770 /* rule 17 can match eol */
1772 #line 559 "../../libinterp/parse-tree/lex.ll"
1773 {
1774  curr_lexer->lexer_debug ("<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}");
1775 
1776  bool full_line_comment = curr_lexer->current_input_column == 1;
1777  curr_lexer->input_line_number++;
1778  curr_lexer->current_input_column = 1;
1779 
1780  bool have_space = false;
1781  size_t len = yyleng;
1782  size_t i = 0;
1783  while (i < len)
1784  {
1785  char c = yytext[i];
1786  if (c == ' ' || c == '\t')
1787  {
1788  have_space = true;
1789  i++;
1790  }
1791  else
1792  break;
1793  }
1794 
1795  size_t num_comment_chars = 0;
1796 
1797  while (i < len)
1798  {
1799  char c = yytext[i];
1800  if (c == '#' || c == '%')
1801  {
1802  num_comment_chars++;
1803  i++;
1804  }
1805  else
1806  break;
1807  }
1808 
1809  curr_lexer->comment_text += &yytext[i];
1810 
1811  if (full_line_comment)
1812  {
1813  if (num_comment_chars == 1 && yytext[i++] == '{')
1814  {
1815  bool looks_like_block_comment = true;
1816 
1817  while (i < len)
1818  {
1819  char c = yytext[i++];
1820  if (! (c == ' ' || c == '\t' || c == '\n' || c == '\r'))
1821  {
1822  looks_like_block_comment = false;
1823  break;
1824  }
1825  }
1826 
1827  if (looks_like_block_comment)
1828  {
1829  yyless (0);
1830 
1831  curr_lexer->finish_comment (octave_comment_elt::full_line);
1832 
1833  curr_lexer->pop_start_state ();
1834  }
1835  }
1836  }
1837  else
1838  {
1839  if (have_space)
1840  curr_lexer->mark_previous_token_trailing_space ();
1841 
1842  curr_lexer->finish_comment (octave_comment_elt::end_of_line);
1843 
1844  curr_lexer->pop_start_state ();
1845 
1846  curr_lexer->xunput ('\n');
1847  curr_lexer->input_line_number--;
1848  }
1849  }
1850  YY_BREAK
1851 
1852 // End of a block of full-line comments.
1853 
1854 case 18:
1855 /* rule 18 can match eol */
1857 #line 641 "../../libinterp/parse-tree/lex.ll"
1858 {
1859  curr_lexer->lexer_debug ("<LINE_COMMENT_START>{ANY_INCLUDING_NL}");
1860 
1861  curr_lexer->xunput (yytext[0]);
1862 
1863  curr_lexer->finish_comment (octave_comment_elt::full_line);
1864 
1865  curr_lexer->pop_start_state ();
1866  }
1867  YY_BREAK
1868 
1869 // End of a block of full-line comments.
1870 
1872 #line 655 "../../libinterp/parse-tree/lex.ll"
1873 {
1874  curr_lexer->lexer_debug ("<LINE_COMMENT_START><<EOF>>");
1875 
1876  curr_lexer->finish_comment (octave_comment_elt::full_line);
1877 
1878  curr_lexer->pop_start_state ();
1879  }
1880  YY_BREAK
1881 
1882 // Double-quoted character strings.
1883 
1884 case 19:
1886 #line 667 "../../libinterp/parse-tree/lex.ll"
1887 {
1888  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\"\\\"");
1889 
1890  curr_lexer->current_input_column += yyleng;
1891  curr_lexer->string_text += '"';
1892  }
1893  YY_BREAK
1894 case 20:
1896 #line 674 "../../libinterp/parse-tree/lex.ll"
1897 {
1898  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\"");
1899 
1900  curr_lexer->current_input_column++;
1901 
1902  curr_lexer->pop_start_state ();
1903 
1904  curr_lexer->looking_for_object_index = true;
1905  curr_lexer->at_beginning_of_statement = false;
1906 
1907  curr_lexer->push_token (new token (DQ_STRING,
1908  curr_lexer->string_text,
1909  curr_lexer->string_line,
1910  curr_lexer->string_column));
1911 
1912  curr_lexer->string_text = "";
1913 
1914  return curr_lexer->count_token_internal (DQ_STRING);
1915  }
1916  YY_BREAK
1917 case 21:
1919 #line 694 "../../libinterp/parse-tree/lex.ll"
1920 {
1921  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\[0-7]{1,3}");
1922 
1923  curr_lexer->current_input_column += yyleng;
1924 
1925  int result;
1926  sscanf (yytext+1, "%o", &result);
1927 
1928  if (result > 0xff)
1929  error ("invalid octal escape sequence in character string");
1930  else
1931  curr_lexer->string_text += static_cast<unsigned char> (result);
1932  }
1933  YY_BREAK
1934 case 22:
1936 #line 708 "../../libinterp/parse-tree/lex.ll"
1937 {
1938  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\x[0-9a-fA-F]+");
1939 
1940  curr_lexer->current_input_column += yyleng;
1941 
1942  int result;
1943  sscanf (yytext+2, "%x", &result);
1944 
1945  // Truncate the value silently instead of checking the range like
1946  // we do for octal above. This is to match C/C++ where any number
1947  // of digits is allowed but the value is implementation-defined if
1948  // it exceeds the range of the character type.
1949  curr_lexer->string_text += static_cast<unsigned char> (result);
1950  }
1951  YY_BREAK
1952 case 23:
1954 #line 723 "../../libinterp/parse-tree/lex.ll"
1955 {
1956  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\a\"");
1957 
1958  curr_lexer->current_input_column += yyleng;
1959  curr_lexer->string_text += '\a';
1960  }
1961  YY_BREAK
1962 case 24:
1964 #line 730 "../../libinterp/parse-tree/lex.ll"
1965 {
1966  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\b\"");
1967 
1968  curr_lexer->current_input_column += yyleng;
1969  curr_lexer->string_text += '\b';
1970  }
1971  YY_BREAK
1972 case 25:
1974 #line 737 "../../libinterp/parse-tree/lex.ll"
1975 {
1976  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\f\"");
1977 
1978  curr_lexer->current_input_column += yyleng;
1979  curr_lexer->string_text += '\f';
1980  }
1981  YY_BREAK
1982 case 26:
1984 #line 744 "../../libinterp/parse-tree/lex.ll"
1985 {
1986  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\n\"");
1987 
1988  curr_lexer->current_input_column += yyleng;
1989  curr_lexer->string_text += '\n';
1990  }
1991  YY_BREAK
1992 case 27:
1994 #line 751 "../../libinterp/parse-tree/lex.ll"
1995 {
1996  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\r\"");
1997 
1998  curr_lexer->current_input_column += yyleng;
1999  curr_lexer->string_text += '\r';
2000  }
2001  YY_BREAK
2002 case 28:
2004 #line 758 "../../libinterp/parse-tree/lex.ll"
2005 {
2006  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\t\"");
2007 
2008  curr_lexer->current_input_column += yyleng;
2009  curr_lexer->string_text += '\t';
2010  }
2011  YY_BREAK
2012 case 29:
2014 #line 765 "../../libinterp/parse-tree/lex.ll"
2015 {
2016  curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\v\"");
2017 
2018  curr_lexer->current_input_column += yyleng;
2019  curr_lexer->string_text += '\v';
2020  }
2021  YY_BREAK
2022 case 30:
2023 /* rule 30 can match eol */
2024 #line 773 "../../libinterp/parse-tree/lex.ll"
2025 case 31:
2026 /* rule 31 can match eol */
2028 #line 773 "../../libinterp/parse-tree/lex.ll"
2029 {
2030  curr_lexer->lexer_debug ("<DQ_STRING_START>(\\.\\.\\.){S}*{NL}|<DQ_STRING_START>(\\.\\.\\.){S}*{CCHAR}.*{NL}");
2031 
2032  static const char *msg = "'...' continuations in double-quoted character strings are obsolete and will not be allowed in a future version of Octave; please use '\\' instead";
2033 
2034  std::string nm = curr_lexer->fcn_file_full_name;
2035 
2036  if (nm.empty ())
2037  warning_with_id ("Octave:deprecated-syntax", "%s", msg);
2038  else
2039  warning_with_id ("Octave:deprecated-syntax",
2040  "%s; near line %d of file '%s'", msg,
2041  curr_lexer->input_line_number, nm.c_str ());
2042 
2044  }
2045  YY_BREAK
2046 case 32:
2047 /* rule 32 can match eol */
2048 #line 791 "../../libinterp/parse-tree/lex.ll"
2049 case 33:
2050 /* rule 33 can match eol */
2052 #line 791 "../../libinterp/parse-tree/lex.ll"
2053 {
2054  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\{S}+{NL}|<DQ_STRING_START>\\\\{S}*{CCHAR}.*{NL}");
2055 
2056  static const char *msg = "white space and comments after continuation markers in double-quoted character strings are obsolete and will not be allowed in a future version of Octave";
2057 
2058  std::string nm = curr_lexer->fcn_file_full_name;
2059 
2060  if (nm.empty ())
2061  warning_with_id ("Octave:deprecated-syntax", "%s", msg);
2062  else
2063  warning_with_id ("Octave:deprecated-syntax",
2064  "%s; near line %d of file '%s'", msg,
2065  curr_lexer->input_line_number, nm.c_str ());
2066 
2068  }
2069  YY_BREAK
2070 case 34:
2071 /* rule 34 can match eol */
2073 #line 808 "../../libinterp/parse-tree/lex.ll"
2074 {
2075  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\{NL}");
2076 
2078  }
2079  YY_BREAK
2080 case 35:
2082 #line 814 "../../libinterp/parse-tree/lex.ll"
2083 {
2084  curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\.");
2085 
2086  curr_lexer->current_input_column += yyleng;
2087  curr_lexer->string_text += yytext[1];
2088  }
2089  YY_BREAK
2090 case 36:
2092 #line 821 "../../libinterp/parse-tree/lex.ll"
2093 {
2094  curr_lexer->lexer_debug ("<DQ_STRING_START>\\.");
2095 
2096  curr_lexer->current_input_column++;
2097  curr_lexer->string_text += yytext[0];
2098  }
2099  YY_BREAK
2100 case 37:
2102 #line 828 "../../libinterp/parse-tree/lex.ll"
2103 {
2104  curr_lexer->lexer_debug ("<DQ_STRING_START>[^\\.\\\\\\r\\n\\\"]+");
2105 
2106  curr_lexer->current_input_column += yyleng;
2107  curr_lexer->string_text += yytext;
2108  }
2109  YY_BREAK
2110 case 38:
2111 /* rule 38 can match eol */
2113 #line 835 "../../libinterp/parse-tree/lex.ll"
2114 {
2115  curr_lexer->lexer_debug ("<DQ_STRING_START>{NL}");
2116 
2117  curr_lexer->input_line_number++;
2118  curr_lexer->current_input_column = 1;
2119 
2120  error ("unterminated character string constant");
2121 
2122  return LEXICAL_ERROR;
2123  }
2124  YY_BREAK
2125 
2126 // Single-quoted character strings.
2127 
2128 case 39:
2130 #line 850 "../../libinterp/parse-tree/lex.ll"
2131 {
2132  curr_lexer->lexer_debug ("<SQ_STRING_START>\\'\\'");
2133 
2134  curr_lexer->current_input_column += yyleng;
2135  curr_lexer->string_text += '\'';
2136  }
2137  YY_BREAK
2138 case 40:
2140 #line 857 "../../libinterp/parse-tree/lex.ll"
2141 {
2142  curr_lexer->lexer_debug ("<SQ_STRING_START>\\'");
2143 
2144  curr_lexer->current_input_column++;
2145 
2146  curr_lexer->pop_start_state ();
2147 
2148  curr_lexer->looking_for_object_index = true;
2149  curr_lexer->at_beginning_of_statement = false;
2150 
2151  curr_lexer->push_token (new token (SQ_STRING,
2152  curr_lexer->string_text,
2153  curr_lexer->string_line,
2154  curr_lexer->string_column));
2155 
2156  curr_lexer->string_text = "";
2157 
2158  return curr_lexer->count_token_internal (SQ_STRING);
2159  }
2160  YY_BREAK
2161 case 41:
2163 #line 877 "../../libinterp/parse-tree/lex.ll"
2164 {
2165  curr_lexer->lexer_debug ("<SQ_STRING_START>[^\\'\\n\\r]+");
2166 
2167  curr_lexer->current_input_column += yyleng;
2168  curr_lexer->string_text += yytext;
2169  }
2170  YY_BREAK
2171 case 42:
2172 /* rule 42 can match eol */
2174 #line 884 "../../libinterp/parse-tree/lex.ll"
2175 {
2176  curr_lexer->lexer_debug ("<SQ_STRING_START>{NL}");
2177 
2178  curr_lexer->input_line_number++;
2179  curr_lexer->current_input_column = 1;
2180 
2181  error ("unterminated character string constant");
2182 
2183  return LEXICAL_ERROR;
2184  }
2185  YY_BREAK
2186 
2187 // Imaginary numbers.
2188 
2189 case 43:
2191 #line 899 "../../libinterp/parse-tree/lex.ll"
2192 {
2193  curr_lexer->lexer_debug ("{NUMBER}{Im}");
2194 
2195  if (curr_lexer->previous_token_may_be_command ()
2196  && curr_lexer->space_follows_previous_token ())
2197  {
2198  yyless (0);
2199  curr_lexer->push_start_state (COMMAND_START);
2200  }
2201  else
2202  {
2203  int tok = curr_lexer->previous_token_value ();
2204 
2205  if (curr_lexer->whitespace_is_significant ()
2206  && curr_lexer->space_follows_previous_token ()
2207  && ! (tok == '[' || tok == '{'
2208  || curr_lexer->previous_token_is_binop ()))
2209  {
2210  yyless (0);
2211  unput (',');
2212  }
2213  else
2214  {
2215  curr_lexer->handle_number ();
2216  return curr_lexer->count_token_internal (IMAG_NUM);
2217  }
2218  }
2219  }
2220  YY_BREAK
2221 
2222 // Real numbers. Don't grab the '.' part of a dot operator as part of
2223 // the constant.
2224 
2225 case 44:
2226 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
2227 yyg->yy_c_buf_p = yy_cp -= 2;
2228 YY_DO_BEFORE_ACTION; /* set up yytext again */
2229 #line 934 "../../libinterp/parse-tree/lex.ll"
2230 case 45:
2232 #line 934 "../../libinterp/parse-tree/lex.ll"
2233 {
2234  curr_lexer->lexer_debug ("{D}+/\\.[\\*/\\\\^\\']|{NUMBER}");
2235 
2236  if (curr_lexer->previous_token_may_be_command ()
2237  && curr_lexer->space_follows_previous_token ())
2238  {
2239  yyless (0);
2240  curr_lexer->push_start_state (COMMAND_START);
2241  }
2242  else
2243  {
2244  int tok = curr_lexer->previous_token_value ();
2245 
2246  if (curr_lexer->whitespace_is_significant ()
2247  && curr_lexer->space_follows_previous_token ()
2248  && ! (tok == '[' || tok == '{'
2249  || curr_lexer->previous_token_is_binop ()))
2250  {
2251  yyless (0);
2252  unput (',');
2253  }
2254  else
2255  {
2256  curr_lexer->handle_number ();
2257  return curr_lexer->count_token_internal (NUM);
2258  }
2259  }
2260  }
2261  YY_BREAK
2262 
2263 // Eat whitespace. Whitespace inside matrix constants is handled by
2264 // the <MATRIX_START> start state code above.
2265 
2266 case 46:
2268 #line 968 "../../libinterp/parse-tree/lex.ll"
2269 {
2270  curr_lexer->current_input_column += yyleng;
2271 
2272  curr_lexer->mark_previous_token_trailing_space ();
2273  }
2274  YY_BREAK
2275 
2276 // Continuation lines. Allow arbitrary text after continuations.
2277 
2278 case 47:
2279 /* rule 47 can match eol */
2281 #line 978 "../../libinterp/parse-tree/lex.ll"
2282 {
2283  curr_lexer->lexer_debug ("\\.\\.\\..*{NL}");
2284 
2285  curr_lexer->handle_continuation ();
2286  }
2287  YY_BREAK
2288 
2289 // Deprecated C preprocessor style continuation markers.
2290 
2291 case 48:
2292 /* rule 48 can match eol */
2293 #line 989 "../../libinterp/parse-tree/lex.ll"
2294 case 49:
2295 /* rule 49 can match eol */
2297 #line 989 "../../libinterp/parse-tree/lex.ll"
2298 {
2299  curr_lexer->lexer_debug ("\\\\{S}*{NL}|\\\\{S}*{CCHAR}.*{NL}");
2300 
2301  static const char *msg = "using continuation marker \\ outside of double quoted strings is deprecated and will be removed in a future version of Octave";
2302 
2303  std::string nm = curr_lexer->fcn_file_full_name;
2304 
2305  if (nm.empty ())
2306  warning_with_id ("Octave:deprecated-syntax", "%s", msg);
2307  else
2308  warning_with_id ("Octave:deprecated-syntax",
2309  "%s; near line %d of file '%s'", msg,
2310  curr_lexer->input_line_number, nm.c_str ());
2311 
2312  curr_lexer->handle_continuation ();
2313  }
2314  YY_BREAK
2315 
2316 // End of file.
2317 
2318 case YY_STATE_EOF(INITIAL):
2325 #line 1010 "../../libinterp/parse-tree/lex.ll"
2326 {
2327  return curr_lexer->handle_end_of_input ();
2328  }
2329  YY_BREAK
2330 
2331 // Identifiers.
2332 
2333 case 50:
2335 #line 1018 "../../libinterp/parse-tree/lex.ll"
2336 {
2337  curr_lexer->lexer_debug ("{IDENT}");
2338 
2339  int tok = curr_lexer->previous_token_value ();
2340 
2341  if (curr_lexer->whitespace_is_significant ()
2342  && curr_lexer->space_follows_previous_token ()
2343  && ! (tok == '[' || tok == '{'
2344  || curr_lexer->previous_token_is_binop ()))
2345  {
2346  yyless (0);
2347  unput (',');
2348  }
2349  else
2350  {
2351  if (! curr_lexer->looking_at_decl_list
2352  && curr_lexer->previous_token_may_be_command ())
2353  {
2354  yyless (0);
2355  curr_lexer->push_start_state (COMMAND_START);
2356  }
2357  else
2358  {
2359  int id_tok = curr_lexer->handle_identifier ();
2360 
2361  if (id_tok >= 0)
2362  return curr_lexer->count_token_internal (id_tok);
2363  }
2364  }
2365  }
2366  YY_BREAK
2367 
2368 // Superclass method identifiers.
2369 
2370 case 51:
2371 #line 1054 "../../libinterp/parse-tree/lex.ll"
2372 case 52:
2374 #line 1054 "../../libinterp/parse-tree/lex.ll"
2375 {
2376  curr_lexer->lexer_debug ("{IDENT}@{IDENT}|{IDENT}@{IDENT}.{IDENT}");
2377 
2378  if (curr_lexer->previous_token_may_be_command ())
2379  {
2380  yyless (0);
2381  curr_lexer->push_start_state (COMMAND_START);
2382  }
2383  else
2384  {
2385  int id_tok = curr_lexer->handle_superclass_identifier ();
2386 
2387  if (id_tok >= 0)
2388  {
2389  curr_lexer->looking_for_object_index = true;
2390 
2391  return curr_lexer->count_token_internal (SUPERCLASSREF);
2392  }
2393  }
2394  }
2395  YY_BREAK
2396 
2397 // Metaclass query
2398 
2399 case 53:
2400 #line 1080 "../../libinterp/parse-tree/lex.ll"
2401 case 54:
2403 #line 1080 "../../libinterp/parse-tree/lex.ll"
2404 {
2405  curr_lexer->lexer_debug ("\\?{IDENT}|\\?{IDENT}\\.{IDENT}");
2406 
2407  if (curr_lexer->previous_token_may_be_command ()
2408  && curr_lexer->space_follows_previous_token ())
2409  {
2410  yyless (0);
2411  curr_lexer->push_start_state (COMMAND_START);
2412  }
2413  else
2414  {
2415  int id_tok = curr_lexer->handle_meta_identifier ();
2416 
2417  if (id_tok >= 0)
2418  {
2419  curr_lexer->looking_for_object_index = true;
2420 
2421  return curr_lexer->count_token_internal (METAQUERY);
2422  }
2423  }
2424  }
2425  YY_BREAK
2426 case 55:
2428 #line 1102 "../../libinterp/parse-tree/lex.ll"
2429 {
2430  if (curr_lexer->previous_token_may_be_command ()
2431  && curr_lexer->space_follows_previous_token ())
2432  {
2433  yyless (0);
2434  curr_lexer->push_start_state (COMMAND_START);
2435  }
2436  else
2437  {
2438  curr_lexer->lexer_debug ("@");
2439 
2440  curr_lexer->current_input_column++;
2441 
2442  curr_lexer->looking_at_function_handle++;
2443  curr_lexer->looking_for_object_index = false;
2444  curr_lexer->at_beginning_of_statement = false;
2445 
2446  return curr_lexer->count_token ('@');
2447  }
2448  }
2449  YY_BREAK
2450 
2451 // A new line character. New line characters inside matrix constants
2452 // are handled by the <MATRIX_START> start state code above. If closest
2453 // nesting is inside parentheses, don't return a row separator.
2454 
2455 case 56:
2456 /* rule 56 can match eol */
2458 #line 1129 "../../libinterp/parse-tree/lex.ll"
2459 {
2460  curr_lexer->lexer_debug ("{NL}");
2461 
2462  curr_lexer->input_line_number++;
2463  curr_lexer->current_input_column = 1;
2464 
2465  if (curr_lexer->nesting_level.is_paren ())
2466  {
2467  curr_lexer->at_beginning_of_statement = false;
2468  curr_lexer->gripe_matlab_incompatible
2469  ("bare newline inside parentheses");
2470  }
2471  else if (curr_lexer->nesting_level.none ()
2472  || curr_lexer->nesting_level.is_anon_fcn_body ())
2473  {
2474  curr_lexer->at_beginning_of_statement = true;
2475  return curr_lexer->count_token ('\n');
2476  }
2477  else if (curr_lexer->nesting_level.is_bracket_or_brace ())
2478  return LEXICAL_ERROR;
2479  }
2480  YY_BREAK
2481 
2482 // Single quote can either be the beginning of a string or a transpose
2483 // operator.
2484 
2485 case 57:
2487 #line 1156 "../../libinterp/parse-tree/lex.ll"
2488 {
2489  curr_lexer->lexer_debug ("'");
2490 
2491  if (curr_lexer->previous_token_may_be_command ()
2492  && curr_lexer->space_follows_previous_token ())
2493  {
2494  curr_lexer->current_input_column++;
2495  curr_lexer->push_start_state (COMMAND_START);
2496  curr_lexer->begin_string (SQ_STRING_START);
2497  }
2498  else if (curr_lexer->at_beginning_of_statement)
2499  {
2500  curr_lexer->current_input_column++;
2501  curr_lexer->begin_string (SQ_STRING_START);
2502  }
2503  else
2504  {
2505  int tok = curr_lexer->previous_token_value ();
2506 
2507  if (curr_lexer->whitespace_is_significant ())
2508  {
2509  if (curr_lexer->space_follows_previous_token ())
2510  {
2511  if (tok == '[' || tok == '{'
2512  || curr_lexer->previous_token_is_binop ())
2513  {
2514  curr_lexer->current_input_column++;
2515  curr_lexer->begin_string (SQ_STRING_START);
2516  }
2517  else
2518  {
2519  yyless (0);
2520  curr_lexer->xunput (',');
2521  // Adjust for comma that was not really in the input stream.
2522  curr_lexer->current_input_column--;
2523  }
2524  }
2525  else
2526  {
2527  if (tok == '[' || tok == '{'
2528  || curr_lexer->previous_token_is_binop ()
2529  || curr_lexer->previous_token_is_keyword ())
2530  {
2531  curr_lexer->current_input_column++;
2532  curr_lexer->begin_string (SQ_STRING_START);
2533  }
2534  else
2535  return curr_lexer->count_token (HERMITIAN);
2536  }
2537  }
2538  else
2539  {
2540  if (! tok || tok == '[' || tok == '{' || tok == '('
2541  || curr_lexer->previous_token_is_binop ()
2542  || curr_lexer->previous_token_is_keyword ())
2543  {
2544  curr_lexer->current_input_column++;
2545  curr_lexer->begin_string (SQ_STRING_START);
2546  }
2547  else
2548  return curr_lexer->count_token (HERMITIAN);
2549  }
2550  }
2551  }
2552  YY_BREAK
2553 
2554 // Double quotes always begin strings.
2555 
2556 case 58:
2558 #line 1225 "../../libinterp/parse-tree/lex.ll"
2559 {
2560  curr_lexer->lexer_debug ("\\\"");
2561 
2562  if (curr_lexer->previous_token_may_be_command ()
2563  && curr_lexer->space_follows_previous_token ())
2564  {
2565  curr_lexer->current_input_column++;
2566  curr_lexer->push_start_state (COMMAND_START);
2567  curr_lexer->begin_string (DQ_STRING_START);
2568  }
2569  else
2570  {
2571  int tok = curr_lexer->previous_token_value ();
2572 
2573  if (curr_lexer->whitespace_is_significant ())
2574  {
2575  if (curr_lexer->space_follows_previous_token ())
2576  {
2577  if (tok == '[' || tok == '{'
2578  || curr_lexer->previous_token_is_binop ())
2579  {
2580  curr_lexer->current_input_column++;
2581  curr_lexer->begin_string (DQ_STRING_START);
2582  }
2583  else
2584  {
2585  yyless (0);
2586  curr_lexer->xunput (',');
2587  // Adjust for comma that was not really in the input stream.
2588  curr_lexer->current_input_column--;
2589  }
2590  }
2591  else
2592  {
2593  curr_lexer->current_input_column++;
2594  curr_lexer->begin_string (DQ_STRING_START);
2595  }
2596  }
2597  else
2598  {
2599  curr_lexer->current_input_column++;
2600  curr_lexer->begin_string (DQ_STRING_START);
2601  }
2602  }
2603  }
2604  YY_BREAK
2605 
2606 // Other operators.
2607 
2608 case 59:
2610 #line 1275 "../../libinterp/parse-tree/lex.ll"
2611 { CMD_OR_OP (":", ':', true); }
2612  YY_BREAK
2613 case 60:
2615 #line 1276 "../../libinterp/parse-tree/lex.ll"
2616 { CMD_OR_OP (".+", EPLUS, false); }
2617  YY_BREAK
2618 case 61:
2620 #line 1277 "../../libinterp/parse-tree/lex.ll"
2621 { CMD_OR_OP (".-", EMINUS, false); }
2622  YY_BREAK
2623 case 62:
2625 #line 1278 "../../libinterp/parse-tree/lex.ll"
2626 { CMD_OR_OP (".*", EMUL, true); }
2627  YY_BREAK
2628 case 63:
2630 #line 1279 "../../libinterp/parse-tree/lex.ll"
2631 { CMD_OR_OP ("./", EDIV, true); }
2632  YY_BREAK
2633 case 64:
2635 #line 1280 "../../libinterp/parse-tree/lex.ll"
2636 { CMD_OR_OP (".\\", ELEFTDIV, true); }
2637  YY_BREAK
2638 case 65:
2640 #line 1281 "../../libinterp/parse-tree/lex.ll"
2641 { CMD_OR_OP (".^", EPOW, true); }
2642  YY_BREAK
2643 case 66:
2645 #line 1282 "../../libinterp/parse-tree/lex.ll"
2646 { CMD_OR_OP (".**", EPOW, false); }
2647  YY_BREAK
2648 case 67:
2650 #line 1283 "../../libinterp/parse-tree/lex.ll"
2651 { CMD_OR_OP ("<=", EXPR_LE, true); }
2652  YY_BREAK
2653 case 68:
2655 #line 1284 "../../libinterp/parse-tree/lex.ll"
2656 { CMD_OR_OP ("==", EXPR_EQ, true); }
2657  YY_BREAK
2658 case 69:
2660 #line 1285 "../../libinterp/parse-tree/lex.ll"
2661 { CMD_OR_OP ("~=", EXPR_NE, true); }
2662  YY_BREAK
2663 case 70:
2665 #line 1286 "../../libinterp/parse-tree/lex.ll"
2666 { CMD_OR_OP ("!=", EXPR_NE, false); }
2667  YY_BREAK
2668 case 71:
2670 #line 1287 "../../libinterp/parse-tree/lex.ll"
2671 { CMD_OR_OP (">=", EXPR_GE, true); }
2672  YY_BREAK
2673 case 72:
2675 #line 1288 "../../libinterp/parse-tree/lex.ll"
2676 { CMD_OR_OP ("&", EXPR_AND, true); }
2677  YY_BREAK
2678 case 73:
2680 #line 1289 "../../libinterp/parse-tree/lex.ll"
2681 { CMD_OR_OP ("|", EXPR_OR, true); }
2682  YY_BREAK
2683 case 74:
2685 #line 1290 "../../libinterp/parse-tree/lex.ll"
2686 { CMD_OR_OP ("<", EXPR_LT, true); }
2687  YY_BREAK
2688 case 75:
2690 #line 1291 "../../libinterp/parse-tree/lex.ll"
2691 { CMD_OR_OP (">", EXPR_GT, true); }
2692  YY_BREAK
2693 case 76:
2695 #line 1292 "../../libinterp/parse-tree/lex.ll"
2696 { CMD_OR_OP ("*", '*', true); }
2697  YY_BREAK
2698 case 77:
2700 #line 1293 "../../libinterp/parse-tree/lex.ll"
2701 { CMD_OR_OP ("/", '/', true); }
2702  YY_BREAK
2703 
2704 // In Matlab, '\' may also trigger command syntax.
2705 
2706 case 78:
2708 #line 1299 "../../libinterp/parse-tree/lex.ll"
2709 { return curr_lexer->handle_op ("\\", LEFTDIV); }
2710  YY_BREAK
2711 case 79:
2713 #line 1301 "../../libinterp/parse-tree/lex.ll"
2714 { CMD_OR_OP ("^", POW, true); }
2715  YY_BREAK
2716 case 80:
2718 #line 1302 "../../libinterp/parse-tree/lex.ll"
2719 { CMD_OR_OP ("**", POW, false); }
2720  YY_BREAK
2721 case 81:
2723 #line 1303 "../../libinterp/parse-tree/lex.ll"
2724 { CMD_OR_OP ("&&", EXPR_AND_AND, true); }
2725  YY_BREAK
2726 case 82:
2728 #line 1304 "../../libinterp/parse-tree/lex.ll"
2729 { CMD_OR_OP ("||", EXPR_OR_OR, true); }
2730  YY_BREAK
2731 case 83:
2733 #line 1305 "../../libinterp/parse-tree/lex.ll"
2734 { CMD_OR_OP ("<<", LSHIFT, false); }
2735  YY_BREAK
2736 case 84:
2738 #line 1306 "../../libinterp/parse-tree/lex.ll"
2739 { CMD_OR_OP (">>", RSHIFT, false); }
2740  YY_BREAK
2741 case 85:
2743 #line 1308 "../../libinterp/parse-tree/lex.ll"
2744 {
2745  bool at_beginning_of_statement
2746  = (! (curr_lexer->whitespace_is_significant ()
2747  || curr_lexer->looking_at_object_index.front ()));
2748 
2749  return curr_lexer->handle_op (";", ';', at_beginning_of_statement);
2750  }
2751  YY_BREAK
2752 case 86:
2754 #line 1316 "../../libinterp/parse-tree/lex.ll"
2755 { CMD_OR_UNARY_OP ("+", '+', true); }
2756  YY_BREAK
2757 case 87:
2759 #line 1317 "../../libinterp/parse-tree/lex.ll"
2760 { CMD_OR_UNARY_OP ("-", '-', true); }
2761  YY_BREAK
2762 case 88:
2764 #line 1319 "../../libinterp/parse-tree/lex.ll"
2765 { CMD_OR_UNARY_OP ("~", EXPR_NOT, true); }
2766  YY_BREAK
2767 case 89:
2769 #line 1320 "../../libinterp/parse-tree/lex.ll"
2770 { CMD_OR_UNARY_OP ("!", EXPR_NOT, false); }
2771  YY_BREAK
2772 case 90:
2774 #line 1322 "../../libinterp/parse-tree/lex.ll"
2775 {
2776  bool at_beginning_of_statement
2777  = (! (curr_lexer->whitespace_is_significant ()
2778  || curr_lexer->looking_at_object_index.front ()));
2779 
2780  return curr_lexer->handle_op (",", ',', at_beginning_of_statement);
2781  }
2782  YY_BREAK
2783 case 91:
2785 #line 1330 "../../libinterp/parse-tree/lex.ll"
2786 {
2787  return curr_lexer->handle_op (".'", TRANSPOSE, false);
2788  }
2789  YY_BREAK
2790 case 92:
2792 #line 1334 "../../libinterp/parse-tree/lex.ll"
2793 { CMD_OR_UNARY_OP ("++", PLUS_PLUS, false); }
2794  YY_BREAK
2795 case 93:
2797 #line 1335 "../../libinterp/parse-tree/lex.ll"
2798 { CMD_OR_UNARY_OP ("--", MINUS_MINUS, false); }
2799  YY_BREAK
2800 case 94:
2802 #line 1337 "../../libinterp/parse-tree/lex.ll"
2803 {
2804  curr_lexer->lexer_debug ("(");
2805 
2806  bool unput_comma = false;
2807 
2808  if (curr_lexer->whitespace_is_significant ()
2809  && curr_lexer->space_follows_previous_token ())
2810  {
2811  int tok = curr_lexer->previous_token_value ();
2812 
2813  if (! (tok == '[' || tok == '{'
2814  || curr_lexer->previous_token_is_binop ()))
2815  unput_comma = true;
2816  }
2817 
2818  if (unput_comma)
2819  {
2820  yyless (0);
2821  curr_lexer->xunput (',');
2822  // Adjust for comma that was not really in the input stream.
2823  curr_lexer->current_input_column--;
2824  }
2825  else
2826  {
2827  // If we are looking for an object index, then push TRUE for
2828  // looking_at_object_index. Otherwise, just push whatever state
2829  // is current (so that we can pop it off the stack when we find
2830  // the matching close paren).
2831 
2832  curr_lexer->looking_at_object_index.push_front
2833  (curr_lexer->looking_for_object_index);
2834 
2835  curr_lexer->looking_at_indirect_ref = false;
2836  curr_lexer->looking_for_object_index = false;
2837  curr_lexer->at_beginning_of_statement = false;
2838 
2839  curr_lexer->nesting_level.paren ();
2840  curr_lexer->decrement_promptflag ();
2841 
2842  return curr_lexer->handle_token ('(');
2843  }
2844  }
2845  YY_BREAK
2846 case 95:
2848 #line 1380 "../../libinterp/parse-tree/lex.ll"
2849 {
2850  curr_lexer->lexer_debug (")");
2851 
2852  curr_lexer->nesting_level.remove ();
2853  curr_lexer->current_input_column++;
2854 
2855  curr_lexer->looking_at_object_index.pop_front ();
2856 
2857  curr_lexer->looking_for_object_index = true;
2858  curr_lexer->at_beginning_of_statement = false;
2859 
2860  if (curr_lexer->looking_at_anon_fcn_args)
2861  {
2862  curr_lexer->looking_at_anon_fcn_args = false;
2863  curr_lexer->nesting_level.anon_fcn_body ();
2864  }
2865 
2866  return curr_lexer->count_token (')');
2867  }
2868  YY_BREAK
2869 case 96:
2871 #line 1400 "../../libinterp/parse-tree/lex.ll"
2872 {
2873  curr_lexer->lexer_debug (".");
2874 
2875  if (curr_lexer->previous_token_may_be_command ()
2876  && curr_lexer->space_follows_previous_token ())
2877  {
2878  yyless (0);
2879  curr_lexer->push_start_state (COMMAND_START);
2880  }
2881  else
2882  {
2883  curr_lexer->looking_for_object_index = false;
2884  curr_lexer->at_beginning_of_statement = false;
2885 
2886  return curr_lexer->handle_token ('.');
2887  }
2888  }
2889  YY_BREAK
2890 
2891 // = and op= operators.
2892 
2893 case 97:
2895 #line 1422 "../../libinterp/parse-tree/lex.ll"
2896 {
2897  curr_lexer->maybe_mark_previous_token_as_variable ();
2898 
2899  return curr_lexer->handle_op ("=", '=');
2900  }
2901  YY_BREAK
2902 case 98:
2904 #line 1428 "../../libinterp/parse-tree/lex.ll"
2905 { CMD_OR_COMPUTED_ASSIGN_OP ("+=", ADD_EQ); }
2906  YY_BREAK
2907 case 99:
2909 #line 1429 "../../libinterp/parse-tree/lex.ll"
2910 { CMD_OR_COMPUTED_ASSIGN_OP ("-=", SUB_EQ); }
2911  YY_BREAK
2912 case 100:
2914 #line 1430 "../../libinterp/parse-tree/lex.ll"
2915 { CMD_OR_COMPUTED_ASSIGN_OP ("*=", MUL_EQ); }
2916  YY_BREAK
2917 case 101:
2919 #line 1431 "../../libinterp/parse-tree/lex.ll"
2920 { CMD_OR_COMPUTED_ASSIGN_OP ("/=", DIV_EQ); }
2921  YY_BREAK
2922 case 102:
2924 #line 1432 "../../libinterp/parse-tree/lex.ll"
2926  YY_BREAK
2927 case 103:
2929 #line 1433 "../../libinterp/parse-tree/lex.ll"
2930 { CMD_OR_COMPUTED_ASSIGN_OP (".+=", ADD_EQ); }
2931  YY_BREAK
2932 case 104:
2934 #line 1434 "../../libinterp/parse-tree/lex.ll"
2935 { CMD_OR_COMPUTED_ASSIGN_OP (".-=", SUB_EQ); }
2936  YY_BREAK
2937 case 105:
2939 #line 1435 "../../libinterp/parse-tree/lex.ll"
2940 { CMD_OR_COMPUTED_ASSIGN_OP (".*=", EMUL_EQ); }
2941  YY_BREAK
2942 case 106:
2944 #line 1436 "../../libinterp/parse-tree/lex.ll"
2945 { CMD_OR_COMPUTED_ASSIGN_OP ("./=", EDIV_EQ); }
2946  YY_BREAK
2947 case 107:
2949 #line 1437 "../../libinterp/parse-tree/lex.ll"
2951  YY_BREAK
2952 case 108:
2954 #line 1438 "../../libinterp/parse-tree/lex.ll"
2955 { CMD_OR_COMPUTED_ASSIGN_OP ("^=", POW_EQ); }
2956  YY_BREAK
2957 case 109:
2959 #line 1439 "../../libinterp/parse-tree/lex.ll"
2960 { CMD_OR_COMPUTED_ASSIGN_OP ("^=", POW_EQ); }
2961  YY_BREAK
2962 case 110:
2964 #line 1440 "../../libinterp/parse-tree/lex.ll"
2965 { CMD_OR_COMPUTED_ASSIGN_OP (".^=", EPOW_EQ); }
2966  YY_BREAK
2967 case 111:
2969 #line 1441 "../../libinterp/parse-tree/lex.ll"
2970 { CMD_OR_COMPUTED_ASSIGN_OP (".^=", EPOW_EQ); }
2971  YY_BREAK
2972 case 112:
2974 #line 1442 "../../libinterp/parse-tree/lex.ll"
2975 { CMD_OR_COMPUTED_ASSIGN_OP ("&=", AND_EQ); }
2976  YY_BREAK
2977 case 113:
2979 #line 1443 "../../libinterp/parse-tree/lex.ll"
2980 { CMD_OR_COMPUTED_ASSIGN_OP ("|=", OR_EQ); }
2981  YY_BREAK
2982 case 114:
2984 #line 1444 "../../libinterp/parse-tree/lex.ll"
2986  YY_BREAK
2987 case 115:
2989 #line 1445 "../../libinterp/parse-tree/lex.ll"
2991  YY_BREAK
2992 
2993 // In Matlab, '{' may also trigger command syntax.
2994 
2995 case 116:
2997 #line 1451 "../../libinterp/parse-tree/lex.ll"
2998 {
2999  curr_lexer->lexer_debug ("{");
3000 
3001  bool unput_comma = false;
3002 
3003  if (curr_lexer->whitespace_is_significant ()
3004  && curr_lexer->space_follows_previous_token ())
3005  {
3006  int tok = curr_lexer->previous_token_value ();
3007 
3008  if (! (tok == '[' || tok == '{'
3009  || curr_lexer->previous_token_is_binop ()))
3010  unput_comma = true;
3011  }
3012 
3013  if (unput_comma)
3014  {
3015  yyless (0);
3016  curr_lexer->xunput (',');
3017  // Adjust for comma that was not really in the input stream.
3018  curr_lexer->current_input_column--;
3019  }
3020  else
3021  {
3022  curr_lexer->nesting_level.brace ();
3023 
3024  curr_lexer->looking_at_object_index.push_front
3025  (curr_lexer->looking_for_object_index);
3026 
3027  curr_lexer->current_input_column += yyleng;
3028  curr_lexer->looking_for_object_index = false;
3029  curr_lexer->at_beginning_of_statement = false;
3030 
3031  curr_lexer->decrement_promptflag ();
3032 
3033  curr_lexer->braceflag++;
3034 
3035  curr_lexer->push_start_state (MATRIX_START);
3036 
3037  return curr_lexer->count_token ('{');
3038  }
3039  }
3040  YY_BREAK
3041 case 117:
3043 #line 1494 "../../libinterp/parse-tree/lex.ll"
3044 {
3045  curr_lexer->lexer_debug ("}");
3046 
3047  curr_lexer->looking_at_object_index.pop_front ();
3048 
3049  curr_lexer->looking_for_object_index = true;
3050  curr_lexer->at_beginning_of_statement = false;
3051 
3052  curr_lexer->nesting_level.remove ();
3053 
3054  return curr_lexer->handle_token ('}');
3055  }
3056  YY_BREAK
3057 
3058 // Unrecognized input is a lexical error.
3059 
3060 case 118:
3062 #line 1511 "../../libinterp/parse-tree/lex.ll"
3063 {
3064  curr_lexer->lexer_debug (".");
3065 
3066  curr_lexer->xunput (yytext[0]);
3067 
3068  int c = curr_lexer->text_yyinput ();
3069 
3070  if (c == 1)
3071  return -1;
3072  else if (c == EOF)
3073  return curr_lexer->handle_end_of_input ();
3074  else
3075  {
3076  curr_lexer->current_input_column++;
3077 
3078  error ("invalid character '%s' (ASCII %d) near line %d, column %d",
3079  undo_string_escape (static_cast<char> (c)), c,
3080  curr_lexer->input_line_number, curr_lexer->current_input_column);
3081 
3082  return LEXICAL_ERROR;
3083  }
3084  }
3085  YY_BREAK
3086 case 119:
3088 #line 1534 "../../libinterp/parse-tree/lex.ll"
3089 ECHO;
3090  YY_BREAK
3091 #line 3092 "parse-tree/lex.cc"
3092 
3093  case YY_END_OF_BUFFER:
3094  {
3095  /* Amount of text matched not including the EOB char. */
3096  int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
3097 
3098  /* Undo the effects of YY_DO_BEFORE_ACTION. */
3099  *yy_cp = yyg->yy_hold_char;
3101 
3102  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
3103  {
3104  /* We're scanning a new file or input source. It's
3105  * possible that this happened because the user
3106  * just pointed yyin at a new source and called
3107  * octave_lex(). If so, then we have to assure
3108  * consistency between YY_CURRENT_BUFFER and our
3109  * globals. Here is the right place to do so, because
3110  * this is the first action (other than possibly a
3111  * back-up) that will match for the new input source.
3112  */
3113  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
3114  YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
3115  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
3116  }
3117 
3118  /* Note that here we test for yy_c_buf_p "<=" to the position
3119  * of the first EOB in the buffer, since yy_c_buf_p will
3120  * already have been incremented past the NUL character
3121  * (since all states make transitions on EOB to the
3122  * end-of-buffer state). Contrast this with the test
3123  * in input().
3124  */
3125  if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
3126  { /* This was really a NUL. */
3127  yy_state_type yy_next_state;
3128 
3129  yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
3130 
3131  yy_current_state = yy_get_previous_state( yyscanner );
3132 
3133  /* Okay, we're now positioned to make the NUL
3134  * transition. We couldn't have
3135  * yy_get_previous_state() go ahead and do it
3136  * for us because it doesn't know how to deal
3137  * with the possibility of jamming (and we don't
3138  * want to build jamming into it because then it
3139  * will run more slowly).
3140  */
3141 
3142  yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
3143 
3144  yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
3145 
3146  if ( yy_next_state )
3147  {
3148  /* Consume the NUL. */
3149  yy_cp = ++yyg->yy_c_buf_p;
3150  yy_current_state = yy_next_state;
3151  goto yy_match;
3152  }
3153 
3154  else
3155  {
3156  yy_cp = yyg->yy_c_buf_p;
3157  goto yy_find_action;
3158  }
3159  }
3160 
3161  else switch ( yy_get_next_buffer( yyscanner ) )
3162  {
3163  case EOB_ACT_END_OF_FILE:
3164  {
3165  yyg->yy_did_buffer_switch_on_eof = 0;
3166 
3167  if ( octave_wrap(yyscanner ) )
3168  {
3169  /* Note: because we've taken care in
3170  * yy_get_next_buffer() to have set up
3171  * yytext, we can now set up
3172  * yy_c_buf_p so that if some total
3173  * hoser (like flex itself) wants to
3174  * call the scanner after we return the
3175  * YY_NULL, it'll still work - another
3176  * YY_NULL will get returned.
3177  */
3178  yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
3179 
3180  yy_act = YY_STATE_EOF(YY_START);
3181  goto do_action;
3182  }
3183 
3184  else
3185  {
3186  if ( ! yyg->yy_did_buffer_switch_on_eof )
3187  YY_NEW_FILE;
3188  }
3189  break;
3190  }
3191 
3192  case EOB_ACT_CONTINUE_SCAN:
3193  yyg->yy_c_buf_p =
3194  yyg->yytext_ptr + yy_amount_of_matched_text;
3195 
3196  yy_current_state = yy_get_previous_state( yyscanner );
3197 
3198  yy_cp = yyg->yy_c_buf_p;
3199  yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
3200  goto yy_match;
3201 
3202  case EOB_ACT_LAST_MATCH:
3203  yyg->yy_c_buf_p =
3204  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
3205 
3206  yy_current_state = yy_get_previous_state( yyscanner );
3207 
3208  yy_cp = yyg->yy_c_buf_p;
3209  yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
3210  goto yy_find_action;
3211  }
3212  break;
3213  }
3214 
3215  default:
3217  "fatal flex scanner internal error--no action found" );
3218  } /* end of action switch */
3219  } /* end of scanning one token */
3220 } /* end of octave_lex */
3221 
3222 /* yy_get_next_buffer - try to read in a new buffer
3223  *
3224  * Returns a code representing an action:
3225  * EOB_ACT_LAST_MATCH -
3226  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
3227  * EOB_ACT_END_OF_FILE - end of file
3228  */
3229 static int yy_get_next_buffer (yyscan_t yyscanner)
3230 {
3231  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3232  register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
3233  register char *source = yyg->yytext_ptr;
3234  register int number_to_move, i;
3235  int ret_val;
3236 
3237  if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
3239  "fatal flex scanner internal error--end of buffer missed" );
3240 
3241  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
3242  { /* Don't try to fill the buffer, so this is an EOF. */
3243  if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
3244  {
3245  /* We matched a single character, the EOB, so
3246  * treat this as a final EOF.
3247  */
3248  return EOB_ACT_END_OF_FILE;
3249  }
3250 
3251  else
3252  {
3253  /* We matched some text prior to the EOB, first
3254  * process it.
3255  */
3256  return EOB_ACT_LAST_MATCH;
3257  }
3258  }
3259 
3260  /* Try to read more data. */
3261 
3262  /* First move last chars to start of buffer. */
3263  number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
3264 
3265  for ( i = 0; i < number_to_move; ++i )
3266  *(dest++) = *(source++);
3267 
3268  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
3269  /* don't do the read, it's not guaranteed to return an EOF,
3270  * just force an EOF
3271  */
3272  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
3273 
3274  else
3275  {
3276  int num_to_read =
3277  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
3278 
3279  while ( num_to_read <= 0 )
3280  { /* Not enough room in the buffer - grow it. */
3281 
3282  /* just a shorter name for the current buffer */
3283  YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
3284 
3285  int yy_c_buf_p_offset =
3286  (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
3287 
3288  if ( b->yy_is_our_buffer )
3289  {
3290  int new_size = b->yy_buf_size * 2;
3291 
3292  if ( new_size <= 0 )
3293  b->yy_buf_size += b->yy_buf_size / 8;
3294  else
3295  b->yy_buf_size *= 2;
3296 
3297  b->yy_ch_buf = (char *)
3298  /* Include room in for 2 EOB chars. */
3299  octave_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
3300  }
3301  else
3302  /* Can't grow it, we don't own it. */
3303  b->yy_ch_buf = 0;
3304 
3305  if ( ! b->yy_ch_buf )
3307  "fatal error - scanner input buffer overflow" );
3308 
3309  yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
3310 
3311  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
3312  number_to_move - 1;
3313 
3314  }
3315 
3316  if ( num_to_read > YY_READ_BUF_SIZE )
3317  num_to_read = YY_READ_BUF_SIZE;
3318 
3319  /* Read in more data. */
3320  YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
3321  yyg->yy_n_chars, (size_t) num_to_read );
3322 
3323  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
3324  }
3325 
3326  if ( yyg->yy_n_chars == 0 )
3327  {
3328  if ( number_to_move == YY_MORE_ADJ )
3329  {
3330  ret_val = EOB_ACT_END_OF_FILE;
3331  octave_restart(yyin ,yyscanner);
3332  }
3333 
3334  else
3335  {
3336  ret_val = EOB_ACT_LAST_MATCH;
3337  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
3339  }
3340  }
3341 
3342  else
3343  ret_val = EOB_ACT_CONTINUE_SCAN;
3344 
3345  if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
3346  /* Extend the array by 50%, plus the number we really need. */
3347  yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
3348  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) octave_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
3349  if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
3350  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
3351  }
3352 
3353  yyg->yy_n_chars += number_to_move;
3356 
3357  yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
3358 
3359  return ret_val;
3360 }
3361 
3362 /* yy_get_previous_state - get the state just before the EOB char was reached */
3363 
3365 {
3366  register yy_state_type yy_current_state;
3367  register char *yy_cp;
3368  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3369 
3370  yy_current_state = yyg->yy_start;
3371  yy_current_state += YY_AT_BOL();
3372 
3373  for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
3374  {
3375  register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
3376  if ( yy_accept[yy_current_state] )
3377  {
3378  yyg->yy_last_accepting_state = yy_current_state;
3379  yyg->yy_last_accepting_cpos = yy_cp;
3380  }
3381  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
3382  {
3383  yy_current_state = (int) yy_def[yy_current_state];
3384  if ( yy_current_state >= 358 )
3385  yy_c = yy_meta[(unsigned int) yy_c];
3386  }
3387  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
3388  }
3389 
3390  return yy_current_state;
3391 }
3392 
3393 /* yy_try_NUL_trans - try to make a transition on the NUL character
3394  *
3395  * synopsis
3396  * next_state = yy_try_NUL_trans( current_state );
3397  */
3398  static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
3399 {
3400  register int yy_is_jam;
3401  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
3402  register char *yy_cp = yyg->yy_c_buf_p;
3403 
3404  register YY_CHAR yy_c = 1;
3405  if ( yy_accept[yy_current_state] )
3406  {
3407  yyg->yy_last_accepting_state = yy_current_state;
3408  yyg->yy_last_accepting_cpos = yy_cp;
3409  }
3410  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
3411  {
3412  yy_current_state = (int) yy_def[yy_current_state];
3413  if ( yy_current_state >= 358 )
3414  yy_c = yy_meta[(unsigned int) yy_c];
3415  }
3416  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
3417  yy_is_jam = (yy_current_state == 357);
3418 
3419  return yy_is_jam ? 0 : yy_current_state;
3420 }
3421 
3422  static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
3423 {
3424  register char *yy_cp;
3425  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3426 
3427  yy_cp = yyg->yy_c_buf_p;
3428 
3429  /* undo effects of setting up yytext */
3430  *yy_cp = yyg->yy_hold_char;
3431 
3432  if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
3433  { /* need to shift things up to make room */
3434  /* +2 for EOB chars. */
3435  register int number_to_move = yyg->yy_n_chars + 2;
3436  register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
3437  YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
3438  register char *source =
3439  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
3440 
3441  while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
3442  *--dest = *--source;
3443 
3444  yy_cp += (int) (dest - source);
3445  yy_bp += (int) (dest - source);
3446  YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
3447  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
3448 
3449  if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
3450  YY_FATAL_ERROR( "flex scanner push-back overflow" );
3451  }
3452 
3453  *--yy_cp = (char) c;
3454 
3455  yyg->yytext_ptr = yy_bp;
3456  yyg->yy_hold_char = *yy_cp;
3457  yyg->yy_c_buf_p = yy_cp;
3458 }
3459 
3460 #ifndef YY_NO_INPUT
3461 #ifdef __cplusplus
3462  static int yyinput (yyscan_t yyscanner)
3463 #else
3464  static int input (yyscan_t yyscanner)
3465 #endif
3466 
3467 {
3468  int c;
3469  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3470 
3471  *yyg->yy_c_buf_p = yyg->yy_hold_char;
3472 
3473  if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
3474  {
3475  /* yy_c_buf_p now points to the character we want to return.
3476  * If this occurs *before* the EOB characters, then it's a
3477  * valid NUL; if not, then we've hit the end of the buffer.
3478  */
3479  if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
3480  /* This was really a NUL. */
3481  *yyg->yy_c_buf_p = '\0';
3482 
3483  else
3484  { /* need more input */
3485  int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
3486  ++yyg->yy_c_buf_p;
3487 
3488  switch ( yy_get_next_buffer( yyscanner ) )
3489  {
3490  case EOB_ACT_LAST_MATCH:
3491  /* This happens because yy_g_n_b()
3492  * sees that we've accumulated a
3493  * token and flags that we need to
3494  * try matching the token before
3495  * proceeding. But for input(),
3496  * there's no matching to consider.
3497  * So convert the EOB_ACT_LAST_MATCH
3498  * to EOB_ACT_END_OF_FILE.
3499  */
3500 
3501  /* Reset buffer status. */
3502  octave_restart(yyin ,yyscanner);
3503 
3504  /*FALLTHROUGH*/
3505 
3506  case EOB_ACT_END_OF_FILE:
3507  {
3508  if ( octave_wrap(yyscanner ) )
3509  return EOF;
3510 
3511  if ( ! yyg->yy_did_buffer_switch_on_eof )
3512  YY_NEW_FILE;
3513 #ifdef __cplusplus
3514  return yyinput(yyscanner);
3515 #else
3516  return input(yyscanner);
3517 #endif
3518  }
3519 
3520  case EOB_ACT_CONTINUE_SCAN:
3521  yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
3522  break;
3523  }
3524  }
3525  }
3526 
3527  c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
3528  *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
3529  yyg->yy_hold_char = *++yyg->yy_c_buf_p;
3530 
3531  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
3532 
3533  return c;
3534 }
3535 #endif /* ifndef YY_NO_INPUT */
3536 
3537 /** Immediately switch to a different input stream.
3538  * @param input_file A readable stream.
3539  * @param yyscanner The scanner object.
3540  * @note This function does not reset the start condition to @c INITIAL .
3541  */
3542  void octave_restart (FILE * input_file , yyscan_t yyscanner)
3543 {
3544  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3545 
3546  if ( ! YY_CURRENT_BUFFER ){
3547  octave_ensure_buffer_stack (yyscanner);
3550  }
3551 
3552  octave__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
3553  octave__load_buffer_state(yyscanner );
3554 }
3555 
3556 /** Switch to a different input buffer.
3557  * @param new_buffer The new input buffer.
3558  * @param yyscanner The scanner object.
3559  */
3560  void octave__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
3561 {
3562  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3563 
3564  /* TODO. We should be able to replace this entire function body
3565  * with
3566  * octave_pop_buffer_state();
3567  * octave_push_buffer_state(new_buffer);
3568  */
3569  octave_ensure_buffer_stack (yyscanner);
3570  if ( YY_CURRENT_BUFFER == new_buffer )
3571  return;
3572 
3573  if ( YY_CURRENT_BUFFER )
3574  {
3575  /* Flush out information for old buffer. */
3576  *yyg->yy_c_buf_p = yyg->yy_hold_char;
3577  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
3578  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
3579  }
3580 
3581  YY_CURRENT_BUFFER_LVALUE = new_buffer;
3582  octave__load_buffer_state(yyscanner );
3583 
3584  /* We don't actually know whether we did this switch during
3585  * EOF (octave_wrap()) processing, but the only time this flag
3586  * is looked at is after octave_wrap() is called, so it's safe
3587  * to go ahead and always set it.
3588  */
3589  yyg->yy_did_buffer_switch_on_eof = 1;
3590 }
3591 
3592 static void octave__load_buffer_state (yyscan_t yyscanner)
3593 {
3594  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3595  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
3596  yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
3597  yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
3598  yyg->yy_hold_char = *yyg->yy_c_buf_p;
3599 }
3600 
3601 /** Allocate and initialize an input buffer state.
3602  * @param file A readable stream.
3603  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
3604  * @param yyscanner The scanner object.
3605  * @return the allocated buffer state.
3606  */
3607  YY_BUFFER_STATE octave__create_buffer (FILE * file, int size , yyscan_t yyscanner)
3608 {
3609  YY_BUFFER_STATE b;
3610 
3611  b = (YY_BUFFER_STATE) octave_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
3612  if ( ! b )
3613  YY_FATAL_ERROR( "out of dynamic memory in octave__create_buffer()" );
3614 
3615  b->yy_buf_size = size;
3616 
3617  /* yy_ch_buf has to be 2 characters longer than the size given because
3618  * we need to put in 2 end-of-buffer characters.
3619  */
3620  b->yy_ch_buf = (char *) octave_alloc(b->yy_buf_size + 2 ,yyscanner );
3621  if ( ! b->yy_ch_buf )
3622  YY_FATAL_ERROR( "out of dynamic memory in octave__create_buffer()" );
3623 
3624  b->yy_is_our_buffer = 1;
3625 
3626  octave__init_buffer(b,file ,yyscanner);
3627 
3628  return b;
3629 }
3630 
3631 /** Destroy the buffer.
3632  * @param b a buffer created with octave__create_buffer()
3633  * @param yyscanner The scanner object.
3634  */
3635  void octave__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
3636 {
3637  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3638 
3639  if ( ! b )
3640  return;
3641 
3642  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
3644 
3645  if ( b->yy_is_our_buffer )
3646  octave_free((void *) b->yy_ch_buf ,yyscanner );
3647 
3648  octave_free((void *) b ,yyscanner );
3649 }
3650 
3651 #ifndef __cplusplus
3652 extern int isatty (int );
3653 #endif /* __cplusplus */
3654 
3655 /* Initializes or reinitializes a buffer.
3656  * This function is sometimes called more than once on the same buffer,
3657  * such as during a octave_restart() or at EOF.
3658  */
3659  static void octave__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
3660 
3661 {
3662  int oerrno = errno;
3663  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3664 
3665  octave__flush_buffer(b ,yyscanner);
3666 
3667  b->yy_input_file = file;
3668  b->yy_fill_buffer = 1;
3669 
3670  /* If b is the current buffer, then octave__init_buffer was _probably_
3671  * called from octave_restart() or through yy_get_next_buffer.
3672  * In that case, we don't want to reset the lineno or column.
3673  */
3674  if (b != YY_CURRENT_BUFFER){
3675  b->yy_bs_lineno = 1;
3676  b->yy_bs_column = 0;
3677  }
3678 
3679  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
3680 
3681  errno = oerrno;
3682 }
3683 
3684 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
3685  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
3686  * @param yyscanner The scanner object.
3687  */
3688  void octave__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
3689 {
3690  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3691  if ( ! b )
3692  return;
3693 
3694  b->yy_n_chars = 0;
3695 
3696  /* We always need two end-of-buffer characters. The first causes
3697  * a transition to the end-of-buffer state. The second causes
3698  * a jam in that state.
3699  */
3702 
3703  b->yy_buf_pos = &b->yy_ch_buf[0];
3704 
3705  b->yy_at_bol = 1;
3707 
3708  if ( b == YY_CURRENT_BUFFER )
3709  octave__load_buffer_state(yyscanner );
3710 }
3711 
3712 /** Pushes the new state onto the stack. The new state becomes
3713  * the current state. This function will allocate the stack
3714  * if necessary.
3715  * @param new_buffer The new state.
3716  * @param yyscanner The scanner object.
3717  */
3718 void octave_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
3719 {
3720  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3721  if (new_buffer == NULL)
3722  return;
3723 
3724  octave_ensure_buffer_stack(yyscanner);
3725 
3726  /* This block is copied from octave__switch_to_buffer. */
3727  if ( YY_CURRENT_BUFFER )
3728  {
3729  /* Flush out information for old buffer. */
3730  *yyg->yy_c_buf_p = yyg->yy_hold_char;
3731  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
3732  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
3733  }
3734 
3735  /* Only push if top exists. Otherwise, replace top. */
3736  if (YY_CURRENT_BUFFER)
3737  yyg->yy_buffer_stack_top++;
3738  YY_CURRENT_BUFFER_LVALUE = new_buffer;
3739 
3740  /* copied from octave__switch_to_buffer. */
3741  octave__load_buffer_state(yyscanner );
3742  yyg->yy_did_buffer_switch_on_eof = 1;
3743 }
3744 
3745 /** Removes and deletes the top of the stack, if present.
3746  * The next element becomes the new top.
3747  * @param yyscanner The scanner object.
3748  */
3750 {
3751  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3752  if (!YY_CURRENT_BUFFER)
3753  return;
3754 
3756  YY_CURRENT_BUFFER_LVALUE = NULL;
3757  if (yyg->yy_buffer_stack_top > 0)
3758  --yyg->yy_buffer_stack_top;
3759 
3760  if (YY_CURRENT_BUFFER) {
3761  octave__load_buffer_state(yyscanner );
3762  yyg->yy_did_buffer_switch_on_eof = 1;
3763  }
3764 }
3765 
3766 /* Allocates the stack if it does not exist.
3767  * Guarantees space for at least one push.
3768  */
3769 static void octave_ensure_buffer_stack (yyscan_t yyscanner)
3770 {
3771  int num_to_alloc;
3772  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3773 
3774  if (!yyg->yy_buffer_stack) {
3775 
3776  /* First allocation is just for 2 elements, since we don't know if this
3777  * scanner will even need a stack. We use 2 instead of 1 to avoid an
3778  * immediate realloc on the next call.
3779  */
3780  num_to_alloc = 1;
3782  (num_to_alloc * sizeof(struct yy_buffer_state*)
3783  , yyscanner);
3784  if ( ! yyg->yy_buffer_stack )
3785  YY_FATAL_ERROR( "out of dynamic memory in octave_ensure_buffer_stack()" );
3786 
3787  memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3788 
3789  yyg->yy_buffer_stack_max = num_to_alloc;
3790  yyg->yy_buffer_stack_top = 0;
3791  return;
3792  }
3793 
3794  if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
3795 
3796  /* Increase the buffer to prepare for a possible push. */
3797  int grow_size = 8 /* arbitrary grow size */;
3798 
3799  num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
3801  (yyg->yy_buffer_stack,
3802  num_to_alloc * sizeof(struct yy_buffer_state*)
3803  , yyscanner);
3804  if ( ! yyg->yy_buffer_stack )
3805  YY_FATAL_ERROR( "out of dynamic memory in octave_ensure_buffer_stack()" );
3806 
3807  /* zero only the new slots.*/
3808  memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
3809  yyg->yy_buffer_stack_max = num_to_alloc;
3810  }
3811 }
3812 
3813 /** Setup the input buffer state to scan directly from a user-specified character buffer.
3814  * @param base the character buffer
3815  * @param size the size in bytes of the character buffer
3816  * @param yyscanner The scanner object.
3817  * @return the newly allocated buffer state object.
3818  */
3819 YY_BUFFER_STATE octave__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
3820 {
3821  YY_BUFFER_STATE b;
3822 
3823  if ( size < 2 ||
3824  base[size-2] != YY_END_OF_BUFFER_CHAR ||
3825  base[size-1] != YY_END_OF_BUFFER_CHAR )
3826  /* They forgot to leave room for the EOB's. */
3827  return 0;
3828 
3829  b = (YY_BUFFER_STATE) octave_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
3830  if ( ! b )
3831  YY_FATAL_ERROR( "out of dynamic memory in octave__scan_buffer()" );
3832 
3833  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
3834  b->yy_buf_pos = b->yy_ch_buf = base;
3835  b->yy_is_our_buffer = 0;
3836  b->yy_input_file = 0;
3837  b->yy_n_chars = b->yy_buf_size;
3838  b->yy_is_interactive = 0;
3839  b->yy_at_bol = 1;
3840  b->yy_fill_buffer = 0;
3842 
3843  octave__switch_to_buffer(b ,yyscanner );
3844 
3845  return b;
3846 }
3847 
3848 /** Setup the input buffer state to scan a string. The next call to octave_lex() will
3849  * scan from a @e copy of @a str.
3850  * @param yystr a NUL-terminated string to scan
3851  * @param yyscanner The scanner object.
3852  * @return the newly allocated buffer state object.
3853  * @note If you want to scan bytes that may contain NUL values, then use
3854  * octave__scan_bytes() instead.
3855  */
3856 YY_BUFFER_STATE octave__scan_string (yyconst char * yystr , yyscan_t yyscanner)
3857 {
3858 
3859  return octave__scan_bytes(yystr,strlen(yystr) ,yyscanner);
3860 }
3861 
3862 /** Setup the input buffer state to scan the given bytes. The next call to octave_lex() will
3863  * scan from a @e copy of @a bytes.
3864  * @param yybytes the byte buffer to scan
3865  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
3866  * @param yyscanner The scanner object.
3867  * @return the newly allocated buffer state object.
3868  */
3869 YY_BUFFER_STATE octave__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
3870 {
3871  YY_BUFFER_STATE b;
3872  char *buf;
3873  yy_size_t n;
3874  int i;
3875 
3876  /* Get memory for full buffer, including space for trailing EOB's. */
3877  n = _yybytes_len + 2;
3878  buf = (char *) octave_alloc(n ,yyscanner );
3879  if ( ! buf )
3880  YY_FATAL_ERROR( "out of dynamic memory in octave__scan_bytes()" );
3881 
3882  for ( i = 0; i < _yybytes_len; ++i )
3883  buf[i] = yybytes[i];
3884 
3885  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
3886 
3887  b = octave__scan_buffer(buf,n ,yyscanner);
3888  if ( ! b )
3889  YY_FATAL_ERROR( "bad buffer in octave__scan_bytes()" );
3890 
3891  /* It's okay to grow etc. this buffer, and we should throw it
3892  * away when we're done.
3893  */
3894  b->yy_is_our_buffer = 1;
3895 
3896  return b;
3897 }
3898 
3899 #ifndef YY_EXIT_FAILURE
3900 #define YY_EXIT_FAILURE 2
3901 #endif
3902 
3903 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
3904 {
3905  (void) fprintf( stderr, "%s\n", msg );
3906  exit( YY_EXIT_FAILURE );
3907 }
3908 
3909 /* Redefine yyless() so it works in section 3 code. */
3910 
3911 #undef yyless
3912 #define yyless(n) \
3913  do \
3914  { \
3915  /* Undo effects of setting up yytext. */ \
3916  int yyless_macro_arg = (n); \
3917  YY_LESS_LINENO(yyless_macro_arg);\
3918  yytext[yyleng] = yyg->yy_hold_char; \
3919  yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
3920  yyg->yy_hold_char = *yyg->yy_c_buf_p; \
3921  *yyg->yy_c_buf_p = '\0'; \
3922  yyleng = yyless_macro_arg; \
3923  } \
3924  while ( 0 )
3925 
3926 /* Accessor methods (get/set functions) to struct members. */
3927 
3928 /** Get the user-defined data for this scanner.
3929  * @param yyscanner The scanner object.
3930  */
3932 {
3933  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3934  return yyextra;
3935 }
3936 
3937 /** Get the current line number.
3938  * @param yyscanner The scanner object.
3939  */
3941 {
3942  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3943 
3944  if (! YY_CURRENT_BUFFER)
3945  return 0;
3946 
3947  return yylineno;
3948 }
3949 
3950 /** Get the current column number.
3951  * @param yyscanner The scanner object.
3952  */
3954 {
3955  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3956 
3957  if (! YY_CURRENT_BUFFER)
3958  return 0;
3959 
3960  return yycolumn;
3961 }
3962 
3963 /** Get the input stream.
3964  * @param yyscanner The scanner object.
3965  */
3966 FILE *octave_get_in (yyscan_t yyscanner)
3967 {
3968  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3969  return yyin;
3970 }
3971 
3972 /** Get the output stream.
3973  * @param yyscanner The scanner object.
3974  */
3975 FILE *octave_get_out (yyscan_t yyscanner)
3976 {
3977  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3978  return yyout;
3979 }
3980 
3981 /** Get the length of the current token.
3982  * @param yyscanner The scanner object.
3983  */
3984 int octave_get_leng (yyscan_t yyscanner)
3985 {
3986  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3987  return yyleng;
3988 }
3989 
3990 /** Get the current token.
3991  * @param yyscanner The scanner object.
3992  */
3993 
3994 char *octave_get_text (yyscan_t yyscanner)
3995 {
3996  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3997  return yytext;
3998 }
3999 
4000 /** Set the user-defined data. This data is never touched by the scanner.
4001  * @param user_defined The data to be associated with this scanner.
4002  * @param yyscanner The scanner object.
4003  */
4004 void octave_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
4005 {
4006  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4007  yyextra = user_defined ;
4008 }
4009 
4010 /** Set the current line number.
4011  * @param line_number
4012  * @param yyscanner The scanner object.
4013  */
4014 void octave_set_lineno (int line_number , yyscan_t yyscanner)
4015 {
4016  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4017 
4018  /* lineno is only valid if an input buffer exists. */
4019  if (! YY_CURRENT_BUFFER )
4020  yy_fatal_error( "octave_set_lineno called with no buffer" , yyscanner);
4021 
4022  yylineno = line_number;
4023 }
4024 
4025 /** Set the current column.
4026  * @param line_number
4027  * @param yyscanner The scanner object.
4028  */
4029 void octave_set_column (int column_no , yyscan_t yyscanner)
4030 {
4031  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4032 
4033  /* column is only valid if an input buffer exists. */
4034  if (! YY_CURRENT_BUFFER )
4035  yy_fatal_error( "octave_set_column called with no buffer" , yyscanner);
4036 
4037  yycolumn = column_no;
4038 }
4039 
4040 /** Set the input stream. This does not discard the current
4041  * input buffer.
4042  * @param in_str A readable stream.
4043  * @param yyscanner The scanner object.
4044  * @see octave__switch_to_buffer
4045  */
4046 void octave_set_in (FILE * in_str , yyscan_t yyscanner)
4047 {
4048  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4049  yyin = in_str ;
4050 }
4051 
4052 void octave_set_out (FILE * out_str , yyscan_t yyscanner)
4053 {
4054  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4055  yyout = out_str ;
4056 }
4057 
4059 {
4060  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4061  return yy_flex_debug;
4062 }
4063 
4064 void octave_set_debug (int bdebug , yyscan_t yyscanner)
4065 {
4066  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4067  yy_flex_debug = bdebug ;
4068 }
4069 
4070 /* Accessor methods for yylval and yylloc */
4071 
4073 {
4074  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4075  return yylval;
4076 }
4077 
4078 void octave_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
4079 {
4080  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4081  yylval = yylval_param;
4082 }
4083 
4084 /* User-visible API */
4085 
4086 /* octave_lex_init is special because it creates the scanner itself, so it is
4087  * the ONLY reentrant function that doesn't take the scanner as the last argument.
4088  * That's why we explicitly handle the declaration, instead of using our macros.
4089  */
4090 
4091 int octave_lex_init(yyscan_t* ptr_yy_globals)
4092 
4093 {
4094  if (ptr_yy_globals == NULL){
4095  errno = EINVAL;
4096  return 1;
4097  }
4098 
4099  *ptr_yy_globals = (yyscan_t) octave_alloc ( sizeof( struct yyguts_t ), NULL );
4100 
4101  if (*ptr_yy_globals == NULL){
4102  errno = ENOMEM;
4103  return 1;
4104  }
4105 
4106  /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
4107  memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
4108 
4109  return yy_init_globals ( *ptr_yy_globals );
4110 }
4111 
4112 /* octave_lex_init_extra has the same functionality as octave_lex_init, but follows the
4113  * convention of taking the scanner as the last argument. Note however, that
4114  * this is a *pointer* to a scanner, as it will be allocated by this call (and
4115  * is the reason, too, why this function also must handle its own declaration).
4116  * The user defined value in the first argument will be available to octave_alloc in
4117  * the yyextra field.
4118  */
4119 
4120 int octave_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
4121 
4122 {
4123  struct yyguts_t dummy_yyguts;
4124 
4125  octave_set_extra (yy_user_defined, &dummy_yyguts);
4126 
4127  if (ptr_yy_globals == NULL){
4128  errno = EINVAL;
4129  return 1;
4130  }
4131 
4132  *ptr_yy_globals = (yyscan_t) octave_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
4133 
4134  if (*ptr_yy_globals == NULL){
4135  errno = ENOMEM;
4136  return 1;
4137  }
4138 
4139  /* By setting to 0xAA, we expose bugs in
4140  yy_init_globals. Leave at 0x00 for releases. */
4141  memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
4142 
4143  octave_set_extra (yy_user_defined, *ptr_yy_globals);
4144 
4145  return yy_init_globals ( *ptr_yy_globals );
4146 }
4147 
4148 static int yy_init_globals (yyscan_t yyscanner)
4149 {
4150  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4151  /* Initialization is the same as for the non-reentrant scanner.
4152  * This function is called from octave_lex_destroy(), so don't allocate here.
4153  */
4154 
4155  yyg->yy_buffer_stack = 0;
4156  yyg->yy_buffer_stack_top = 0;
4157  yyg->yy_buffer_stack_max = 0;
4158  yyg->yy_c_buf_p = (char *) 0;
4159  yyg->yy_init = 0;
4160  yyg->yy_start = 0;
4161 
4162  yyg->yy_start_stack_ptr = 0;
4163  yyg->yy_start_stack_depth = 0;
4164  yyg->yy_start_stack = NULL;
4165 
4166 /* Defined in main.c */
4167 #ifdef YY_STDINIT
4168  yyin = stdin;
4169  yyout = stdout;
4170 #else
4171  yyin = (FILE *) 0;
4172  yyout = (FILE *) 0;
4173 #endif
4174 
4175  /* For future reference: Set errno on error, since we are called by
4176  * octave_lex_init()
4177  */
4178  return 0;
4179 }
4180 
4181 /* octave_lex_destroy is for both reentrant and non-reentrant scanners. */
4183 {
4184  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
4185 
4186  /* Pop the buffer stack, destroying each element. */
4187  while(YY_CURRENT_BUFFER){
4189  YY_CURRENT_BUFFER_LVALUE = NULL;
4190  octave_pop_buffer_state(yyscanner);
4191  }
4192 
4193  /* Destroy the stack itself. */
4194  octave_free(yyg->yy_buffer_stack ,yyscanner);
4195  yyg->yy_buffer_stack = NULL;
4196 
4197  /* Destroy the start condition stack. */
4198  octave_free(yyg->yy_start_stack ,yyscanner );
4199  yyg->yy_start_stack = NULL;
4200 
4201  /* Reset the globals. This is important in a non-reentrant scanner so the next time
4202  * octave_lex() is called, initialization will occur. */
4203  yy_init_globals( yyscanner);
4204 
4205  /* Destroy the main struct (reentrant only). */
4206  octave_free ( yyscanner , yyscanner );
4207  yyscanner = NULL;
4208  return 0;
4209 }
4210 
4211 /*
4212  * Internal utility routines.
4213  */
4214 
4215 #ifndef yytext_ptr
4216 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
4217 {
4218  register int i;
4219  for ( i = 0; i < n; ++i )
4220  s1[i] = s2[i];
4221 }
4222 #endif
4223 
4224 #ifdef YY_NEED_STRLEN
4225 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
4226 {
4227  register int n;
4228  for ( n = 0; s[n]; ++n )
4229  ;
4230 
4231  return n;
4232 }
4233 #endif
4234 
4236 {
4237  return (void *) malloc( size );
4238 }
4239 
4240 void *octave_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
4241 {
4242  /* The cast to (char *) in the following accommodates both
4243  * implementations that use char* generic pointers, and those
4244  * that use void* generic pointers. It works with the latter
4245  * because both ANSI C and C++ allow castless assignment from
4246  * any pointer type to void*, and deal with argument conversions
4247  * as though doing an assignment.
4248  */
4249  return (void *) realloc( (char *) ptr, size );
4250 }
4251 
4252 void octave_free (void * ptr , yyscan_t yyscanner)
4253 {
4254  free( (char *) ptr ); /* see octave_realloc() for (char *) cast */
4255 }
4256 
4257 #define YYTABLES_NAME "yytables"
4258 
4259 #line 1534 "../../libinterp/parse-tree/lex.ll"
4260 
4261 
4262 
4263 static void
4265 {
4266  if (isgraph (c))
4267  std::cerr << c;
4268  else
4269  switch (c)
4270  {
4271  case 0:
4272  std::cerr << "NUL";
4273  break;
4274 
4275  case 1:
4276  std::cerr << "SOH";
4277  break;
4278 
4279  case 2:
4280  std::cerr << "STX";
4281  break;
4282 
4283  case 3:
4284  std::cerr << "ETX";
4285  break;
4286 
4287  case 4:
4288  std::cerr << "EOT";
4289  break;
4290 
4291  case 5:
4292  std::cerr << "ENQ";
4293  break;
4294 
4295  case 6:
4296  std::cerr << "ACK";
4297  break;
4298 
4299  case 7:
4300  std::cerr << "\\a";
4301  break;
4302 
4303  case 8:
4304  std::cerr << "\\b";
4305  break;
4306 
4307  case 9:
4308  std::cerr << "\\t";
4309  break;
4310 
4311  case 10:
4312  std::cerr << "\\n";
4313  break;
4314 
4315  case 11:
4316  std::cerr << "\\v";
4317  break;
4318 
4319  case 12:
4320  std::cerr << "\\f";
4321  break;
4322 
4323  case 13:
4324  std::cerr << "\\r";
4325  break;
4326 
4327  case 14:
4328  std::cerr << "SO";
4329  break;
4330 
4331  case 15:
4332  std::cerr << "SI";
4333  break;
4334 
4335  case 16:
4336  std::cerr << "DLE";
4337  break;
4338 
4339  case 17:
4340  std::cerr << "DC1";
4341  break;
4342 
4343  case 18:
4344  std::cerr << "DC2";
4345  break;
4346 
4347  case 19:
4348  std::cerr << "DC3";
4349  break;
4350 
4351  case 20:
4352  std::cerr << "DC4";
4353  break;
4354 
4355  case 21:
4356  std::cerr << "NAK";
4357  break;
4358 
4359  case 22:
4360  std::cerr << "SYN";
4361  break;
4362 
4363  case 23:
4364  std::cerr << "ETB";
4365  break;
4366 
4367  case 24:
4368  std::cerr << "CAN";
4369  break;
4370 
4371  case 25:
4372  std::cerr << "EM";
4373  break;
4374 
4375  case 26:
4376  std::cerr << "SUB";
4377  break;
4378 
4379  case 27:
4380  std::cerr << "ESC";
4381  break;
4382 
4383  case 28:
4384  std::cerr << "FS";
4385  break;
4386 
4387  case 29:
4388  std::cerr << "GS";
4389  break;
4390 
4391  case 30:
4392  std::cerr << "RS";
4393  break;
4394 
4395  case 31:
4396  std::cerr << "US";
4397  break;
4398 
4399  case 32:
4400  std::cerr << "SPACE";
4401  break;
4402 
4403  case 127:
4404  std::cerr << "DEL";
4405  break;
4406  }
4407 }
4408 
4409 bool
4410 is_keyword (const std::string& s)
4411 {
4412  // Parsing function names like "set.property_name" inside
4413  // classdef-style class definitions is simplified by handling the
4414  // "set" and "get" portions of the names using the same mechanism as
4415  // is used for keywords. However, they are not really keywords in
4416  // the language, so omit them from the list of possible keywords.
4417 
4418  return (octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0
4419  && ! (s == "set" || s == "get"));
4420 }
4421 
4422 DEFUN (iskeyword, args, ,
4423  "-*- texinfo -*-\n\
4424 @deftypefn {Built-in Function} {} iskeyword ()\n\
4425 @deftypefnx {Built-in Function} {} iskeyword (@var{name})\n\
4426 Return true if @var{name} is an Octave keyword. If @var{name}\n\
4427 is omitted, return a list of keywords.\n\
4428 @seealso{isvarname, exist}\n\
4429 @end deftypefn")
4430 {
4431  octave_value retval;
4432 
4433  int argc = args.length () + 1;
4434 
4435  string_vector argv = args.make_argv ("iskeyword");
4436 
4437  if (error_state)
4438  return retval;
4439 
4440  if (argc == 1)
4441  {
4442  // Neither set and get are keywords. See the note in the
4443  // is_keyword function for additional details.
4444 
4446 
4447  int j = 0;
4448 
4449  for (int i = 0; i < TOTAL_KEYWORDS; i++)
4450  {
4451  std::string tmp = wordlist[i].name;
4452 
4453  if (! (tmp == "set" || tmp == "get"))
4454  lst[j++] = tmp;
4455  }
4456 
4457  lst.resize (j);
4458 
4459  retval = Cell (lst.sort ());
4460  }
4461  else if (argc == 2)
4462  {
4463  retval = is_keyword (argv[1]);
4464  }
4465  else
4466  print_usage ();
4467 
4468  return retval;
4469 }
4470 
4471 /*
4472 
4473 %!assert (iskeyword ("for"))
4474 %!assert (iskeyword ("fort"), false)
4475 %!assert (iskeyword ("fft"), false)
4476 
4477 */
4478 
4479 // Used to delete trailing white space from tokens.
4480 
4481 static std::string
4483 {
4484  std::string retval = s;
4485 
4486  size_t pos = retval.find_first_of (" \t");
4487 
4488  if (pos != std::string::npos)
4489  retval.resize (pos);
4490 
4491  return retval;
4492 }
4493 
4494 DEFUN (__display_tokens__, args, nargout,
4495  "-*- texinfo -*-\n\
4496 @deftypefn {Built-in Function} {} __display_tokens__ ()\n\
4497 Query or set the internal variable that determines whether Octave's\n\
4498 lexer displays tokens as they are read.\n\
4499 @end deftypefn")
4500 {
4501  return SET_INTERNAL_VARIABLE (display_tokens);
4502 }
4503 
4504 DEFUN (__token_count__, , ,
4505  "-*- texinfo -*-\n\
4506 @deftypefn {Built-in Function} {} __token_count__ ()\n\
4507 Number of language tokens processed since Octave startup.\n\
4508 @end deftypefn")
4509 {
4510  return octave_value (Vtoken_count);
4511 }
4512 
4513 DEFUN (__lexer_debug_flag__, args, nargout,
4514  "-*- texinfo -*-\n\
4515 @deftypefn {Built-in Function} {@var{old_val} =} __lexer_debug_flag__ (@var{new_val}))\n\
4516 Undocumented internal function.\n\
4517 @end deftypefn")
4518 {
4519  octave_value retval;
4520 
4521  retval = set_internal_variable (lexer_debug_flag, args, nargout,
4522  "__lexer_debug_flag__");
4523 
4524  return retval;
4525 }
4526 
4528 {
4529  tokens.clear ();
4530 }
4531 
4532 void
4534 {
4535  // The closest paren, brace, or bracket nesting is not an object
4536  // index.
4537  looking_at_object_index.push_front (false);
4538 }
4539 
4540 void
4542 {
4543  end_of_input = false;
4545  looking_at_anon_fcn_args = false;
4546  looking_at_return_list = false;
4547  looking_at_parameter_list = false;
4548  looking_at_decl_list = false;
4551  looking_for_object_index = false;
4552  looking_at_indirect_ref = false;
4553  parsing_class_method = false;
4555  parsing_classdef = false;
4556  force_script = false;
4557  reading_fcn_file = false;
4558  reading_script_file = false;
4559  reading_classdef_file = false;
4560  input_line_number = 1;
4562  bracketflag = 0;
4563  braceflag = 0;
4564  looping = 0;
4565  defining_func = 0;
4568  token_count = 0;
4569  current_input_line = "";
4570  comment_text = "";
4571  help_text = "";
4572  string_text = "";
4573  string_line = 0;
4574  string_column = 0;
4575  fcn_file_name = "";
4576  fcn_file_full_name = "";
4577  looking_at_object_index.clear ();
4578  looking_at_object_index.push_front (false);
4579 
4580  while (! parsed_function_name.empty ())
4581  parsed_function_name.pop ();
4582 
4583  nesting_level.reset ();
4584 
4585  tokens.clear ();
4586 }
4587 
4588 int
4590 {
4591  const token *tok = tokens.front ();
4592  return tok ? tok->token_value () : 0;
4593 }
4594 
4595 bool
4597 {
4598  const token *tok = tokens.front ();
4599  return tok ? tok->token_value_is (tok_val) : false;
4600 }
4601 
4602 void
4604 {
4605  token *tok = tokens.front ();
4606  if (tok && ! previous_token_value_is ('\n'))
4607  tok->mark_trailing_space ();
4608 }
4609 
4610 bool
4612 {
4613  const token *tok = tokens.front ();
4614  return tok ? tok->space_follows_token () : false;
4615 }
4616 
4617 bool
4619 {
4620  int tok = previous_token_value ();
4621 
4622  return (tok == '+' || tok == '-' || tok == '@'
4623  || tok == ',' || tok == ';' || tok == '*' || tok == '/'
4624  || tok == ':' || tok == '=' || tok == ADD_EQ
4625  || tok == AND_EQ || tok == DIV_EQ || tok == EDIV
4626  || tok == EDIV_EQ || tok == ELEFTDIV || tok == ELEFTDIV_EQ
4627  || tok == EMINUS || tok == EMUL || tok == EMUL_EQ
4628  || tok == EPOW || tok == EPOW_EQ || tok == EXPR_AND
4629  || tok == EXPR_AND_AND || tok == EXPR_EQ || tok == EXPR_GE
4630  || tok == EXPR_GT || tok == EXPR_LE || tok == EXPR_LT
4631  || tok == EXPR_NE || tok == EXPR_NOT || tok == EXPR_OR
4632  || tok == EXPR_OR_OR || tok == LEFTDIV || tok == LEFTDIV_EQ
4633  || tok == LSHIFT || tok == LSHIFT_EQ || tok == MUL_EQ
4634  || tok == OR_EQ || tok == POW || tok == POW_EQ
4635  || tok == RSHIFT || tok == RSHIFT_EQ || tok == SUB_EQ);
4636 }
4637 
4638 bool
4640 {
4641  const token *tok = tokens.front ();
4642  return tok ? tok->is_keyword () : false;
4643 }
4644 
4645 bool
4647 {
4648  const token *tok = tokens.front ();
4649  return tok ? tok->may_be_command () : false;
4650 }
4651 
4652 void
4654 {
4655  token *tok = tokens.front ();
4656 
4657  if (tok && tok->is_symbol ())
4658  pending_local_variables.insert (tok->symbol_name ());
4659 }
4660 
4661 void
4662 lexical_feedback::mark_as_variables (const std::list<std::string>& lst)
4663 {
4664  for (std::list<std::string>::const_iterator p = lst.begin ();
4665  p != lst.end (); p++)
4666  {
4667  pending_local_variables.insert (*p);
4668  }
4669 }
4670 
4671 static bool
4672 looks_like_copyright (const std::string& s)
4673 {
4674  bool retval = false;
4675 
4676  if (! s.empty ())
4677  {
4678  size_t offset = s.find_first_not_of (" \t");
4679 
4680  retval = (s.substr (offset, 9) == "Copyright" || s.substr (offset, 6) == "Author");
4681  }
4682 
4683  return retval;
4684 }
4685 
4686 void
4687 octave_base_lexer::input_buffer::fill (const std::string& input, bool eof_arg)
4688 {
4689  buffer = input;
4690  chars_left = buffer.length ();
4691  pos = buffer.c_str ();
4692  eof = eof_arg;
4693 }
4694 
4695 int
4697 {
4698  static const char * const eol = "\n";
4699 
4700  size_t len = max_size > chars_left ? chars_left : max_size;
4701  assert (len > 0);
4702 
4703  memcpy (buf, pos, len);
4704 
4705  chars_left -= len;
4706  pos += len;
4707 
4708  // Make sure input ends with a new line character.
4709  if (chars_left == 0 && buf[len-1] != '\n')
4710  {
4711  if (len < max_size)
4712  {
4713  // There is enough room to plug the newline character in
4714  // the buffer.
4715  buf[len++] = '\n';
4716  }
4717  else
4718  {
4719  // There isn't enough room to plug the newline character
4720  // in the buffer so arrange to have it returned on the next
4721  // call to octave_base_lexer::read.
4722  pos = eol;
4723  chars_left = 1;
4724  }
4725  }
4726 
4727  return len;
4728 }
4729 
4731 {
4733 }
4734 
4735 void
4737 {
4739 
4740  // Make octave_base_lexer object available through yyextra in
4741  // flex-generated lexer.
4742  octave_set_extra (this, scanner);
4743 
4744  clear_start_state ();
4745 }
4746 
4747 // Inside Flex-generated functions, yyg is the scanner cast to its real
4748 // type. Some flex macros that we use in octave_base_lexer member functions
4749 // (for example, BEGIN) use yyg. If we could perform the actions of
4750 // these macros with functions instead, we could eliminate the
4751 // OCTAVE_YYG macro.
4752 
4753 #define OCTAVE_YYG \
4754  struct yyguts_t *yyg = static_cast<struct yyguts_t*> (scanner)
4755 
4756 void
4758 {
4759  // Start off on the right foot.
4760  clear_start_state ();
4761 
4762  symtab_context.clear ();
4763 
4764  // We do want a prompt by default.
4765  promptflag (1);
4766 
4767  // Only ask for input from stdin if we are expecting interactive
4768  // input.
4769 
4770  if (! quitting_gracefully
4772  && ! (reading_fcn_file
4775  || input_from_eval_string ()))
4776  octave_restart (stdin, scanner);
4777 
4779 
4780  comment_buf.reset ();
4781 }
4782 
4783 void
4785 {
4786  reading_script_file = true;
4787 
4789 }
4790 
4791 void
4793 {
4796 
4797  push_start_state (state);
4798 }
4799 
4800 int
4802 {
4803  lexer_debug ("<<EOF>>");
4804 
4805  if (block_comment_nesting_level != 0)
4806  {
4807  warning ("block comment open at end of input");
4808 
4810  && ! fcn_file_name.empty ())
4811  warning ("near line %d of file '%s.m'",
4812  input_line_number, fcn_file_name.c_str ());
4813  }
4814 
4815  return handle_token (END_OF_INPUT);
4816 }
4817 
4818 char *
4820 {
4821  return octave_get_text (scanner);
4822 }
4823 
4824 int
4826 {
4827  return octave_get_leng (scanner);
4828 }
4829 
4830 int
4832 {
4833  int c = yyinput (scanner);
4834 
4835  if (lexer_debug_flag)
4836  {
4837  std::cerr << "I: ";
4838  display_character (c);
4839  std::cerr << std::endl;
4840  }
4841 
4842  // Convert CRLF into just LF and single CR into LF.
4843 
4844  if (c == '\r')
4845  {
4846  c = yyinput (scanner);
4847 
4848  if (lexer_debug_flag)
4849  {
4850  std::cerr << "I: ";
4851  display_character (c);
4852  std::cerr << std::endl;
4853  }
4854 
4855  if (c != '\n')
4856  {
4857  xunput (c);
4858  c = '\n';
4859  }
4860  }
4861 
4862  return c;
4863 }
4864 
4865 void
4866 octave_base_lexer::xunput (char c, char *buf)
4867 {
4868  if (c != EOF)
4869  {
4870  if (lexer_debug_flag)
4871  {
4872  std::cerr << "U: ";
4873  display_character (c);
4874  std::cerr << std::endl;
4875  }
4876 
4877  yyunput (c, buf, scanner);
4878  }
4879 }
4880 
4881 void
4883 {
4884  char *yytxt = flex_yytext ();
4885 
4886  xunput (c, yytxt);
4887 }
4888 
4889 bool
4891 {
4892  int c = text_yyinput ();
4893  xunput (c);
4894  return (c == ' ' || c == '\t');
4895 }
4896 
4897 bool
4899 {
4900  bool retval = false;
4901 
4902  for (std::list<bool>::const_iterator i = looking_at_object_index.begin ();
4903  i != looking_at_object_index.end (); i++)
4904  {
4905  if (*i)
4906  {
4907  retval = true;
4908  break;
4909  }
4910  }
4911 
4912  return retval;
4913 }
4914 
4915 bool
4916 octave_base_lexer::is_variable (const std::string& name)
4917 {
4918  return (symbol_table::is_variable (name)
4919  || (pending_local_variables.find (name)
4920  != pending_local_variables.end ()));
4921 }
4922 
4923 // Handle keywords. Return -1 if the keyword should be ignored.
4924 
4925 int
4927 {
4928  int l = input_line_number;
4929  int c = current_input_column;
4930 
4931  int len = s.length ();
4932 
4933  const octave_kw *kw = octave_kw_hash::in_word_set (s.c_str (), len);
4934 
4935  if (kw)
4936  {
4937  // May be reset to true for some token types.
4938  at_beginning_of_statement = false;
4939 
4940  token *tok_val = 0;
4941 
4942  switch (kw->kw_id)
4943  {
4944  case break_kw:
4945  case catch_kw:
4946  case continue_kw:
4947  case else_kw:
4948  case otherwise_kw:
4949  case return_kw:
4952  break;
4953 
4954  case static_kw:
4957  && ! fcn_file_full_name.empty ())
4958  warning_with_id ("Octave:deprecated-keyword",
4959  "the 'static' keyword is obsolete and will be removed from a future version of Octave; please use 'persistent' instead; near line %d of file '%s'",
4961  fcn_file_full_name.c_str ());
4962  else
4963  warning_with_id ("Octave:deprecated-keyword",
4964  "the 'static' keyword is obsolete and will be removed from a future version of Octave; please use 'persistent' instead; near line %d",
4966  // fall through ...
4967 
4968  case persistent_kw:
4969  case global_kw:
4970  looking_at_decl_list = true;
4971  break;
4972 
4973  case case_kw:
4974  case elseif_kw:
4975  case until_kw:
4976  break;
4977 
4978  case end_kw:
4980  || (! reading_classdef_file
4981  && (defining_func
4983  || parsed_function_name.top ()))))
4984  return 0;
4985 
4986  tok_val = new token (end_kw, token::simple_end, l, c);
4988  break;
4989 
4990  case end_try_catch_kw:
4991  tok_val = new token (end_try_catch_kw, token::try_catch_end, l, c);
4993  break;
4994 
4995  case end_unwind_protect_kw:
4996  tok_val = new token (end_unwind_protect_kw,
4999  break;
5000 
5001  case endfor_kw:
5002  tok_val = new token (endfor_kw, token::for_end, l, c);
5004  break;
5005 
5006  case endfunction_kw:
5007  tok_val = new token (endfunction_kw, token::function_end, l, c);
5009  break;
5010 
5011  case endif_kw:
5012  tok_val = new token (endif_kw, token::if_end, l, c);
5014  break;
5015 
5016  case endparfor_kw:
5017  tok_val = new token (endparfor_kw, token::parfor_end, l, c);
5019  break;
5020 
5021  case endswitch_kw:
5022  tok_val = new token (endswitch_kw, token::switch_end, l, c);
5024  break;
5025 
5026  case endwhile_kw:
5027  tok_val = new token (endwhile_kw, token::while_end, l, c);
5029  break;
5030 
5031  case endclassdef_kw:
5032  tok_val = new token (endclassdef_kw, token::classdef_end, l, c);
5034  break;
5035 
5036  case endenumeration_kw:
5037  tok_val = new token (endenumeration_kw, token::enumeration_end, l, c);
5039  break;
5040 
5041  case endevents_kw:
5042  tok_val = new token (endevents_kw, token::events_end, l, c);
5044  break;
5045 
5046  case endmethods_kw:
5047  tok_val = new token (endmethods_kw, token::methods_end, l, c);
5049  break;
5050 
5051  case endproperties_kw:
5052  tok_val = new token (endproperties_kw, token::properties_end, l, c);
5054  break;
5055 
5056 
5057  case for_kw:
5058  case parfor_kw:
5059  case while_kw:
5061  looping++;
5062  break;
5063 
5064  case do_kw:
5067  looping++;
5068  break;
5069 
5070  case try_kw:
5071  case unwind_protect_kw:
5074  break;
5075 
5076  case if_kw:
5077  case switch_kw:
5079  break;
5080 
5081  case get_kw:
5082  case set_kw:
5083  // 'get' and 'set' are keywords in classdef method
5084  // declarations.
5086  return 0;
5087  break;
5088 
5089  case enumeration_kw:
5090  case events_kw:
5091  case methods_kw:
5092  case properties_kw:
5093  // 'properties', 'methods' and 'events' are keywords for
5094  // classdef blocks.
5095  if (! parsing_classdef)
5096  return 0;
5097  // fall through ...
5098 
5099  case classdef_kw:
5100  // 'classdef' is always a keyword.
5102 
5103  if (! force_script && token_count == 0 && input_from_file ())
5104  {
5105  reading_classdef_file = true;
5106  reading_script_file = false;
5107  }
5108  break;
5109 
5110  case function_kw:
5112 
5113  defining_func++;
5114  parsed_function_name.push (false);
5115 
5116  if (! force_script && token_count == 0 && input_from_file ())
5117  {
5118  reading_fcn_file = true;
5119  reading_script_file = false;
5120  }
5121 
5124  input_line_number = 1;
5125  break;
5126 
5127  case magic_file_kw:
5128  {
5131  && ! fcn_file_full_name.empty ())
5132  tok_val = new token (magic_file_kw, true,
5133  fcn_file_full_name, l, c);
5134  else
5135  tok_val = new token (magic_file_kw, "stdin", l, c);
5136  }
5137  break;
5138 
5139  case magic_line_kw:
5140  tok_val = new token (magic_line_kw, static_cast<double> (l),
5141  "", l, c);
5142  break;
5143 
5144  default:
5145  panic_impossible ();
5146  }
5147 
5148  if (! tok_val)
5149  tok_val = new token (kw->tok, true, l, c);
5150 
5151  push_token (tok_val);
5152 
5153  return kw->tok;
5154  }
5155 
5156  return 0;
5157 }
5158 
5159 bool
5161 {
5162  return (nesting_level.is_bracket ()
5163  || (nesting_level.is_brace ()
5164  && ! looking_at_object_index.front ()));
5165 }
5166 
5167 static inline bool
5168 looks_like_hex (const char *s, int len)
5169 {
5170  return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'));
5171 }
5172 
5173 void
5175 {
5176  double value = 0.0;
5177  int nread = 0;
5178 
5179  char *yytxt = flex_yytext ();
5180 
5181  if (looks_like_hex (yytxt, strlen (yytxt)))
5182  {
5183  unsigned long ival;
5184 
5185  nread = sscanf (yytxt, "%lx", &ival);
5186 
5187  value = static_cast<double> (ival);
5188  }
5189  else
5190  {
5191  char *tmp = strsave (yytxt);
5192 
5193  char *idx = strpbrk (tmp, "Dd");
5194 
5195  if (idx)
5196  *idx = 'e';
5197 
5198  nread = sscanf (tmp, "%lf", &value);
5199 
5200  delete [] tmp;
5201  }
5202 
5203  // If yytext doesn't contain a valid number, we are in deep doo doo.
5204 
5205  assert (nread == 1);
5206 
5207  looking_for_object_index = false;
5208  at_beginning_of_statement = false;
5209 
5210  push_token (new token (NUM, value, yytxt, input_line_number,
5212 
5214 }
5215 
5216 void
5218 {
5219  char *yytxt = flex_yytext ();
5220  int yylng = flex_yyleng ();
5221 
5222  int offset = 1;
5223  if (yytxt[0] == '\\')
5225  else
5226  offset = 3;
5227 
5228  bool have_space = false;
5229  while (offset < yylng)
5230  {
5231  char c = yytxt[offset];
5232  if (c == ' ' || c == '\t')
5233  {
5234  have_space = true;
5235  offset++;
5236  }
5237  else
5238  break;
5239  }
5240 
5241  if (have_space)
5243 
5244  bool have_comment = false;
5245  while (offset < yylng)
5246  {
5247  char c = yytxt[offset];
5248  if (c == '#' || c == '%')
5249  {
5250  have_comment = true;
5251  offset++;
5252  }
5253  else
5254  break;
5255  }
5256 
5257  if (have_comment)
5258  {
5259  comment_text = &yytxt[offset];
5260 
5262  }
5263 
5267 }
5268 
5269 void
5271 {
5272  bool copyright = looks_like_copyright (comment_text);
5273 
5274  if (nesting_level.none () && help_text.empty ()
5275  && ! comment_text.empty () && ! copyright)
5277 
5278  if (copyright)
5280 
5282 
5283  comment_text = "";
5284 
5286 }
5287 
5288 int
5290 {
5291  int retval = bracket_type;
5292 
5293  if (! nesting_level.none ())
5294  {
5295  nesting_level.remove ();
5296 
5297  if (bracket_type == ']')
5298  bracketflag--;
5299  else if (bracket_type == '}')
5300  braceflag--;
5301  else
5302  panic_impossible ();
5303  }
5304 
5305  pop_start_state ();
5306 
5307  return retval;
5308 }
5309 
5310 bool
5312 {
5313  bool space_before = space_follows_previous_token ();
5314  bool space_after = looking_at_space ();
5315 
5316  return (space_before && ! space_after
5318 }
5319 
5320 int
5322 {
5323  std::string pkg;
5324  char *yytxt = flex_yytext ();
5325  std::string meth = strip_trailing_whitespace (yytxt);
5326  size_t pos = meth.find ("@");
5327  std::string cls = meth.substr (pos).substr (1);
5328  meth = meth.substr (0, pos - 1);
5329 
5330  pos = cls.find (".");
5331  if (pos != std::string::npos)
5332  {
5333  pkg = cls.substr (pos).substr (1);
5334  cls = cls.substr (0, pos - 1);
5335  }
5336 
5337  int kw_token = (is_keyword_token (meth) || is_keyword_token (cls)
5338  || is_keyword_token (pkg));
5339  if (kw_token)
5340  {
5341  error ("method, class and package names may not be keywords");
5342  return LEXICAL_ERROR;
5343  }
5344 
5346 
5347  push_token (new token
5348  (SUPERCLASSREF,
5349  meth.empty () ? 0 : &(symbol_table::insert (meth, sid)),
5350  cls.empty () ? 0 : &(symbol_table::insert (cls, sid)),
5351  pkg.empty () ? 0 : &(symbol_table::insert (pkg, sid)),
5353 
5355 
5356  return SUPERCLASSREF;
5357 }
5358 
5359 int
5361 {
5362  std::string pkg;
5363  char *yytxt = flex_yytext ();
5364  std::string cls = strip_trailing_whitespace (yytxt).substr (1);
5365  size_t pos = cls.find (".");
5366 
5367  if (pos != std::string::npos)
5368  {
5369  pkg = cls.substr (pos).substr (1);
5370  cls = cls.substr (0, pos - 1);
5371  }
5372 
5373  int kw_token = is_keyword_token (cls) || is_keyword_token (pkg);
5374  if (kw_token)
5375  {
5376  error ("class and package names may not be keywords");
5377  return LEXICAL_ERROR;
5378  }
5379 
5381 
5382  push_token (new token
5383  (METAQUERY,
5384  cls.empty () ? 0 : &(symbol_table::insert (cls, sid)),
5385  pkg.empty () ? 0 : &(symbol_table::insert (pkg, sid)),
5387 
5389 
5390  return METAQUERY;
5391 }
5392 
5393 // Figure out exactly what kind of token to return when we have seen
5394 // an identifier. Handles keywords. Return -1 if the identifier
5395 // should be ignored.
5396 
5397 int
5399 {
5400  char *yytxt = flex_yytext ();
5401 
5402  std::string tok = yytxt;
5403 
5404  // If we are expecting a structure element, avoid recognizing
5405  // keywords and other special names and return STRUCT_ELT, which is
5406  // a string that is also a valid identifier. But first, we have to
5407  // decide whether to insert a comma.
5408 
5410  {
5413 
5414  looking_for_object_index = true;
5415 
5417 
5418  assert (! at_beginning_of_statement);
5419 
5420  return STRUCT_ELT;
5421  }
5422 
5423  // If tok is a keyword token, then is_keyword_token will set
5424  // at_beginning_of_statement. For example, if tok is and IF
5425  // token, then at_beginning_of_statement will be false.
5426 
5427  int kw_token = is_keyword_token (tok);
5428 
5430  {
5431  if (kw_token)
5432  {
5433  error ("function handles may not refer to keywords");
5434 
5435  return LEXICAL_ERROR;
5436  }
5437  else
5438  {
5441 
5443  looking_for_object_index = true;
5444 
5445  at_beginning_of_statement = false;
5446 
5447  return FCN_HANDLE;
5448  }
5449  }
5450 
5451  // If we have a regular keyword, return it.
5452  // Keywords can be followed by identifiers.
5453 
5454  if (kw_token)
5455  {
5456  if (kw_token >= 0)
5457  {
5459  looking_for_object_index = false;
5460  }
5461 
5462  // The call to is_keyword_token set at_beginning_of_statement.
5463 
5464  return kw_token;
5465  }
5466 
5467  // Find the token in the symbol table.
5468 
5470 
5471  token *tok_val = new token (NAME, &(symbol_table::insert (tok, sid)),
5473 
5474  // The following symbols are handled specially so that things like
5475  //
5476  // pi +1
5477  //
5478  // are parsed as an addition expression instead of as a command-style
5479  // function call with the argument "+1".
5480 
5482  && (! (is_variable (tok)
5483  || tok == "e" || tok == "pi"
5484  || tok == "I" || tok == "i"
5485  || tok == "J" || tok == "j"
5486  || tok == "Inf" || tok == "inf"
5487  || tok == "NaN" || tok == "nan")))
5488  tok_val->mark_may_be_command ();
5489 
5490  push_token (tok_val);
5491 
5493 
5494  // The magic end index can't be indexed.
5495 
5496  if (tok != "end")
5497  looking_for_object_index = true;
5498 
5499  at_beginning_of_statement = false;
5500 
5501  return NAME;
5502 }
5503 
5504 void
5506 {
5507  std::string nm = fcn_file_full_name;
5508 
5509  if (nm.empty ())
5510  warning_with_id ("Octave:separator-insert",
5511  "potential auto-insertion of '%c' near line %d",
5512  sep, input_line_number);
5513  else
5514  warning_with_id ("Octave:separator-insert",
5515  "potential auto-insertion of '%c' near line %d of file %s",
5516  sep, input_line_number, nm.c_str ());
5517 }
5518 
5519 void
5521 {
5522  std::string nm = fcn_file_full_name;
5523 
5524  if (nm.empty ())
5525  warning_with_id ("Octave:single-quote-string",
5526  "single quote delimited string near line %d",
5528  else
5529  warning_with_id ("Octave:single-quote-string",
5530  "single quote delimited string near line %d of file %s",
5531  input_line_number, nm.c_str ());
5532 }
5533 
5534 void
5536 {
5537  std::string nm = fcn_file_full_name;
5538 
5539  if (nm.empty ())
5540  warning_with_id ("Octave:matlab-incompatible",
5541  "potential Matlab compatibility problem: %s",
5542  msg.c_str ());
5543  else
5544  warning_with_id ("Octave:matlab-incompatible",
5545  "potential Matlab compatibility problem: %s near line %d offile %s",
5546  msg.c_str (), input_line_number, nm.c_str ());
5547 }
5548 
5549 void
5551 {
5552  if (c == '#')
5553  gripe_matlab_incompatible ("# used as comment character");
5554 }
5555 
5556 void
5558 {
5559  gripe_matlab_incompatible ("\\ used as line continuation marker");
5560 }
5561 
5562 void
5564 {
5565  std::string t = op;
5566  int n = t.length ();
5567  if (t[n-1] == '\n')
5568  t.resize (n-1);
5569  gripe_matlab_incompatible (t + " used as operator");
5570 }
5571 
5572 void
5574 {
5575  YYSTYPE *lval = octave_get_lval (scanner);
5576  lval->tok_val = tok;
5577  tokens.push (tok);
5578 }
5579 
5580 token *
5582 {
5583  YYSTYPE *lval = octave_get_lval (scanner);
5584  return lval->tok_val;
5585 }
5586 
5587 void
5589 {
5590  switch (tok)
5591  {
5592  case '=': std::cerr << "'='\n"; break;
5593  case ':': std::cerr << "':'\n"; break;
5594  case '-': std::cerr << "'-'\n"; break;
5595  case '+': std::cerr << "'+'\n"; break;
5596  case '*': std::cerr << "'*'\n"; break;
5597  case '/': std::cerr << "'/'\n"; break;
5598  case ADD_EQ: std::cerr << "ADD_EQ\n"; break;
5599  case SUB_EQ: std::cerr << "SUB_EQ\n"; break;
5600  case MUL_EQ: std::cerr << "MUL_EQ\n"; break;
5601  case DIV_EQ: std::cerr << "DIV_EQ\n"; break;
5602  case LEFTDIV_EQ: std::cerr << "LEFTDIV_EQ\n"; break;
5603  case POW_EQ: std::cerr << "POW_EQ\n"; break;
5604  case EMUL_EQ: std::cerr << "EMUL_EQ\n"; break;
5605  case EDIV_EQ: std::cerr << "EDIV_EQ\n"; break;
5606  case ELEFTDIV_EQ: std::cerr << "ELEFTDIV_EQ\n"; break;
5607  case EPOW_EQ: std::cerr << "EPOW_EQ\n"; break;
5608  case AND_EQ: std::cerr << "AND_EQ\n"; break;
5609  case OR_EQ: std::cerr << "OR_EQ\n"; break;
5610  case LSHIFT_EQ: std::cerr << "LSHIFT_EQ\n"; break;
5611  case RSHIFT_EQ: std::cerr << "RSHIFT_EQ\n"; break;
5612  case LSHIFT: std::cerr << "LSHIFT\n"; break;
5613  case RSHIFT: std::cerr << "RSHIFT\n"; break;
5614  case EXPR_AND_AND: std::cerr << "EXPR_AND_AND\n"; break;
5615  case EXPR_OR_OR: std::cerr << "EXPR_OR_OR\n"; break;
5616  case EXPR_AND: std::cerr << "EXPR_AND\n"; break;
5617  case EXPR_OR: std::cerr << "EXPR_OR\n"; break;
5618  case EXPR_NOT: std::cerr << "EXPR_NOT\n"; break;
5619  case EXPR_LT: std::cerr << "EXPR_LT\n"; break;
5620  case EXPR_LE: std::cerr << "EXPR_LE\n"; break;
5621  case EXPR_EQ: std::cerr << "EXPR_EQ\n"; break;
5622  case EXPR_NE: std::cerr << "EXPR_NE\n"; break;
5623  case EXPR_GE: std::cerr << "EXPR_GE\n"; break;
5624  case EXPR_GT: std::cerr << "EXPR_GT\n"; break;
5625  case LEFTDIV: std::cerr << "LEFTDIV\n"; break;
5626  case EMUL: std::cerr << "EMUL\n"; break;
5627  case EDIV: std::cerr << "EDIV\n"; break;
5628  case ELEFTDIV: std::cerr << "ELEFTDIV\n"; break;
5629  case EPLUS: std::cerr << "EPLUS\n"; break;
5630  case EMINUS: std::cerr << "EMINUS\n"; break;
5631  case HERMITIAN: std::cerr << "HERMITIAN\n"; break;
5632  case TRANSPOSE: std::cerr << "TRANSPOSE\n"; break;
5633  case PLUS_PLUS: std::cerr << "PLUS_PLUS\n"; break;
5634  case MINUS_MINUS: std::cerr << "MINUS_MINUS\n"; break;
5635  case POW: std::cerr << "POW\n"; break;
5636  case EPOW: std::cerr << "EPOW\n"; break;
5637 
5638  case NUM:
5639  case IMAG_NUM:
5640  {
5641  token *tok_val = current_token ();
5642  std::cerr << (tok == NUM ? "NUM" : "IMAG_NUM")
5643  << " [" << tok_val->number () << "]\n";
5644  }
5645  break;
5646 
5647  case STRUCT_ELT:
5648  {
5649  token *tok_val = current_token ();
5650  std::cerr << "STRUCT_ELT [" << tok_val->text () << "]\n";
5651  }
5652  break;
5653 
5654  case NAME:
5655  {
5656  token *tok_val = current_token ();
5657  symbol_table::symbol_record *sr = tok_val->sym_rec ();
5658  std::cerr << "NAME";
5659  if (sr)
5660  std::cerr << " [" << sr->name () << "]";
5661  std::cerr << "\n";
5662  }
5663  break;
5664 
5665  case END: std::cerr << "END\n"; break;
5666 
5667  case DQ_STRING:
5668  case SQ_STRING:
5669  {
5670  token *tok_val = current_token ();
5671 
5672  std::cerr << (tok == DQ_STRING ? "DQ_STRING" : "SQ_STRING")
5673  << " [" << tok_val->text () << "]\n";
5674  }
5675  break;
5676 
5677  case FOR: std::cerr << "FOR\n"; break;
5678  case WHILE: std::cerr << "WHILE\n"; break;
5679  case DO: std::cerr << "DO\n"; break;
5680  case UNTIL: std::cerr << "UNTIL\n"; break;
5681  case IF: std::cerr << "IF\n"; break;
5682  case ELSEIF: std::cerr << "ELSEIF\n"; break;
5683  case ELSE: std::cerr << "ELSE\n"; break;
5684  case SWITCH: std::cerr << "SWITCH\n"; break;
5685  case CASE: std::cerr << "CASE\n"; break;
5686  case OTHERWISE: std::cerr << "OTHERWISE\n"; break;
5687  case BREAK: std::cerr << "BREAK\n"; break;
5688  case CONTINUE: std::cerr << "CONTINUE\n"; break;
5689  case FUNC_RET: std::cerr << "FUNC_RET\n"; break;
5690  case UNWIND: std::cerr << "UNWIND\n"; break;
5691  case CLEANUP: std::cerr << "CLEANUP\n"; break;
5692  case TRY: std::cerr << "TRY\n"; break;
5693  case CATCH: std::cerr << "CATCH\n"; break;
5694  case GLOBAL: std::cerr << "GLOBAL\n"; break;
5695  case PERSISTENT: std::cerr << "PERSISTENT\n"; break;
5696  case FCN_HANDLE: std::cerr << "FCN_HANDLE\n"; break;
5697  case END_OF_INPUT: std::cerr << "END_OF_INPUT\n\n"; break;
5698  case LEXICAL_ERROR: std::cerr << "LEXICAL_ERROR\n\n"; break;
5699  case FCN: std::cerr << "FCN\n"; break;
5700  case INPUT_FILE: std::cerr << "INPUT_FILE\n"; break;
5701  case SUPERCLASSREF: std::cerr << "SUPERCLASSREF\n"; break;
5702  case METAQUERY: std::cerr << "METAQUERY\n"; break;
5703  case GET: std::cerr << "GET\n"; break;
5704  case SET: std::cerr << "SET\n"; break;
5705  case PROPERTIES: std::cerr << "PROPERTIES\n"; break;
5706  case METHODS: std::cerr << "METHODS\n"; break;
5707  case EVENTS: std::cerr << "EVENTS\n"; break;
5708  case CLASSDEF: std::cerr << "CLASSDEF\n"; break;
5709  case '\n': std::cerr << "\\n\n"; break;
5710  case '\r': std::cerr << "\\r\n"; break;
5711  case '\t': std::cerr << "TAB\n"; break;
5712  default:
5713  {
5714  if (tok < 256 && tok > 31)
5715  std::cerr << static_cast<char> (tok) << "\n";
5716  else
5717  std::cerr << "UNKNOWN(" << tok << ")\n";
5718  }
5719  break;
5720  }
5721 }
5722 
5723 void
5725 {
5726  error (msg);
5727 
5728  OCTAVE_QUIT;
5729 
5730  yy_fatal_error (msg, scanner);
5731 }
5732 
5733 void
5734 octave_base_lexer::lexer_debug (const char *pattern)
5735 {
5736  if (lexer_debug_flag)
5737  {
5738  std::cerr << std::endl;
5739 
5741 
5742  std::cerr << "P: " << pattern << std::endl;
5743  std::cerr << "T: " << flex_yytext () << std::endl;
5744  }
5745 }
5746 
5747 void
5749 {
5750  OCTAVE_YYG;
5751 
5752  start_state_stack.push (state);
5753 
5754  BEGIN (start_state ());
5755 }
5756 
5757 void
5759 {
5760  OCTAVE_YYG;
5761 
5762  start_state_stack.pop ();
5763 
5764  BEGIN (start_state ());
5765 }
5766 
5767 void
5769 {
5770  while (! start_state_stack.empty ())
5771  start_state_stack.pop ();
5772 
5774 }
5775 
5776 void
5778 {
5779  std::cerr << "S: ";
5780 
5781  switch (start_state ())
5782  {
5783  case INITIAL:
5784  std::cerr << "INITIAL" << std::endl;
5785  break;
5786 
5787  case COMMAND_START:
5788  std::cerr << "COMMAND_START" << std::endl;
5789  break;
5790 
5791  case MATRIX_START:
5792  std::cerr << "MATRIX_START" << std::endl;
5793  break;
5794 
5795  case INPUT_FILE_START:
5796  std::cerr << "INPUT_FILE_BEGIN" << std::endl;
5797  break;
5798 
5799  case BLOCK_COMMENT_START:
5800  std::cerr << "BLOCK_COMMENT_START" << std::endl;
5801  break;
5802 
5803  case LINE_COMMENT_START:
5804  std::cerr << "LINE_COMMENT_START" << std::endl;
5805  break;
5806 
5807  case DQ_STRING_START:
5808  std::cerr << "DQ_STRING_START" << std::endl;
5809  break;
5810 
5811  case SQ_STRING_START:
5812  std::cerr << "SQ_STRING_START" << std::endl;
5813  break;
5814 
5815  default:
5816  std::cerr << "UNKNOWN START STATE!" << std::endl;
5817  break;
5818  }
5819 }
5820 
5821 int
5822 octave_base_lexer::handle_op (const char *pattern, int tok, bool bos)
5823 {
5824  lexer_debug (pattern);
5825 
5826  return handle_op_internal (tok, bos, true);
5827 }
5828 
5829 int
5830 octave_base_lexer::handle_incompatible_op (const char *pattern, int tok,
5831  bool bos)
5832 {
5833  lexer_debug (pattern);
5834 
5835  return handle_op_internal (tok, bos, false);
5836 }
5837 
5838 bool
5840 {
5841  int prev_tok = previous_token_value ();
5842 
5843  bool unput_comma = false;
5844 
5846  {
5847  int c = text_yyinput ();
5848  xunput (c);
5849 
5850  bool space_after = (c == ' ' || c == '\t');
5851 
5852  if (! (prev_tok == '[' || prev_tok == '{'
5854  || ((tok == '+' || tok == '-') && space_after)))
5855  unput_comma = true;
5856  }
5857 
5858  return unput_comma;
5859 }
5860 
5861 int
5863 {
5865  ? -1 : handle_op_internal (tok, bos, true);
5866 }
5867 
5868 int
5870 {
5872  ? -1 : handle_op_internal (tok, bos, false);
5873 }
5874 
5875 int
5876 octave_base_lexer::handle_op_internal (int tok, bool bos, bool compat)
5877 {
5878  if (! compat)
5880 
5882 
5884  looking_for_object_index = false;
5886 
5887  return count_token_internal (tok);
5888 }
5889 
5890 int
5891 octave_base_lexer::handle_token (const std::string& name, int tok)
5892 {
5893  token *tok_val = new token (tok, name, input_line_number,
5895 
5896  return handle_token (tok, tok_val);
5897 }
5898 
5899 int
5901 {
5902  if (! tok_val)
5903  tok_val = new token (tok, input_line_number, current_input_column);
5904 
5905  push_token (tok_val);
5906 
5908 
5909  return count_token_internal (tok);
5910 }
5911 
5912 int
5914 {
5915  token *tok_val = new token (tok, input_line_number, current_input_column);
5916 
5917  push_token (tok_val);
5918 
5919  return count_token_internal (tok);
5920 }
5921 
5922 int
5924 {
5925  if (tok != '\n')
5926  {
5927  Vtoken_count++;
5928  token_count++;
5929  }
5930 
5931  return show_token (tok);
5932 }
5933 
5934 int
5936 {
5937  if (Vdisplay_tokens)
5938  display_token (tok);
5939 
5940  if (lexer_debug_flag)
5941  {
5942  std::cerr << "R: ";
5943  display_token (tok);
5944  std::cerr << std::endl;
5945  }
5946 
5947  return tok;
5948 }
5949 
5950 int
5951 octave_lexer::fill_flex_buffer (char *buf, unsigned max_size)
5952 {
5953  int status = 0;
5954 
5955  if (input_buf.empty ())
5956  {
5957  bool eof = false;
5958  current_input_line = input_reader.get_input (eof);
5960  }
5961 
5962  if (! input_buf.empty ())
5963  status = input_buf.copy_chunk (buf, max_size);
5964  else
5965  {
5966  status = YY_NULL;
5967 
5968  if (! input_buf.at_eof ())
5969  fatal_error ("octave_base_lexer::fill_flex_buffer failed");
5970  }
5971 
5972  return status;
5973 }
5974 
5975 int
5976 octave_push_lexer::fill_flex_buffer (char *buf, unsigned max_size)
5977 {
5978  int status = 0;
5979 
5980  if (input_buf.empty () && ! input_buf.at_eof ())
5981  input_buf.fill (std::string (1, static_cast<char> (1)), false);
5982 
5983  if (! input_buf.empty ())
5984  status = input_buf.copy_chunk (buf, max_size);
5985  else
5986  {
5987  status = YY_NULL;
5988 
5989  if (! input_buf.at_eof ())
5990  fatal_error ("octave_base_lexer::fill_flex_buffer failed");
5991  }
5992 
5993  return status;
5994 }
5995