My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scan_csv.cpp
Go to the documentation of this file.
1 #line 2 "scan_csv.cpp"
2 
3 #line 4 "scan_csv.cpp"
4 
5 #define YY_INT_ALIGNED short int
6 
7 /* A lexical scanner generated by flex */
8 
9 #define yy_create_buffer csv__create_buffer
10 #define yy_delete_buffer csv__delete_buffer
11 #define yy_flex_debug csv__flex_debug
12 #define yy_init_buffer csv__init_buffer
13 #define yy_flush_buffer csv__flush_buffer
14 #define yy_load_buffer_state csv__load_buffer_state
15 #define yy_switch_to_buffer csv__switch_to_buffer
16 #define yyin csv_in
17 #define yyleng csv_leng
18 #define yylex csv_lex
19 #define yylineno csv_lineno
20 #define yyout csv_out
21 #define yyrestart csv_restart
22 #define yytext csv_text
23 #define yywrap csv_wrap
24 #define yyalloc csv_alloc
25 #define yyrealloc csv_realloc
26 #define yyfree csv_free
27 
28 #define FLEX_SCANNER
29 #define YY_FLEX_MAJOR_VERSION 2
30 #define YY_FLEX_MINOR_VERSION 5
31 #define YY_FLEX_SUBMINOR_VERSION 35
32 #if YY_FLEX_SUBMINOR_VERSION > 0
33 #define FLEX_BETA
34 #endif
35 
36 /* First, we deal with platform-specific or compiler-specific issues. */
37 
38 /* begin standard C headers. */
39 #include <stdio.h>
40 #include <string.h>
41 #include <errno.h>
42 #include <stdlib.h>
43 
44 /* end standard C headers. */
45 
46 /* flex integer type definitions */
47 
48 #ifndef FLEXINT_H
49 #define FLEXINT_H
50 
51 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
52 
53 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
54 
55 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
56  * if you want the limit (max/min) macros for int types.
57  */
58 #ifndef __STDC_LIMIT_MACROS
59 #define __STDC_LIMIT_MACROS 1
60 #endif
61 
62 #include <inttypes.h>
63 typedef int8_t flex_int8_t;
64 typedef uint8_t flex_uint8_t;
65 typedef int16_t flex_int16_t;
66 typedef uint16_t flex_uint16_t;
67 typedef int32_t flex_int32_t;
68 typedef uint32_t flex_uint32_t;
69 #else
70 typedef signed char flex_int8_t;
71 typedef short int flex_int16_t;
72 typedef int flex_int32_t;
73 typedef unsigned char flex_uint8_t;
74 typedef unsigned short int flex_uint16_t;
75 typedef unsigned int flex_uint32_t;
76 
77 /* Limits of integral types. */
78 #ifndef INT8_MIN
79 #define INT8_MIN (-128)
80 #endif
81 #ifndef INT16_MIN
82 #define INT16_MIN (-32767-1)
83 #endif
84 #ifndef INT32_MIN
85 #define INT32_MIN (-2147483647-1)
86 #endif
87 #ifndef INT8_MAX
88 #define INT8_MAX (127)
89 #endif
90 #ifndef INT16_MAX
91 #define INT16_MAX (32767)
92 #endif
93 #ifndef INT32_MAX
94 #define INT32_MAX (2147483647)
95 #endif
96 #ifndef UINT8_MAX
97 #define UINT8_MAX (255U)
98 #endif
99 #ifndef UINT16_MAX
100 #define UINT16_MAX (65535U)
101 #endif
102 #ifndef UINT32_MAX
103 #define UINT32_MAX (4294967295U)
104 #endif
105 
106 #endif /* ! C99 */
107 
108 #endif /* ! FLEXINT_H */
109 
110 #ifdef __cplusplus
111 
112 /* The "const" storage-class-modifier is valid. */
113 #define YY_USE_CONST
114 
115 #else /* ! __cplusplus */
116 
117 /* C99 requires __STDC__ to be defined as 1. */
118 #if defined (__STDC__)
119 
120 #define YY_USE_CONST
121 
122 #endif /* defined (__STDC__) */
123 #endif /* ! __cplusplus */
124 
125 #ifdef YY_USE_CONST
126 #define yyconst const
127 #else
128 #define yyconst
129 #endif
130 
131 /* Returned upon end-of-file. */
132 #define YY_NULL 0
133 
134 /* Promotes a possibly negative, possibly signed char to an unsigned
135  * integer for use as an array index. If the signed char is negative,
136  * we want to instead treat it as an 8-bit unsigned char, hence the
137  * double cast.
138  */
139 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
140 
141 /* Enter a start condition. This macro really ought to take a parameter,
142  * but we do it the disgusting crufty way forced on us by the ()-less
143  * definition of BEGIN.
144  */
145 #define BEGIN (yy_start) = 1 + 2 *
146 
147 /* Translate the current start state into a value that can be later handed
148  * to BEGIN to return to the state. The YYSTATE alias is for lex
149  * compatibility.
150  */
151 #define YY_START (((yy_start) - 1) / 2)
152 #define YYSTATE YY_START
153 
154 /* Action number for EOF rule of a given start state. */
155 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
156 
157 /* Special action meaning "start processing a new file". */
158 #define YY_NEW_FILE csv_restart(csv_in )
159 
160 #define YY_END_OF_BUFFER_CHAR 0
161 
162 /* Size of default input buffer. */
163 #ifndef YY_BUF_SIZE
164 #ifdef __ia64__
165 /* On IA-64, the buffer size is 16k, not 8k.
166  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
167  * Ditto for the __ia64__ case accordingly.
168  */
169 #define YY_BUF_SIZE 32768
170 #else
171 #define YY_BUF_SIZE 16384
172 #endif /* __ia64__ */
173 #endif
174 
175 /* The state buf must be large enough to hold one state per character in the main buffer.
176  */
177 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
178 
179 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
180 #define YY_TYPEDEF_YY_BUFFER_STATE
182 #endif
183 
184 extern int csv_leng;
185 
186 extern FILE *csv_in, *csv_out;
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  /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
193  * access to the local variable yy_act. Since yyless() is a macro, it would break
194  * existing scanners that call yyless() from OUTSIDE csv_lex.
195  * One obvious solution it to make yy_act a global. I tried that, and saw
196  * a 5% performance hit in a non-csv_lineno scanner, because yy_act is
197  * normally declared as a register variable-- so it is not worth it.
198  */
199  #define YY_LESS_LINENO(n) \
200  do { \
201  int yyl;\
202  for ( yyl = n; yyl < csv_leng; ++yyl )\
203  if ( csv_text[yyl] == '\n' )\
204  --csv_lineno;\
205  }while(0)
206 
207 /* Return all but the first "n" matched characters back to the input stream. */
208 #define yyless(n) \
209  do \
210  { \
211  /* Undo effects of setting up csv_text. */ \
212  int yyless_macro_arg = (n); \
213  YY_LESS_LINENO(yyless_macro_arg);\
214  *yy_cp = (yy_hold_char); \
215  YY_RESTORE_YY_MORE_OFFSET \
216  (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
217  YY_DO_BEFORE_ACTION; /* set up csv_text again */ \
218  } \
219  while ( 0 )
220 
221 #define unput(c) yyunput( c, (yytext_ptr) )
222 
223 #ifndef YY_TYPEDEF_YY_SIZE_T
224 #define YY_TYPEDEF_YY_SIZE_T
225 typedef size_t yy_size_t;
226 #endif
227 
228 #ifndef YY_STRUCT_YY_BUFFER_STATE
229 #define YY_STRUCT_YY_BUFFER_STATE
230 struct yy_buffer_state
231  {
232  FILE *yy_input_file;
233 
234  char *yy_ch_buf; /* input buffer */
235  char *yy_buf_pos; /* current position in input buffer */
236 
237  /* Size of input buffer in bytes, not including room for EOB
238  * characters.
239  */
241 
242  /* Number of characters read into yy_ch_buf, not including EOB
243  * characters.
244  */
245  int yy_n_chars;
246 
247  /* Whether we "own" the buffer - i.e., we know we created it,
248  * and can realloc() it to grow it, and should free() it to
249  * delete it.
250  */
251  int yy_is_our_buffer;
252 
253  /* Whether this is an "interactive" input source; if so, and
254  * if we're using stdio for input, then we want to use getc()
255  * instead of fread(), to make sure we stop fetching input after
256  * each newline.
257  */
258  int yy_is_interactive;
259 
260  /* Whether we're considered to be at the beginning of a line.
261  * If so, '^' rules will be active on the next match, otherwise
262  * not.
263  */
264  int yy_at_bol;
265 
266  int yy_bs_lineno;
267  int yy_bs_column;
269  /* Whether to try to fill the input buffer when we reach the
270  * end of it.
271  */
272  int yy_fill_buffer;
273 
274  int yy_buffer_status;
275 
276 #define YY_BUFFER_NEW 0
277 #define YY_BUFFER_NORMAL 1
278  /* When an EOF's been seen but there's still some text to process
279  * then we mark the buffer as YY_EOF_PENDING, to indicate that we
280  * shouldn't try reading from the input source any more. We might
281  * still have a bunch of tokens to match, though, because of
282  * possible backing-up.
283  *
284  * When we actually see the EOF, we change the status to "new"
285  * (via csv_restart()), so that the user can continue scanning by
286  * just pointing csv_in at a new input file.
287  */
288 #define YY_BUFFER_EOF_PENDING 2
289 
290  };
291 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
292 
293 /* Stack of input buffers. */
294 static size_t yy_buffer_stack_top = 0;
295 static size_t yy_buffer_stack_max = 0;
296 static YY_BUFFER_STATE * yy_buffer_stack = 0;
298 /* We provide macros for accessing buffer states in case in the
299  * future we want to put the buffer states in a more general
300  * "scanner state".
301  *
302  * Returns the top of the stack, or NULL.
303  */
304 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
305  ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
306  : NULL)
307 
308 /* Same as previous macro, but useful when we know that the buffer stack is not
309  * NULL or when we need an lvalue. For internal use only.
310  */
311 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
312 
313 /* yy_hold_char holds the character lost when csv_text is formed. */
314 static char yy_hold_char;
315 static int yy_n_chars; /* number of characters read into yy_ch_buf */
317 
318 /* Points to current character in buffer. */
319 static char *yy_c_buf_p = (char *) 0;
320 static int yy_init = 0; /* whether we need to initialize */
321 static int yy_start = 0; /* start state number */
322 
323 /* Flag which is used to allow csv_wrap()'s to do buffer switches
324  * instead of setting up a fresh csv_in. A bit of a hack ...
325  */
326 static int yy_did_buffer_switch_on_eof;
327 
328 void csv_restart (FILE *input_file );
329 void csv__switch_to_buffer (YY_BUFFER_STATE new_buffer );
330 YY_BUFFER_STATE csv__create_buffer (FILE *file,int size );
331 void csv__delete_buffer (YY_BUFFER_STATE b );
332 void csv__flush_buffer (YY_BUFFER_STATE b );
333 void csv_push_buffer_state (YY_BUFFER_STATE new_buffer );
334 void csv_pop_buffer_state (void );
335 
336 static void csv_ensure_buffer_stack (void );
337 static void csv__load_buffer_state (void );
338 static void csv__init_buffer (YY_BUFFER_STATE b,FILE *file );
339 
340 #define YY_FLUSH_BUFFER csv__flush_buffer(YY_CURRENT_BUFFER )
341 
342 YY_BUFFER_STATE csv__scan_buffer (char *base,yy_size_t size );
343 YY_BUFFER_STATE csv__scan_string (yyconst char *yy_str );
344 YY_BUFFER_STATE csv__scan_bytes (yyconst char *bytes,int len );
345 
346 void *csv_alloc (yy_size_t );
347 void *csv_realloc (void *,yy_size_t );
348 void csv_free (void * );
349 
350 #define yy_new_buffer csv__create_buffer
351 
352 #define yy_set_interactive(is_interactive) \
353  { \
354  if ( ! YY_CURRENT_BUFFER ){ \
355  csv_ensure_buffer_stack (); \
356  YY_CURRENT_BUFFER_LVALUE = \
357  csv__create_buffer(csv_in,YY_BUF_SIZE ); \
358  } \
359  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
360  }
361 
362 #define yy_set_bol(at_bol) \
363  { \
364  if ( ! YY_CURRENT_BUFFER ){\
365  csv_ensure_buffer_stack (); \
366  YY_CURRENT_BUFFER_LVALUE = \
367  csv__create_buffer(csv_in,YY_BUF_SIZE ); \
368  } \
369  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
370  }
371 
372 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
373 
374 /* Begin user sect3 */
375 
376 #define csv_wrap(n) 1
377 #define YY_SKIP_YYWRAP
378 
379 typedef unsigned char YY_CHAR;
380 
381 FILE *csv_in = (FILE *) 0, *csv_out = (FILE *) 0;
382 
383 typedef int yy_state_type;
384 
385 extern int csv_lineno;
386 
387 int csv_lineno = 1;
388 
389 extern char *csv_text;
390 #define yytext_ptr csv_text
391 
392 static yy_state_type yy_get_previous_state (void );
393 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
394 static int yy_get_next_buffer (void );
395 static void yy_fatal_error (yyconst char msg[] );
396 
397 /* Done after the current pattern has been matched and before the
398  * corresponding action - sets up csv_text.
399  */
400 #define YY_DO_BEFORE_ACTION \
401  (yytext_ptr) = yy_bp; \
402  csv_leng = (size_t) (yy_cp - yy_bp); \
403  (yy_hold_char) = *yy_cp; \
404  *yy_cp = '\0'; \
405  (yy_c_buf_p) = yy_cp;
406 
407 #define YY_NUM_RULES 12
408 #define YY_END_OF_BUFFER 13
409 /* This struct is not used in this scanner,
410  but its presence is necessary. */
411 struct yy_trans_info
412  {
415  };
416 static yyconst flex_int16_t yy_accept[46] =
417  { 0,
418  0, 0, 0, 0, 4, 4, 13, 9, 7, 2,
419  9, 1, 9, 9, 8, 3, 10, 7, 11, 10,
420  4, 4, 6, 12, 5, 2, 0, 8, 8, 0,
421  3, 0, 11, 4, 6, 0, 0, 8, 0, 0,
422  8, 0, 0, 3, 0
423  } ;
424 
425 static yyconst flex_int32_t yy_ec[256] =
426  { 0,
427  1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
428  1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
429  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430  1, 2, 1, 5, 1, 1, 1, 1, 1, 1,
431  1, 1, 6, 7, 6, 8, 1, 9, 9, 9,
432  9, 9, 9, 9, 9, 9, 9, 1, 10, 1,
433  1, 1, 1, 1, 11, 11, 11, 11, 12, 11,
434  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
435  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
436  13, 1, 14, 1, 11, 1, 11, 11, 11, 11,
437 
438  12, 11, 11, 11, 11, 11, 11, 11, 11, 11,
439  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
440  11, 11, 1, 1, 1, 1, 1, 1, 1, 1,
441  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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 
449  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
450  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
451  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
452  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
453  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
454  1, 1, 1, 1, 1
455  } ;
456 
457 static yyconst flex_int32_t yy_meta[15] =
458  { 0,
459  1, 1, 2, 2, 2, 1, 1, 3, 3, 1,
460  3, 3, 3, 1
461  } ;
462 
463 static yyconst flex_int16_t yy_base[49] =
464  { 0,
465  0, 0, 13, 22, 32, 0, 73, 74, 74, 74,
466  69, 74, 10, 62, 39, 57, 74, 74, 74, 66,
467  0, 0, 74, 65, 74, 74, 58, 0, 18, 22,
468  53, 55, 74, 0, 74, 43, 49, 48, 46, 47,
469  41, 13, 45, 74, 74, 59, 18, 62
470  } ;
471 
472 static yyconst flex_int16_t yy_def[49] =
473  { 0,
474  45, 1, 46, 46, 45, 5, 45, 45, 45, 45,
475  45, 45, 45, 45, 45, 47, 45, 45, 45, 45,
476  48, 48, 45, 45, 45, 45, 45, 15, 45, 45,
477  47, 45, 45, 48, 45, 45, 45, 45, 45, 45,
478  45, 45, 45, 45, 0, 45, 45, 45
479  } ;
480 
481 static yyconst flex_int16_t yy_nxt[89] =
482  { 0,
483  8, 9, 10, 11, 12, 13, 9, 14, 15, 9,
484  16, 16, 8, 8, 18, 19, 20, 27, 28, 18,
485  31, 43, 18, 18, 19, 20, 29, 37, 18, 36,
486  38, 18, 21, 22, 23, 24, 25, 21, 22, 21,
487  21, 22, 21, 21, 21, 21, 27, 28, 40, 41,
488  30, 41, 42, 43, 39, 41, 38, 38, 44, 17,
489  17, 17, 34, 39, 34, 32, 29, 35, 33, 32,
490  29, 26, 45, 7, 45, 45, 45, 45, 45, 45,
491  45, 45, 45, 45, 45, 45, 45, 45
492  } ;
493 
494 static yyconst flex_int16_t yy_chk[89] =
495  { 0,
496  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
497  1, 1, 1, 1, 3, 3, 3, 13, 13, 3,
498  47, 42, 3, 4, 4, 4, 29, 30, 4, 29,
499  30, 4, 5, 5, 5, 5, 5, 5, 5, 5,
500  5, 5, 5, 5, 5, 5, 15, 15, 36, 41,
501  15, 36, 39, 43, 39, 40, 38, 37, 43, 46,
502  46, 46, 48, 32, 48, 31, 27, 24, 20, 16,
503  14, 11, 7, 45, 45, 45, 45, 45, 45, 45,
504  45, 45, 45, 45, 45, 45, 45, 45
505  } ;
506 
507 /* Table of booleans, true if rule could match eol. */
508 static yyconst flex_int32_t yy_rule_can_match_eol[13] =
509  { 0,
510 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, };
511 
512 static yy_state_type yy_last_accepting_state;
513 static char *yy_last_accepting_cpos;
514 
515 extern int csv__flex_debug;
516 int csv__flex_debug = 0;
517 
518 /* The intent behind this definition is that it'll catch
519  * any uses of REJECT which flex missed.
520  */
521 #define REJECT reject_used_but_not_detected
522 #define yymore() yymore_used_but_not_detected
523 #define YY_MORE_ADJ 0
524 #define YY_RESTORE_YY_MORE_OFFSET
525 char *csv_text;
526 #line 1 "scan_csv.l"
527 /* -*-c-*- */
528 #line 4 "scan_csv.l"
529 /*
530  * scan_csv.l - scanner for CSV files
531  *
532  * Copyright (C) 2007 Stefan Jahn <stefan@lkcc.org>
533  *
534  * This is free software; you can redistribute it and/or modify
535  * it under the terms of the GNU General Public License as published by
536  * the Free Software Foundation; either version 2, or (at your option)
537  * any later version.
538  *
539  * This software is distributed in the hope that it will be useful,
540  * but WITHOUT ANY WARRANTY; without even the implied warranty of
541  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
542  * GNU General Public License for more details.
543  *
544  * You should have received a copy of the GNU General Public License
545  * along with this package; see the file COPYING. If not, write to
546  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
547  * Boston, MA 02110-1301, USA.
548  *
549  * $Id: scan_csv.l 1825 2011-03-11 20:42:14Z ela $
550  *
551  */
552 
553 #if HAVE_CONFIG_H
554 # include <config.h>
555 #endif
556 
557 #include <stdio.h>
558 #include <stdlib.h>
559 #include <string.h>
560 #include <ctype.h>
561 
562 #ifdef __MINGW32__
563 #include <io.h>
564 #endif
565 
566 #ifdef HAVE_UNISTD_H
567 #include <unistd.h>
568 #endif
569 
570 #include "logging.h"
571 #include "complex.h"
572 #include "object.h"
573 #include "vector.h"
574 #include "dataset.h"
575 #include "check_csv.h"
576 #include "tokens_csv.h"
577 
578 
579 #line 580 "scan_csv.cpp"
580 
581 #define INITIAL 0
582 #define COMMENT 1
583 #define IDENT 2
584 
585 #ifndef YY_EXTRA_TYPE
586 #define YY_EXTRA_TYPE void *
587 #endif
588 
589 static int yy_init_globals (void );
590 
591 /* Accessor methods to globals.
592  These are made visible to non-reentrant scanners for convenience. */
593 
594 int csv_lex_destroy (void );
595 
596 int csv_get_debug (void );
597 
598 void csv_set_debug (int debug_flag );
599 
601 
602 void csv_set_extra (YY_EXTRA_TYPE user_defined );
603 
604 FILE *csv_get_in (void );
605 
606 void csv_set_in (FILE * in_str );
607 
608 FILE *csv_get_out (void );
609 
610 void csv_set_out (FILE * out_str );
611 
612 int csv_get_leng (void );
613 
614 char *csv_get_text (void );
615 
616 int csv_get_lineno (void );
617 
618 void csv_set_lineno (int line_number );
619 
620 /* Macros after this point can all be overridden by user definitions in
621  * section 1.
622  */
623 
624 #ifndef YY_SKIP_YYWRAP
625 #ifdef __cplusplus
626 extern "C" int csv_wrap (void );
627 #else
628 extern int csv_wrap (void );
629 #endif
630 #endif
631 
632 #ifndef yytext_ptr
633 static void yy_flex_strncpy (char *,yyconst char *,int );
634 #endif
635 
636 #ifdef YY_NEED_STRLEN
637 static int yy_flex_strlen (yyconst char * );
638 #endif
639 
640 #ifndef YY_NO_INPUT
641 
642 #ifdef __cplusplus
643 static int yyinput (void );
644 #else
645 static int input (void );
646 #endif
647 
648 #endif
649 
650 /* Amount of stuff to slurp up with each read. */
651 #ifndef YY_READ_BUF_SIZE
652 #ifdef __ia64__
653 /* On IA-64, the buffer size is 16k, not 8k */
654 #define YY_READ_BUF_SIZE 16384
655 #else
656 #define YY_READ_BUF_SIZE 8192
657 #endif /* __ia64__ */
658 #endif
659 
660 /* Copy whatever the last rule matched to the standard output. */
661 #ifndef ECHO
662 /* This used to be an fputs(), but since the string might contain NUL's,
663  * we now use fwrite().
664  */
665 #define ECHO do { if (fwrite( csv_text, csv_leng, 1, csv_out )) {} } while (0)
666 #endif
667 
668 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
669  * is returned in "result".
670  */
671 #ifndef YY_INPUT
672 #define YY_INPUT(buf,result,max_size) \
673  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
674  { \
675  int c = '*'; \
676  size_t n; \
677  for ( n = 0; n < max_size && \
678  (c = getc( csv_in )) != EOF && c != '\n'; ++n ) \
679  buf[n] = (char) c; \
680  if ( c == '\n' ) \
681  buf[n++] = (char) c; \
682  if ( c == EOF && ferror( csv_in ) ) \
683  YY_FATAL_ERROR( "input in flex scanner failed" ); \
684  result = n; \
685  } \
686  else \
687  { \
688  errno=0; \
689  while ( (result = fread(buf, 1, max_size, csv_in))==0 && ferror(csv_in)) \
690  { \
691  if( errno != EINTR) \
692  { \
693  YY_FATAL_ERROR( "input in flex scanner failed" ); \
694  break; \
695  } \
696  errno=0; \
697  clearerr(csv_in); \
698  } \
699  }\
700 \
701 
702 #endif
703 
704 /* No semi-colon after return; correct usage is to write "yyterminate();" -
705  * we don't want an extra ';' after the "return" because that will cause
706  * some compilers to complain about unreachable statements.
707  */
708 #ifndef yyterminate
709 #define yyterminate() return YY_NULL
710 #endif
711 
712 /* Number of entries by which start-condition stack grows. */
713 #ifndef YY_START_STACK_INCR
714 #define YY_START_STACK_INCR 25
715 #endif
716 
717 /* Report a fatal error. */
718 #ifndef YY_FATAL_ERROR
719 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
720 #endif
721 
722 /* end tables serialization structures and prototypes */
723 
724 /* Default declaration of generated scanner - a define so the user can
725  * easily add parameters.
726  */
727 #ifndef YY_DECL
728 #define YY_DECL_IS_OURS 1
729 
730 extern int csv_lex (void);
731 
732 #define YY_DECL int csv_lex (void)
733 #endif /* !YY_DECL */
734 
735 /* Code executed at the beginning of each rule, after csv_text and csv_leng
736  * have been set up.
737  */
738 #ifndef YY_USER_ACTION
739 #define YY_USER_ACTION
740 #endif
741 
742 /* Code executed at the end of each rule. */
743 #ifndef YY_BREAK
744 #define YY_BREAK break;
745 #endif
746 
747 #define YY_RULE_SETUP \
748  YY_USER_ACTION
749 
752 YY_DECL
753 {
754  register yy_state_type yy_current_state;
755  register char *yy_cp, *yy_bp;
756  register int yy_act;
757 
758 #line 70 "scan_csv.l"
759 
760 
761 #line 762 "scan_csv.cpp"
762 
763  if ( !(yy_init) )
764  {
765  (yy_init) = 1;
766 
767 #ifdef YY_USER_INIT
768  YY_USER_INIT;
769 #endif
770 
771  if ( ! (yy_start) )
772  (yy_start) = 1; /* first start state */
773 
774  if ( ! csv_in )
775  csv_in = stdin;
776 
777  if ( ! csv_out )
778  csv_out = stdout;
779 
780  if ( ! YY_CURRENT_BUFFER ) {
781  csv_ensure_buffer_stack ();
784  }
785 
786  csv__load_buffer_state( );
787  }
788 
789  while ( 1 ) /* loops until end-of-file is reached */
790  {
791  yy_cp = (yy_c_buf_p);
792 
793  /* Support of csv_text. */
794  *yy_cp = (yy_hold_char);
795 
796  /* yy_bp points to the position in yy_ch_buf of the start of
797  * the current run.
798  */
799  yy_bp = yy_cp;
800 
801  yy_current_state = (yy_start);
802 yy_match:
803  do
804  {
805  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
806  if ( yy_accept[yy_current_state] )
807  {
808  (yy_last_accepting_state) = yy_current_state;
809  (yy_last_accepting_cpos) = yy_cp;
810  }
811  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
812  {
813  yy_current_state = (int) yy_def[yy_current_state];
814  if ( yy_current_state >= 46 )
815  yy_c = yy_meta[(unsigned int) yy_c];
816  }
817  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
818  ++yy_cp;
819  }
820  while ( yy_base[yy_current_state] != 74 );
821 
822 yy_find_action:
823  yy_act = yy_accept[yy_current_state];
824  if ( yy_act == 0 )
825  { /* have to back up */
826  yy_cp = (yy_last_accepting_cpos);
827  yy_current_state = (yy_last_accepting_state);
828  yy_act = yy_accept[yy_current_state];
829  }
830 
832 
833  if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
834  {
835  int yyl;
836  for ( yyl = 0; yyl < csv_leng; ++yyl )
837  if ( csv_text[yyl] == '\n' )
838 
839  csv_lineno++;
840 ;
841  }
842 
843 do_action: /* This label is used only to access EOF actions. */
844 
845  switch ( yy_act )
846  { /* beginning of action switch */
847  case 0: /* must back up */
848  /* undo the effects of YY_DO_BEFORE_ACTION */
849  *yy_cp = (yy_hold_char);
850  yy_cp = (yy_last_accepting_cpos);
851  yy_current_state = (yy_last_accepting_state);
852  goto yy_find_action;
853 
854 case 1:
856 #line 72 "scan_csv.l"
857 { BEGIN(IDENT); /* pass the '"' to the parser */ return '"'; }
858  YY_BREAK
859 case 2:
860 /* rule 2 can match eol */
862 #line 73 "scan_csv.l"
863 { /* detect end of line */ return Eol; }
864  YY_BREAK
865 case 3:
867 #line 75 "scan_csv.l"
868 { /* identify identifier */
869  csv_lval.ident = strdup (csv_text);
870  return Identifier;
871  }
872  YY_BREAK
873 case 4:
875 #line 80 "scan_csv.l"
876 { /* identify identifier */
877  csv_lval.ident = strdup (csv_text);
878  return Identifier;
879  }
880  YY_BREAK
881 case 5:
883 #line 85 "scan_csv.l"
884 { BEGIN(INITIAL); return '"'; }
885  YY_BREAK
886 case 6:
887 /* rule 6 can match eol */
889 #line 86 "scan_csv.l"
890 { BEGIN(INITIAL); return Eol; }
891  YY_BREAK
892 case 7:
894 #line 88 "scan_csv.l"
895 /* skip spaces and separators */
896  YY_BREAK
897 case 8:
899 #line 90 "scan_csv.l"
900 { /* identify float */
901  csv_lval.f = strtod (csv_text, NULL);
902  return Float;
903  }
904  YY_BREAK
905 case 9:
907 #line 95 "scan_csv.l"
908 { /* any other character in invalid */
910  "line %d: syntax error, unrecognized character: `%s'\n",
911  csv_lineno, csv_text);
912  return InvalidCharacter;
913  }
914  YY_BREAK
915 case 10:
917 #line 102 "scan_csv.l"
918 { /* skip any character in here */ }
919  YY_BREAK
920 case 11:
921 /* rule 11 can match eol */
923 #line 103 "scan_csv.l"
924 { BEGIN(INITIAL); /* skipping ends here */ return Eol; }
925  YY_BREAK
926 case 12:
928 #line 105 "scan_csv.l"
929 ECHO;
930  YY_BREAK
931 #line 932 "scan_csv.cpp"
932 case YY_STATE_EOF(INITIAL):
933 case YY_STATE_EOF(COMMENT):
934 case YY_STATE_EOF(IDENT):
935  yyterminate();
936 
937  case YY_END_OF_BUFFER:
938  {
939  /* Amount of text matched not including the EOB char. */
940  int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
941 
942  /* Undo the effects of YY_DO_BEFORE_ACTION. */
943  *yy_cp = (yy_hold_char);
945 
946  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
947  {
948  /* We're scanning a new file or input source. It's
949  * possible that this happened because the user
950  * just pointed csv_in at a new source and called
951  * csv_lex(). If so, then we have to assure
952  * consistency between YY_CURRENT_BUFFER and our
953  * globals. Here is the right place to do so, because
954  * this is the first action (other than possibly a
955  * back-up) that will match for the new input source.
956  */
957  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
958  YY_CURRENT_BUFFER_LVALUE->yy_input_file = csv_in;
959  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
960  }
961 
962  /* Note that here we test for yy_c_buf_p "<=" to the position
963  * of the first EOB in the buffer, since yy_c_buf_p will
964  * already have been incremented past the NUL character
965  * (since all states make transitions on EOB to the
966  * end-of-buffer state). Contrast this with the test
967  * in input().
968  */
969  if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
970  { /* This was really a NUL. */
971  yy_state_type yy_next_state;
972 
973  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
974 
975  yy_current_state = yy_get_previous_state( );
976 
977  /* Okay, we're now positioned to make the NUL
978  * transition. We couldn't have
979  * yy_get_previous_state() go ahead and do it
980  * for us because it doesn't know how to deal
981  * with the possibility of jamming (and we don't
982  * want to build jamming into it because then it
983  * will run more slowly).
984  */
985 
986  yy_next_state = yy_try_NUL_trans( yy_current_state );
987 
988  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
989 
990  if ( yy_next_state )
991  {
992  /* Consume the NUL. */
993  yy_cp = ++(yy_c_buf_p);
994  yy_current_state = yy_next_state;
995  goto yy_match;
996  }
997 
998  else
999  {
1000  yy_cp = (yy_c_buf_p);
1001  goto yy_find_action;
1002  }
1003  }
1004 
1005  else switch ( yy_get_next_buffer( ) )
1006  {
1007  case EOB_ACT_END_OF_FILE:
1008  {
1009  (yy_did_buffer_switch_on_eof) = 0;
1010 
1011  if ( csv_wrap( ) )
1012  {
1013  /* Note: because we've taken care in
1014  * yy_get_next_buffer() to have set up
1015  * csv_text, we can now set up
1016  * yy_c_buf_p so that if some total
1017  * hoser (like flex itself) wants to
1018  * call the scanner after we return the
1019  * YY_NULL, it'll still work - another
1020  * YY_NULL will get returned.
1021  */
1022  (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1023 
1024  yy_act = YY_STATE_EOF(YY_START);
1025  goto do_action;
1026  }
1027 
1028  else
1029  {
1030  if ( ! (yy_did_buffer_switch_on_eof) )
1031  YY_NEW_FILE;
1032  }
1033  break;
1034  }
1035 
1036  case EOB_ACT_CONTINUE_SCAN:
1037  (yy_c_buf_p) =
1038  (yytext_ptr) + yy_amount_of_matched_text;
1039 
1040  yy_current_state = yy_get_previous_state( );
1041 
1042  yy_cp = (yy_c_buf_p);
1043  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1044  goto yy_match;
1045 
1046  case EOB_ACT_LAST_MATCH:
1047  (yy_c_buf_p) =
1048  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1049 
1050  yy_current_state = yy_get_previous_state( );
1051 
1052  yy_cp = (yy_c_buf_p);
1053  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1054  goto yy_find_action;
1055  }
1056  break;
1057  }
1058 
1059  default:
1061  "fatal flex scanner internal error--no action found" );
1062  } /* end of action switch */
1063  } /* end of scanning one token */
1064 } /* end of csv_lex */
1065 
1066 /* yy_get_next_buffer - try to read in a new buffer
1067  *
1068  * Returns a code representing an action:
1069  * EOB_ACT_LAST_MATCH -
1070  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1071  * EOB_ACT_END_OF_FILE - end of file
1072  */
1073 static int yy_get_next_buffer (void)
1074 {
1075  register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1076  register char *source = (yytext_ptr);
1077  register int number_to_move, i;
1078  int ret_val;
1079 
1080  if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1082  "fatal flex scanner internal error--end of buffer missed" );
1083 
1084  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1085  { /* Don't try to fill the buffer, so this is an EOF. */
1086  if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1087  {
1088  /* We matched a single character, the EOB, so
1089  * treat this as a final EOF.
1090  */
1091  return EOB_ACT_END_OF_FILE;
1092  }
1093 
1094  else
1095  {
1096  /* We matched some text prior to the EOB, first
1097  * process it.
1098  */
1099  return EOB_ACT_LAST_MATCH;
1100  }
1101  }
1102 
1103  /* Try to read more data. */
1104 
1105  /* First move last chars to start of buffer. */
1106  number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1107 
1108  for ( i = 0; i < number_to_move; ++i )
1109  *(dest++) = *(source++);
1110 
1111  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1112  /* don't do the read, it's not guaranteed to return an EOF,
1113  * just force an EOF
1114  */
1115  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1116 
1117  else
1118  {
1119  int num_to_read =
1120  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1121 
1122  while ( num_to_read <= 0 )
1123  { /* Not enough room in the buffer - grow it. */
1124 
1125  /* just a shorter name for the current buffer */
1126  YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1127 
1128  int yy_c_buf_p_offset =
1129  (int) ((yy_c_buf_p) - b->yy_ch_buf);
1130 
1131  if ( b->yy_is_our_buffer )
1132  {
1133  int new_size = b->yy_buf_size * 2;
1134 
1135  if ( new_size <= 0 )
1136  b->yy_buf_size += b->yy_buf_size / 8;
1137  else
1138  b->yy_buf_size *= 2;
1139 
1140  b->yy_ch_buf = (char *)
1141  /* Include room in for 2 EOB chars. */
1142  csv_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1143  }
1144  else
1145  /* Can't grow it, we don't own it. */
1146  b->yy_ch_buf = 0;
1147 
1148  if ( ! b->yy_ch_buf )
1150  "fatal error - scanner input buffer overflow" );
1151 
1152  (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1153 
1154  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1155  number_to_move - 1;
1156 
1157  }
1158 
1159  if ( num_to_read > YY_READ_BUF_SIZE )
1160  num_to_read = YY_READ_BUF_SIZE;
1161 
1162  /* Read in more data. */
1163  YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1164  (yy_n_chars), (size_t) num_to_read );
1165 
1166  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1167  }
1168 
1169  if ( (yy_n_chars) == 0 )
1170  {
1171  if ( number_to_move == YY_MORE_ADJ )
1172  {
1173  ret_val = EOB_ACT_END_OF_FILE;
1174  csv_restart(csv_in );
1175  }
1176 
1177  else
1178  {
1179  ret_val = EOB_ACT_LAST_MATCH;
1180  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1182  }
1183  }
1184 
1185  else
1186  ret_val = EOB_ACT_CONTINUE_SCAN;
1187 
1188  if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1189  /* Extend the array by 50%, plus the number we really need. */
1190  yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1191  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) csv_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1192  if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1193  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1194  }
1195 
1196  (yy_n_chars) += number_to_move;
1197  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1198  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1199 
1200  (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1201 
1202  return ret_val;
1203 }
1204 
1205 /* yy_get_previous_state - get the state just before the EOB char was reached */
1206 
1207  static yy_state_type yy_get_previous_state (void)
1208 {
1209  register yy_state_type yy_current_state;
1210  register char *yy_cp;
1211 
1212  yy_current_state = (yy_start);
1213 
1214  for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1215  {
1216  register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1217  if ( yy_accept[yy_current_state] )
1218  {
1219  (yy_last_accepting_state) = yy_current_state;
1220  (yy_last_accepting_cpos) = yy_cp;
1221  }
1222  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1223  {
1224  yy_current_state = (int) yy_def[yy_current_state];
1225  if ( yy_current_state >= 46 )
1226  yy_c = yy_meta[(unsigned int) yy_c];
1227  }
1228  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1229  }
1230 
1231  return yy_current_state;
1232 }
1233 
1234 /* yy_try_NUL_trans - try to make a transition on the NUL character
1235  *
1236  * synopsis
1237  * next_state = yy_try_NUL_trans( current_state );
1238  */
1239  static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1240 {
1241  register int yy_is_jam;
1242  register char *yy_cp = (yy_c_buf_p);
1243 
1244  register YY_CHAR yy_c = 1;
1245  if ( yy_accept[yy_current_state] )
1246  {
1247  (yy_last_accepting_state) = yy_current_state;
1248  (yy_last_accepting_cpos) = yy_cp;
1249  }
1250  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1251  {
1252  yy_current_state = (int) yy_def[yy_current_state];
1253  if ( yy_current_state >= 46 )
1254  yy_c = yy_meta[(unsigned int) yy_c];
1255  }
1256  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1257  yy_is_jam = (yy_current_state == 45);
1258 
1259  return yy_is_jam ? 0 : yy_current_state;
1260 }
1261 
1262 #ifndef YY_NO_INPUT
1263 #ifdef __cplusplus
1264  static int yyinput (void)
1265 #else
1266  static int input (void)
1267 #endif
1268 
1269 {
1270  int c;
1271 
1272  *(yy_c_buf_p) = (yy_hold_char);
1273 
1274  if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1275  {
1276  /* yy_c_buf_p now points to the character we want to return.
1277  * If this occurs *before* the EOB characters, then it's a
1278  * valid NUL; if not, then we've hit the end of the buffer.
1279  */
1280  if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1281  /* This was really a NUL. */
1282  *(yy_c_buf_p) = '\0';
1283 
1284  else
1285  { /* need more input */
1286  int offset = (yy_c_buf_p) - (yytext_ptr);
1287  ++(yy_c_buf_p);
1288 
1289  switch ( yy_get_next_buffer( ) )
1290  {
1291  case EOB_ACT_LAST_MATCH:
1292  /* This happens because yy_g_n_b()
1293  * sees that we've accumulated a
1294  * token and flags that we need to
1295  * try matching the token before
1296  * proceeding. But for input(),
1297  * there's no matching to consider.
1298  * So convert the EOB_ACT_LAST_MATCH
1299  * to EOB_ACT_END_OF_FILE.
1300  */
1301 
1302  /* Reset buffer status. */
1303  csv_restart(csv_in );
1304 
1305  /*FALLTHROUGH*/
1306 
1307  case EOB_ACT_END_OF_FILE:
1308  {
1309  if ( csv_wrap( ) )
1310  return EOF;
1311 
1312  if ( ! (yy_did_buffer_switch_on_eof) )
1313  YY_NEW_FILE;
1314 #ifdef __cplusplus
1315  return yyinput();
1316 #else
1317  return input();
1318 #endif
1319  }
1320 
1321  case EOB_ACT_CONTINUE_SCAN:
1322  (yy_c_buf_p) = (yytext_ptr) + offset;
1323  break;
1324  }
1325  }
1326  }
1327 
1328  c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1329  *(yy_c_buf_p) = '\0'; /* preserve csv_text */
1330  (yy_hold_char) = *++(yy_c_buf_p);
1331 
1332  if ( c == '\n' )
1333 
1334  csv_lineno++;
1335 ;
1336 
1337  return c;
1338 }
1339 #endif /* ifndef YY_NO_INPUT */
1340 
1346  void csv_restart (FILE * input_file )
1347 {
1348 
1349  if ( ! YY_CURRENT_BUFFER ){
1350  csv_ensure_buffer_stack ();
1353  }
1354 
1355  csv__init_buffer(YY_CURRENT_BUFFER,input_file );
1356  csv__load_buffer_state( );
1357 }
1358 
1363  void csv__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1364 {
1365 
1366  /* TODO. We should be able to replace this entire function body
1367  * with
1368  * csv_pop_buffer_state();
1369  * csv_push_buffer_state(new_buffer);
1370  */
1371  csv_ensure_buffer_stack ();
1372  if ( YY_CURRENT_BUFFER == new_buffer )
1373  return;
1374 
1375  if ( YY_CURRENT_BUFFER )
1376  {
1377  /* Flush out information for old buffer. */
1378  *(yy_c_buf_p) = (yy_hold_char);
1379  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1380  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1381  }
1382 
1383  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1384  csv__load_buffer_state( );
1385 
1386  /* We don't actually know whether we did this switch during
1387  * EOF (csv_wrap()) processing, but the only time this flag
1388  * is looked at is after csv_wrap() is called, so it's safe
1389  * to go ahead and always set it.
1390  */
1391  (yy_did_buffer_switch_on_eof) = 1;
1392 }
1393 
1394 static void csv__load_buffer_state (void)
1395 {
1396  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1397  (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1398  csv_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1399  (yy_hold_char) = *(yy_c_buf_p);
1400 }
1401 
1408  YY_BUFFER_STATE csv__create_buffer (FILE * file, int size )
1409 {
1410  YY_BUFFER_STATE b;
1411 
1412  b = (YY_BUFFER_STATE) csv_alloc(sizeof( struct yy_buffer_state ) );
1413  if ( ! b )
1414  YY_FATAL_ERROR( "out of dynamic memory in csv__create_buffer()" );
1415 
1416  b->yy_buf_size = size;
1417 
1418  /* yy_ch_buf has to be 2 characters longer than the size given because
1419  * we need to put in 2 end-of-buffer characters.
1420  */
1421  b->yy_ch_buf = (char *) csv_alloc(b->yy_buf_size + 2 );
1422  if ( ! b->yy_ch_buf )
1423  YY_FATAL_ERROR( "out of dynamic memory in csv__create_buffer()" );
1424 
1425  b->yy_is_our_buffer = 1;
1426 
1427  csv__init_buffer(b,file );
1428 
1429  return b;
1430 }
1431 
1436  void csv__delete_buffer (YY_BUFFER_STATE b )
1437 {
1438 
1439  if ( ! b )
1440  return;
1441 
1442  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1444 
1445  if ( b->yy_is_our_buffer )
1446  csv_free((void *) b->yy_ch_buf );
1447 
1448  csv_free((void *) b );
1449 }
1450 
1451 #ifndef __cplusplus
1452 extern int isatty (int );
1453 #endif /* __cplusplus */
1454 
1455 /* Initializes or reinitializes a buffer.
1456  * This function is sometimes called more than once on the same buffer,
1457  * such as during a csv_restart() or at EOF.
1458  */
1459  static void csv__init_buffer (YY_BUFFER_STATE b, FILE * file )
1460 
1461 {
1462  int oerrno = errno;
1463 
1464  csv__flush_buffer(b );
1465 
1466  b->yy_input_file = file;
1467  b->yy_fill_buffer = 1;
1468 
1469  /* If b is the current buffer, then csv__init_buffer was _probably_
1470  * called from csv_restart() or through yy_get_next_buffer.
1471  * In that case, we don't want to reset the lineno or column.
1472  */
1473  if (b != YY_CURRENT_BUFFER){
1474  b->yy_bs_lineno = 1;
1475  b->yy_bs_column = 0;
1476  }
1477 
1478  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1479 
1480  errno = oerrno;
1481 }
1482 
1487  void csv__flush_buffer (YY_BUFFER_STATE b )
1488 {
1489  if ( ! b )
1490  return;
1491 
1492  b->yy_n_chars = 0;
1493 
1494  /* We always need two end-of-buffer characters. The first causes
1495  * a transition to the end-of-buffer state. The second causes
1496  * a jam in that state.
1497  */
1500 
1501  b->yy_buf_pos = &b->yy_ch_buf[0];
1502 
1503  b->yy_at_bol = 1;
1505 
1506  if ( b == YY_CURRENT_BUFFER )
1507  csv__load_buffer_state( );
1508 }
1509 
1516 void csv_push_buffer_state (YY_BUFFER_STATE new_buffer )
1517 {
1518  if (new_buffer == NULL)
1519  return;
1520 
1521  csv_ensure_buffer_stack();
1522 
1523  /* This block is copied from csv__switch_to_buffer. */
1524  if ( YY_CURRENT_BUFFER )
1525  {
1526  /* Flush out information for old buffer. */
1527  *(yy_c_buf_p) = (yy_hold_char);
1528  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1529  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1530  }
1531 
1532  /* Only push if top exists. Otherwise, replace top. */
1533  if (YY_CURRENT_BUFFER)
1534  (yy_buffer_stack_top)++;
1535  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1536 
1537  /* copied from csv__switch_to_buffer. */
1538  csv__load_buffer_state( );
1539  (yy_did_buffer_switch_on_eof) = 1;
1540 }
1541 
1547 {
1548  if (!YY_CURRENT_BUFFER)
1549  return;
1550 
1552  YY_CURRENT_BUFFER_LVALUE = NULL;
1553  if ((yy_buffer_stack_top) > 0)
1554  --(yy_buffer_stack_top);
1555 
1556  if (YY_CURRENT_BUFFER) {
1557  csv__load_buffer_state( );
1558  (yy_did_buffer_switch_on_eof) = 1;
1559  }
1560 }
1561 
1562 /* Allocates the stack if it does not exist.
1563  * Guarantees space for at least one push.
1564  */
1565 static void csv_ensure_buffer_stack (void)
1566 {
1567  int num_to_alloc;
1568 
1569  if (!(yy_buffer_stack)) {
1570 
1571  /* First allocation is just for 2 elements, since we don't know if this
1572  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1573  * immediate realloc on the next call.
1574  */
1575  num_to_alloc = 1;
1576  (yy_buffer_stack) = (struct yy_buffer_state**)csv_alloc
1577  (num_to_alloc * sizeof(struct yy_buffer_state*)
1578  );
1579  if ( ! (yy_buffer_stack) )
1580  YY_FATAL_ERROR( "out of dynamic memory in csv_ensure_buffer_stack()" );
1581 
1582  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1583 
1584  (yy_buffer_stack_max) = num_to_alloc;
1585  (yy_buffer_stack_top) = 0;
1586  return;
1587  }
1588 
1589  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1590 
1591  /* Increase the buffer to prepare for a possible push. */
1592  int grow_size = 8 /* arbitrary grow size */;
1593 
1594  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1595  (yy_buffer_stack) = (struct yy_buffer_state**)csv_realloc
1596  ((yy_buffer_stack),
1597  num_to_alloc * sizeof(struct yy_buffer_state*)
1598  );
1599  if ( ! (yy_buffer_stack) )
1600  YY_FATAL_ERROR( "out of dynamic memory in csv_ensure_buffer_stack()" );
1601 
1602  /* zero only the new slots.*/
1603  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1604  (yy_buffer_stack_max) = num_to_alloc;
1605  }
1606 }
1607 
1614 YY_BUFFER_STATE csv__scan_buffer (char * base, yy_size_t size )
1615 {
1616  YY_BUFFER_STATE b;
1617 
1618  if ( size < 2 ||
1619  base[size-2] != YY_END_OF_BUFFER_CHAR ||
1620  base[size-1] != YY_END_OF_BUFFER_CHAR )
1621  /* They forgot to leave room for the EOB's. */
1622  return 0;
1623 
1624  b = (YY_BUFFER_STATE) csv_alloc(sizeof( struct yy_buffer_state ) );
1625  if ( ! b )
1626  YY_FATAL_ERROR( "out of dynamic memory in csv__scan_buffer()" );
1627 
1628  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1629  b->yy_buf_pos = b->yy_ch_buf = base;
1630  b->yy_is_our_buffer = 0;
1631  b->yy_input_file = 0;
1632  b->yy_n_chars = b->yy_buf_size;
1633  b->yy_is_interactive = 0;
1634  b->yy_at_bol = 1;
1635  b->yy_fill_buffer = 0;
1637 
1639 
1640  return b;
1641 }
1642 
1651 YY_BUFFER_STATE csv__scan_string (yyconst char * yystr )
1652 {
1653 
1654  return csv__scan_bytes(yystr,strlen(yystr) );
1655 }
1656 
1664 YY_BUFFER_STATE csv__scan_bytes (yyconst char * yybytes, int _yybytes_len )
1665 {
1666  YY_BUFFER_STATE b;
1667  char *buf;
1668  yy_size_t n;
1669  int i;
1670 
1671  /* Get memory for full buffer, including space for trailing EOB's. */
1672  n = _yybytes_len + 2;
1673  buf = (char *) csv_alloc(n );
1674  if ( ! buf )
1675  YY_FATAL_ERROR( "out of dynamic memory in csv__scan_bytes()" );
1676 
1677  for ( i = 0; i < _yybytes_len; ++i )
1678  buf[i] = yybytes[i];
1679 
1680  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1681 
1682  b = csv__scan_buffer(buf,n );
1683  if ( ! b )
1684  YY_FATAL_ERROR( "bad buffer in csv__scan_bytes()" );
1685 
1686  /* It's okay to grow etc. this buffer, and we should throw it
1687  * away when we're done.
1688  */
1689  b->yy_is_our_buffer = 1;
1690 
1691  return b;
1692 }
1693 
1694 #ifndef YY_EXIT_FAILURE
1695 #define YY_EXIT_FAILURE 2
1696 #endif
1697 
1698 static void yy_fatal_error (yyconst char* msg )
1699 {
1700  (void) fprintf( stderr, "%s\n", msg );
1701  exit( YY_EXIT_FAILURE );
1702 }
1703 
1704 /* Redefine yyless() so it works in section 3 code. */
1705 
1706 #undef yyless
1707 #define yyless(n) \
1708  do \
1709  { \
1710  /* Undo effects of setting up csv_text. */ \
1711  int yyless_macro_arg = (n); \
1712  YY_LESS_LINENO(yyless_macro_arg);\
1713  csv_text[csv_leng] = (yy_hold_char); \
1714  (yy_c_buf_p) = csv_text + yyless_macro_arg; \
1715  (yy_hold_char) = *(yy_c_buf_p); \
1716  *(yy_c_buf_p) = '\0'; \
1717  csv_leng = yyless_macro_arg; \
1718  } \
1719  while ( 0 )
1720 
1721 /* Accessor methods (get/set functions) to struct members. */
1722 
1726 int csv_get_lineno (void)
1727 {
1728 
1729  return csv_lineno;
1730 }
1731 
1735 FILE *csv_get_in (void)
1736 {
1737  return csv_in;
1738 }
1739 
1743 FILE *csv_get_out (void)
1744 {
1745  return csv_out;
1746 }
1747 
1751 int csv_get_leng (void)
1752 {
1753  return csv_leng;
1754 }
1755 
1760 char *csv_get_text (void)
1761 {
1762  return csv_text;
1763 }
1764 
1769 void csv_set_lineno (int line_number )
1770 {
1771 
1772  csv_lineno = line_number;
1773 }
1774 
1781 void csv_set_in (FILE * in_str )
1782 {
1783  csv_in = in_str ;
1784 }
1785 
1786 void csv_set_out (FILE * out_str )
1787 {
1788  csv_out = out_str ;
1789 }
1790 
1791 int csv_get_debug (void)
1792 {
1793  return csv__flex_debug;
1794 }
1795 
1796 void csv_set_debug (int bdebug )
1797 {
1798  csv__flex_debug = bdebug ;
1799 }
1800 
1801 static int yy_init_globals (void)
1802 {
1803  /* Initialization is the same as for the non-reentrant scanner.
1804  * This function is called from csv_lex_destroy(), so don't allocate here.
1805  */
1806 
1807  /* We do not touch csv_lineno unless the option is enabled. */
1808  csv_lineno = 1;
1809 
1810  (yy_buffer_stack) = 0;
1811  (yy_buffer_stack_top) = 0;
1812  (yy_buffer_stack_max) = 0;
1813  (yy_c_buf_p) = (char *) 0;
1814  (yy_init) = 0;
1815  (yy_start) = 0;
1816 
1817 /* Defined in main.c */
1818 #ifdef YY_STDINIT
1819  csv_in = stdin;
1820  csv_out = stdout;
1821 #else
1822  csv_in = (FILE *) 0;
1823  csv_out = (FILE *) 0;
1824 #endif
1825 
1826  /* For future reference: Set errno on error, since we are called by
1827  * csv_lex_init()
1828  */
1829  return 0;
1830 }
1831 
1832 /* csv_lex_destroy is for both reentrant and non-reentrant scanners. */
1834 {
1835 
1836  /* Pop the buffer stack, destroying each element. */
1837  while(YY_CURRENT_BUFFER){
1839  YY_CURRENT_BUFFER_LVALUE = NULL;
1841  }
1842 
1843  /* Destroy the stack itself. */
1844  csv_free((yy_buffer_stack) );
1845  (yy_buffer_stack) = NULL;
1846 
1847  /* Reset the globals. This is important in a non-reentrant scanner so the next time
1848  * csv_lex() is called, initialization will occur. */
1849  yy_init_globals( );
1850 
1851  return 0;
1852 }
1853 
1854 /*
1855  * Internal utility routines.
1856  */
1857 
1858 #ifndef yytext_ptr
1859 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1860 {
1861  register int i;
1862  for ( i = 0; i < n; ++i )
1863  s1[i] = s2[i];
1864 }
1865 #endif
1866 
1867 #ifdef YY_NEED_STRLEN
1868 static int yy_flex_strlen (yyconst char * s )
1869 {
1870  register int n;
1871  for ( n = 0; s[n]; ++n )
1872  ;
1873 
1874  return n;
1875 }
1876 #endif
1877 
1878 void *csv_alloc (yy_size_t size )
1879 {
1880  return (void *) malloc( size );
1881 }
1882 
1883 void *csv_realloc (void * ptr, yy_size_t size )
1884 {
1885  /* The cast to (char *) in the following accommodates both
1886  * implementations that use char* generic pointers, and those
1887  * that use void* generic pointers. It works with the latter
1888  * because both ANSI C and C++ allow castless assignment from
1889  * any pointer type to void*, and deal with argument conversions
1890  * as though doing an assignment.
1891  */
1892  return (void *) realloc( (char *) ptr, size );
1893 }
1894 
1895 void csv_free (void * ptr )
1896 {
1897  free( (char *) ptr ); /* see csv_realloc() for (char *) cast */
1898 }
1899 
1900 #define YYTABLES_NAME "yytables"
1901 
1902 #line 105 "scan_csv.l"
1903 
1904 
1905