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