lilypond-1.3.28
[lilypond.git] / lily / lexer.cc
blob592aec13fe96b1cb99aaecdcf5be8091eadb6197
1 /* A lexical scanner generated by flex */
3 /* Scanner skeleton version:
4 * $Header: /home/lilydev/vc/lilypond.git/../lilypond.cvsrepo/lilypond/lily/Attic/lexer.cc,v 1.3 1998/04/09 08:42:17 fred Exp $
5 */
7 #define FLEX_SCANNER
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
13 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
14 #ifdef c_plusplus
15 #ifndef __cplusplus
16 #define __cplusplus
17 #endif
18 #endif
21 #ifdef __cplusplus
23 #include <stdlib.h>
24 class istream;
25 #include <unistd.h>
27 /* Use prototypes in function declarations. */
28 #define YY_USE_PROTOS
30 /* The "const" storage-class-modifier is valid. */
31 #define YY_USE_CONST
33 #else /* ! __cplusplus */
35 #if __STDC__
37 #define YY_USE_PROTOS
38 #define YY_USE_CONST
40 #endif /* __STDC__ */
41 #endif /* ! __cplusplus */
43 #ifdef __TURBOC__
44 #pragma warn -rch
45 #pragma warn -use
46 #include <io.h>
47 #include <stdlib.h>
48 #define YY_USE_CONST
49 #define YY_USE_PROTOS
50 #endif
52 #ifdef YY_USE_CONST
53 #define yyconst const
54 #else
55 #define yyconst
56 #endif
59 #ifdef YY_USE_PROTOS
60 #define YY_PROTO(proto) proto
61 #else
62 #define YY_PROTO(proto) ()
63 #endif
65 /* Returned upon end-of-file. */
66 #define YY_NULL 0
68 /* Promotes a possibly negative, possibly signed char to an unsigned
69 * integer for use as an array index. If the signed char is negative,
70 * we want to instead treat it as an 8-bit unsigned char, hence the
71 * double cast.
73 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
75 /* Enter a start condition. This macro really ought to take a parameter,
76 * but we do it the disgusting crufty way forced on us by the ()-less
77 * definition of BEGIN.
79 #define BEGIN yy_start = 1 + 2 *
81 /* Translate the current start state into a value that can be later handed
82 * to BEGIN to return to the state. The YYSTATE alias is for lex
83 * compatibility.
85 #define YY_START ((yy_start - 1) / 2)
86 #define YYSTATE YY_START
88 /* Action number for EOF rule of a given start state. */
89 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
91 /* Special action meaning "start processing a new file". */
92 #define YY_NEW_FILE yyrestart( yyin )
94 #define YY_END_OF_BUFFER_CHAR 0
96 /* Size of default input buffer. */
97 #define YY_BUF_SIZE 16384
99 typedef struct yy_buffer_state *YY_BUFFER_STATE;
101 extern int yyleng;
103 #define EOB_ACT_CONTINUE_SCAN 0
104 #define EOB_ACT_END_OF_FILE 1
105 #define EOB_ACT_LAST_MATCH 2
107 /* The funky do-while in the following #define is used to turn the definition
108 * int a single C statement (which needs a semi-colon terminator). This
109 * avoids problems with code like:
111 * if ( condition_holds )
112 * yyless( 5 );
113 * else
114 * do_something_else();
116 * Prior to using the do-while the compiler would get upset at the
117 * "else" because it interpreted the "if" statement as being all
118 * done when it reached the ';' after the yyless() call.
121 /* Return all but the first 'n' matched characters back to the input stream. */
123 #define yyless(n) \
124 do \
126 /* Undo effects of setting up yytext. */ \
127 *yy_cp = yy_hold_char; \
128 YY_RESTORE_YY_MORE_OFFSET \
129 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
130 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
132 while ( 0 )
134 #define unput(c) yyunput( c, yytext_ptr )
136 /* The following is because we cannot portably get our hands on size_t
137 * (without autoconf's help, which isn't available because we want
138 * flex-generated scanners to compile on their own).
140 typedef unsigned int yy_size_t;
143 struct yy_buffer_state
145 istream* yy_input_file;
147 char *yy_ch_buf; /* input buffer */
148 char *yy_buf_pos; /* current position in input buffer */
150 /* Size of input buffer in bytes, not including room for EOB
151 * characters.
153 yy_size_t yy_buf_size;
155 /* Number of characters read into yy_ch_buf, not including EOB
156 * characters.
158 int yy_n_chars;
160 /* Whether we "own" the buffer - i.e., we know we created it,
161 * and can realloc() it to grow it, and should free() it to
162 * delete it.
164 int yy_is_our_buffer;
166 /* Whether this is an "interactive" input source; if so, and
167 * if we're using stdio for input, then we want to use getc()
168 * instead of fread(), to make sure we stop fetching input after
169 * each newline.
171 int yy_is_interactive;
173 /* Whether we're considered to be at the beginning of a line.
174 * If so, '^' rules will be active on the next match, otherwise
175 * not.
177 int yy_at_bol;
179 /* Whether to try to fill the input buffer when we reach the
180 * end of it.
182 int yy_fill_buffer;
184 int yy_buffer_status;
185 #define YY_BUFFER_NEW 0
186 #define YY_BUFFER_NORMAL 1
187 /* When an EOF's been seen but there's still some text to process
188 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
189 * shouldn't try reading from the input source any more. We might
190 * still have a bunch of tokens to match, though, because of
191 * possible backing-up.
193 * When we actually see the EOF, we change the status to "new"
194 * (via yyrestart()), so that the user can continue scanning by
195 * just pointing yyin at a new input file.
197 #define YY_BUFFER_EOF_PENDING 2
201 /* We provide macros for accessing buffer states in case in the
202 * future we want to put the buffer states in a more general
203 * "scanner state".
205 #define YY_CURRENT_BUFFER yy_current_buffer
209 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
210 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
211 static void yy_flex_free YY_PROTO(( void * ));
213 #define yy_new_buffer yy_create_buffer
215 #define yy_set_interactive(is_interactive) \
217 if ( ! yy_current_buffer ) \
218 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
219 yy_current_buffer->yy_is_interactive = is_interactive; \
222 #define yy_set_bol(at_bol) \
224 if ( ! yy_current_buffer ) \
225 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
226 yy_current_buffer->yy_at_bol = at_bol; \
229 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
232 #define yywrap() 1
233 #define YY_SKIP_YYWRAP
235 #define FLEX_DEBUG
236 typedef unsigned char YY_CHAR;
237 #define yytext_ptr yytext
238 #define YY_INTERACTIVE
240 #define FLEX_DEBUG
242 #include <FlexLexer.h>
243 int yyFlexLexer::yylex()
245 LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" );
246 return 0;
249 #define YY_DECL int My_lily_lexer::yylex()
252 /* Done after the current pattern has been matched and before the
253 * corresponding action - sets up yytext.
255 #define YY_DO_BEFORE_ACTION \
256 yytext_ptr = yy_bp; \
257 yyleng = (int) (yy_cp - yy_bp); \
258 yy_hold_char = *yy_cp; \
259 *yy_cp = '\0'; \
260 yy_c_buf_p = yy_cp;
262 #define YY_NUM_RULES 47
263 #define YY_END_OF_BUFFER 48
264 static yyconst short int yy_accept[124] =
265 { 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 8, 8, 48, 44, 7, 7, 1, 26, 18, 44,
268 41, 44, 44, 39, 36, 44, 40, 46, 7, 1,
269 13, 46, 34, 35, 7, 1, 31, 18, 35, 32,
270 34, 35, 25, 20, 23, 21, 44, 14, 28, 28,
271 1, 29, 30, 8, 8, 1, 9, 8, 7, 18,
272 16, 4, 5, 2, 0, 0, 38, 38, 39, 36,
273 45, 17, 37, 37, 13, 12, 34, 32, 34, 33,
274 42, 43, 33, 20, 24, 19, 21, 22, 22, 28,
275 27, 8, 8, 9, 9, 10, 6, 3, 38, 17,
277 15, 37, 37, 33, 33, 22, 22, 37, 33, 22,
278 37, 33, 22, 37, 33, 22, 37, 33, 22, 11,
279 11, 11, 0
282 static yyconst int yy_ec[256] =
283 { 0,
284 1, 1, 1, 1, 1, 1, 2, 2, 3, 4,
285 2, 3, 5, 2, 2, 2, 1, 1, 1, 1,
286 1, 1, 1, 2, 1, 2, 2, 2, 2, 1,
287 2, 3, 6, 7, 2, 8, 9, 2, 10, 2,
288 2, 11, 2, 2, 12, 13, 2, 14, 14, 14,
289 14, 14, 14, 14, 14, 14, 14, 15, 2, 2,
290 11, 2, 6, 2, 16, 16, 16, 16, 16, 16,
291 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
292 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
293 17, 18, 19, 20, 21, 20, 16, 16, 22, 23,
295 24, 16, 16, 16, 25, 16, 16, 26, 16, 27,
296 16, 16, 16, 28, 28, 29, 30, 16, 16, 16,
297 16, 16, 31, 2, 32, 2, 2, 1, 1, 1,
298 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
299 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
300 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
301 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
302 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
303 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
304 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
306 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
307 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
308 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
309 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
310 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
311 1, 1, 1, 1, 1
314 static yyconst int yy_meta[33] =
315 { 0,
316 1, 1, 2, 3, 1, 1, 4, 1, 5, 6,
317 1, 1, 1, 7, 1, 8, 1, 4, 1, 1,
318 9, 8, 8, 8, 8, 8, 10, 8, 10, 8,
319 1, 1
322 static yyconst short int yy_base[144] =
323 { 0,
324 0, 0, 30, 37, 46, 0, 78, 0, 107, 111,
325 115, 117, 409, 410, 124, 127, 410, 410, 129, 109,
326 410, 121, 394, 123, 0, 142, 410, 410, 135, 410,
327 400, 113, 0, 410, 138, 410, 410, 142, 144, 392,
328 0, 175, 410, 395, 390, 393, 200, 392, 0, 0,
329 0, 410, 0, 369, 368, 366, 142, 0, 149, 151,
330 410, 391, 410, 410, 350, 143, 330, 324, 146, 0,
331 410, 158, 0, 310, 329, 410, 0, 320, 0, 0,
332 410, 410, 299, 311, 305, 410, 304, 0, 283, 0,
333 410, 277, 0, 200, 201, 410, 286, 410, 217, 208,
335 410, 0, 199, 0, 198, 0, 196, 189, 188, 187,
336 149, 143, 133, 120, 100, 22, 19, 14, 12, 0,
337 0, 0, 410, 233, 243, 253, 263, 273, 277, 287,
338 297, 307, 312, 322, 329, 339, 349, 359, 369, 379,
339 383, 386, 389
342 static yyconst short int yy_def[144] =
343 { 0,
344 123, 1, 124, 124, 123, 5, 123, 7, 125, 125,
345 126, 126, 123, 123, 123, 123, 123, 123, 127, 128,
346 123, 123, 123, 123, 129, 130, 123, 123, 123, 123,
347 131, 128, 132, 123, 123, 123, 123, 127, 128, 123,
348 132, 123, 123, 123, 123, 133, 130, 133, 134, 134,
349 134, 123, 135, 136, 136, 136, 137, 138, 123, 127,
350 123, 139, 123, 123, 123, 123, 123, 123, 123, 129,
351 123, 140, 141, 141, 131, 123, 132, 123, 132, 142,
352 123, 123, 142, 123, 123, 123, 133, 143, 143, 134,
353 123, 136, 138, 137, 137, 123, 139, 123, 123, 140,
355 123, 141, 141, 142, 142, 143, 143, 141, 142, 143,
356 141, 142, 143, 141, 142, 143, 141, 142, 143, 141,
357 142, 143, 0, 123, 123, 123, 123, 123, 123, 123,
358 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
359 123, 123, 123
362 static yyconst short int yy_nxt[443] =
363 { 0,
364 14, 14, 15, 16, 17, 14, 18, 19, 20, 14,
365 21, 22, 23, 24, 21, 25, 14, 26, 14, 14,
366 14, 25, 25, 25, 25, 25, 25, 25, 25, 25,
367 27, 27, 29, 16, 30, 122, 31, 121, 32, 29,
368 16, 30, 120, 31, 119, 32, 33, 34, 35, 16,
369 36, 33, 37, 38, 39, 33, 34, 33, 34, 40,
370 33, 41, 34, 42, 34, 34, 41, 41, 41, 41,
371 41, 41, 41, 41, 41, 41, 34, 34, 14, 14,
372 15, 16, 17, 14, 43, 19, 20, 44, 14, 14,
373 14, 45, 14, 46, 14, 47, 14, 14, 14, 46,
375 46, 46, 46, 46, 46, 48, 46, 46, 14, 14,
376 50, 51, 63, 52, 50, 51, 63, 52, 55, 56,
377 55, 56, 118, 57, 53, 57, 59, 59, 53, 59,
378 59, 61, 61, 65, 66, 68, 69, 59, 59, 64,
379 59, 59, 117, 64, 61, 61, 58, 63, 58, 72,
380 95, 59, 59, 61, 61, 68, 66, 73, 68, 69,
381 101, 101, 116, 73, 73, 73, 74, 73, 73, 73,
382 73, 73, 115, 96, 64, 71, 71, 71, 114, 71,
383 71, 79, 72, 71, 79, 71, 71, 71, 71, 71,
384 80, 81, 71, 82, 79, 71, 80, 80, 80, 83,
386 80, 80, 80, 80, 80, 71, 71, 72, 123, 95,
387 101, 101, 113, 112, 111, 88, 81, 110, 82, 109,
388 108, 88, 88, 88, 89, 88, 88, 88, 88, 88,
389 99, 123, 96, 28, 28, 28, 28, 28, 28, 28,
390 28, 28, 28, 49, 49, 49, 49, 49, 49, 49,
391 49, 49, 49, 54, 54, 54, 54, 54, 54, 54,
392 54, 54, 54, 60, 60, 60, 60, 60, 60, 60,
393 60, 60, 60, 62, 62, 62, 62, 62, 62, 62,
394 62, 62, 62, 70, 70, 70, 70, 71, 71, 98,
395 71, 71, 71, 71, 71, 71, 71, 75, 75, 75,
397 75, 75, 75, 75, 75, 75, 75, 77, 93, 107,
398 77, 77, 77, 86, 77, 77, 77, 87, 85, 87,
399 84, 87, 90, 90, 90, 105, 90, 90, 90, 90,
400 90, 90, 91, 78, 91, 76, 103, 99, 91, 92,
401 92, 92, 92, 67, 92, 92, 92, 92, 92, 94,
402 94, 94, 94, 94, 94, 94, 94, 94, 94, 93,
403 93, 93, 93, 67, 93, 93, 93, 93, 93, 97,
404 97, 97, 97, 97, 97, 97, 97, 97, 97, 100,
405 100, 100, 100, 100, 100, 100, 100, 100, 100, 102,
406 102, 102, 102, 104, 98, 104, 106, 93, 106, 93,
408 93, 86, 86, 85, 84, 78, 76, 67, 123, 13,
409 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
410 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
411 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
412 123, 123
415 static yyconst short int yy_chk[443] =
416 { 0,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 3, 3, 3, 119, 3, 118, 3, 4,
421 4, 4, 117, 4, 116, 4, 5, 5, 5, 5,
422 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
423 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
424 5, 5, 5, 5, 5, 5, 5, 5, 7, 7,
425 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
426 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
428 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
429 9, 9, 20, 9, 10, 10, 32, 10, 11, 11,
430 12, 12, 115, 11, 9, 12, 15, 15, 10, 16,
431 16, 19, 19, 22, 22, 24, 24, 29, 29, 20,
432 35, 35, 114, 32, 38, 38, 11, 39, 12, 26,
433 57, 59, 59, 60, 60, 66, 66, 26, 69, 69,
434 72, 72, 113, 26, 26, 26, 26, 26, 26, 26,
435 26, 26, 112, 57, 39, 42, 42, 42, 111, 42,
436 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
437 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
439 42, 42, 42, 42, 42, 42, 42, 47, 94, 95,
440 100, 100, 110, 109, 108, 47, 47, 107, 47, 105,
441 103, 47, 47, 47, 47, 47, 47, 47, 47, 47,
442 99, 94, 95, 124, 124, 124, 124, 124, 124, 124,
443 124, 124, 124, 125, 125, 125, 125, 125, 125, 125,
444 125, 125, 125, 126, 126, 126, 126, 126, 126, 126,
445 126, 126, 126, 127, 127, 127, 127, 127, 127, 127,
446 127, 127, 127, 128, 128, 128, 128, 128, 128, 128,
447 128, 128, 128, 129, 129, 129, 129, 130, 130, 97,
448 130, 130, 130, 130, 130, 130, 130, 131, 131, 131,
450 131, 131, 131, 131, 131, 131, 131, 132, 92, 89,
451 132, 132, 132, 87, 132, 132, 132, 133, 85, 133,
452 84, 133, 134, 134, 134, 83, 134, 134, 134, 134,
453 134, 134, 135, 78, 135, 75, 74, 68, 135, 136,
454 136, 136, 136, 67, 136, 136, 136, 136, 136, 137,
455 137, 137, 137, 137, 137, 137, 137, 137, 137, 138,
456 138, 138, 138, 65, 138, 138, 138, 138, 138, 139,
457 139, 139, 139, 139, 139, 139, 139, 139, 139, 140,
458 140, 140, 140, 140, 140, 140, 140, 140, 140, 141,
459 141, 141, 141, 142, 62, 142, 143, 56, 143, 55,
461 54, 48, 46, 45, 44, 40, 31, 23, 13, 123,
462 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
463 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
464 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
465 123, 123
468 static yyconst short int yy_rule_linenum[47] =
469 { 0,
470 94, 99, 102, 104, 106, 108, 110, 116, 118, 121,
471 133, 136, 143, 147, 153, 158, 163, 167, 172, 176,
472 184, 189, 193, 198, 203, 208, 212, 215, 218, 223,
473 230, 233, 237, 240, 255, 267, 270, 273, 282, 287,
474 292, 298, 302, 306, 310, 325
477 /* The intent behind this definition is that it'll catch
478 * any uses of REJECT which flex missed.
480 #define REJECT reject_used_but_not_detected
481 #define yymore() yymore_used_but_not_detected
482 #define YY_MORE_ADJ 0
483 #define YY_RESTORE_YY_MORE_OFFSET
484 #line 1 "lexer.ll"
485 #define INITIAL 0
486 #line 2 "lexer.ll"
488 lexer.l -- implement the Flex lexer
490 source file of the LilyPond music typesetter
492 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
497 backup rules
499 after making a change to the lexer rules, run
500 flex -b <this lexer file>
501 and make sure that
502 lex.backup
503 contains no backup states, but only the reminder
504 Compressed tables always back up.
505 (don-t forget to rm lex.yy.cc :-)
509 #include <stdio.h>
510 #include <ctype.h>
512 #include "string.hh"
513 #include "string-convert.hh"
514 #include "my-lily-lexer.hh"
515 #include "varray.hh"
516 #include "interval.hh"
517 #include "parser.hh"
518 #include "debug.hh"
519 #include "parseconstruct.hh"
520 #include "main.hh"
521 #include "identifier.hh"
522 void strip_trailing_white (String&);
523 void strip_leading_white (String&);
526 #define start_quote() \
527 yy_push_state (quote);\
528 yylval.string = new String
530 #define yylval (*(YYSTYPE*)lexval_l)
532 #define YY_USER_ACTION add_lexed_char (YYLeng ());
533 #define YY_STACK_USED 1
534 #define YY_NEVER_INTERACTIVE 1
535 #define incl 1
537 #define lyrics 2
539 #define notes 3
541 #define quote 4
543 #define longcomment 5
545 #line 546 "lex.yy.cc"
547 /* Macros after this point can all be overridden by user definitions in
548 * section 1.
551 #ifndef YY_SKIP_YYWRAP
552 #ifdef __cplusplus
553 extern "C" int yywrap YY_PROTO(( void ));
554 #else
555 extern int yywrap YY_PROTO(( void ));
556 #endif
557 #endif
560 #ifndef yytext_ptr
561 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
562 #endif
564 #ifdef YY_NEED_STRLEN
565 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
566 #endif
568 #ifndef YY_NO_INPUT
569 #endif
571 #if YY_STACK_USED
572 static int yy_start_stack_ptr = 0;
573 static int yy_start_stack_depth = 0;
574 static int *yy_start_stack = 0;
575 #ifndef YY_NO_PUSH_STATE
576 static void yy_push_state YY_PROTO(( int new_state ));
577 #endif
578 #ifndef YY_NO_POP_STATE
579 static void yy_pop_state YY_PROTO(( void ));
580 #endif
581 #ifndef YY_NO_TOP_STATE
582 static int yy_top_state YY_PROTO(( void ));
583 #endif
585 #else
586 #define YY_NO_PUSH_STATE 1
587 #define YY_NO_POP_STATE 1
588 #define YY_NO_TOP_STATE 1
589 #endif
591 #ifdef YY_MALLOC_DECL
592 YY_MALLOC_DECL
593 #else
594 #if __STDC__
595 #ifndef __cplusplus
596 #include <stdlib.h>
597 #endif
598 #else
599 /* Just try to get by without declaring the routines. This will fail
600 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
601 * or sizeof(void*) != sizeof(int).
603 #endif
604 #endif
606 /* Amount of stuff to slurp up with each read. */
607 #ifndef YY_READ_BUF_SIZE
608 #define YY_READ_BUF_SIZE 8192
609 #endif
611 /* Copy whatever the last rule matched to the standard output. */
613 #ifndef ECHO
614 #define ECHO LexerOutput( yytext, yyleng )
615 #endif
617 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
618 * is returned in "result".
620 #ifndef YY_INPUT
621 #define YY_INPUT(buf,result,max_size) \
622 if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
623 YY_FATAL_ERROR( "input in flex scanner failed" );
624 #endif
626 /* No semi-colon after return; correct usage is to write "yyterminate();" -
627 * we don't want an extra ';' after the "return" because that will cause
628 * some compilers to complain about unreachable statements.
630 #ifndef yyterminate
631 #define yyterminate() return YY_NULL
632 #endif
634 /* Number of entries by which start-condition stack grows. */
635 #ifndef YY_START_STACK_INCR
636 #define YY_START_STACK_INCR 25
637 #endif
639 /* Report a fatal error. */
640 #ifndef YY_FATAL_ERROR
641 #define YY_FATAL_ERROR(msg) LexerError( msg )
642 #endif
644 /* Default declaration of generated scanner - a define so the user can
645 * easily add parameters.
647 #ifndef YY_DECL
648 #define YY_DECL int yyFlexLexer::yylex()
649 #endif
651 /* Code executed at the beginning of each rule, after yytext and yyleng
652 * have been set up.
654 #ifndef YY_USER_ACTION
655 #define YY_USER_ACTION
656 #endif
658 /* Code executed at the end of each rule. */
659 #ifndef YY_BREAK
660 #define YY_BREAK break;
661 #endif
663 #define YY_RULE_SETUP \
664 YY_USER_ACTION
666 YY_DECL
668 register yy_state_type yy_current_state;
669 register char *yy_cp, *yy_bp;
670 register int yy_act;
672 #line 91 "lexer.ll"
676 #line 677 "lex.yy.cc"
678 if ( yy_init )
680 yy_init = 0;
682 #ifdef YY_USER_INIT
683 YY_USER_INIT;
684 #endif
686 if ( ! yy_start )
687 yy_start = 1; /* first start state */
689 if ( ! yyin )
690 yyin = &cin;
692 if ( ! yyout )
693 yyout = &cout;
695 if ( ! yy_current_buffer )
696 yy_current_buffer =
697 yy_create_buffer( yyin, YY_BUF_SIZE );
699 yy_load_buffer_state();
702 while ( 1 ) /* loops until end-of-file is reached */
704 yy_cp = yy_c_buf_p;
706 /* Support of yytext. */
707 *yy_cp = yy_hold_char;
709 /* yy_bp points to the position in yy_ch_buf of the start of
710 * the current run.
712 yy_bp = yy_cp;
714 yy_current_state = yy_start;
715 yy_match:
718 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
719 if ( yy_accept[yy_current_state] )
721 yy_last_accepting_state = yy_current_state;
722 yy_last_accepting_cpos = yy_cp;
724 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
726 yy_current_state = (int) yy_def[yy_current_state];
727 if ( yy_current_state >= 124 )
728 yy_c = yy_meta[(unsigned int) yy_c];
730 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
731 ++yy_cp;
733 while ( yy_base[yy_current_state] != 410 );
735 yy_find_action:
736 yy_act = yy_accept[yy_current_state];
737 if ( yy_act == 0 )
738 { /* have to back up */
739 yy_cp = yy_last_accepting_cpos;
740 yy_current_state = yy_last_accepting_state;
741 yy_act = yy_accept[yy_current_state];
744 YY_DO_BEFORE_ACTION;
747 do_action: /* This label is used only to access EOF actions. */
749 if ( yy_flex_debug )
751 if ( yy_act == 0 )
752 cerr << "--scanner backing up\n";
753 else if ( yy_act < 47 )
754 cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] <<
755 "(\"" << yytext << "\")\n";
756 else if ( yy_act == 47 )
757 cerr << "--accepting default rule (\"" << yytext << "\")\n";
758 else if ( yy_act == 48 )
759 cerr << "--(end of buffer or a NUL)\n";
760 else
761 cerr << "--EOF (start condition " << YY_START << ")\n";
764 switch ( yy_act )
765 { /* beginning of action switch */
766 case 0: /* must back up */
767 /* undo the effects of YY_DO_BEFORE_ACTION */
768 *yy_cp = yy_hold_char;
769 yy_cp = yy_last_accepting_cpos;
770 yy_current_state = yy_last_accepting_state;
771 goto yy_find_action;
773 case 1:
774 YY_RULE_SETUP
775 #line 94 "lexer.ll"
777 // windows-suck-suck-suck
779 YY_BREAK
781 case 2:
782 YY_RULE_SETUP
783 #line 99 "lexer.ll"
785 yy_push_state (longcomment);
787 YY_BREAK
788 case 3:
789 YY_RULE_SETUP
790 #line 102 "lexer.ll"
793 YY_BREAK
794 case 4:
795 YY_RULE_SETUP
796 #line 104 "lexer.ll"
797 { // backup rule
799 YY_BREAK
800 case 5:
801 YY_RULE_SETUP
802 #line 106 "lexer.ll"
805 YY_BREAK
806 case 6:
807 YY_RULE_SETUP
808 #line 108 "lexer.ll"
811 YY_BREAK
812 case 7:
813 YY_RULE_SETUP
814 #line 110 "lexer.ll"
818 YY_BREAK
821 case 8:
822 YY_RULE_SETUP
823 #line 116 "lexer.ll"
826 YY_BREAK
827 case 9:
828 YY_RULE_SETUP
829 #line 118 "lexer.ll"
833 YY_BREAK
834 case 10:
835 YY_RULE_SETUP
836 #line 121 "lexer.ll"
838 yy_pop_state ();
840 YY_BREAK
841 case YY_STATE_EOF(longcomment):
842 #line 124 "lexer.ll"
844 LexerError ("EOF found inside a comment");
845 if (! close_input ())
846 yyterminate (); // can't move this, since it actually rets a YY_NULL
848 YY_BREAK
850 case 11:
851 YY_RULE_SETUP
852 #line 133 "lexer.ll"
854 yy_push_state (incl);
856 YY_BREAK
857 case 12:
858 YY_RULE_SETUP
859 #line 136 "lexer.ll"
860 { /* got the include file name */
861 String s (YYText ()+1);
862 s = s.left_str (s.length_i ()-1);
863 DOUT << "#include `" << s << "\'\n";
864 new_input (s,source_global_l);
865 yy_pop_state ();
867 YY_BREAK
868 case 13:
869 YY_RULE_SETUP
870 #line 143 "lexer.ll"
871 { // backup rule
872 cerr << "missing end quote" << endl;
873 exit (1);
875 YY_BREAK
876 case 14:
877 YY_RULE_SETUP
878 #line 147 "lexer.ll"
880 const char *s = YYText ();
881 yylval.string = new String (s);
882 DOUT << "rest:"<< yylval.string;
883 return RESTNAME;
885 YY_BREAK
886 case 15:
887 YY_RULE_SETUP
888 #line 153 "lexer.ll"
890 String s=YYText () + 2;
891 s=s.left_str (s.length_i () - 1);
892 return scan_escaped_word (s);
894 YY_BREAK
895 case 16:
896 YY_RULE_SETUP
897 #line 158 "lexer.ll"
899 String s=YYText () + 1;
900 s=s.left_str (s.length_i () - 1);
901 return scan_bare_word (s);
903 YY_BREAK
904 case 17:
905 YY_RULE_SETUP
906 #line 163 "lexer.ll"
907 { // backup rule
908 cerr << "white expected" << endl;
909 exit (1);
911 YY_BREAK
912 case 18:
913 YY_RULE_SETUP
914 #line 167 "lexer.ll"
915 { // backup rule
916 cerr << "white expected" << endl;
917 exit (1);
919 YY_BREAK
921 case 19:
922 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
923 yy_c_buf_p = yy_cp -= 1;
924 YY_DO_BEFORE_ACTION; /* set up yytext again */
925 YY_RULE_SETUP
926 #line 172 "lexer.ll"
928 post_quotes_b_ = true;
929 return scan_bare_word (YYText ());
931 YY_BREAK
932 case 20:
933 YY_RULE_SETUP
934 #line 176 "lexer.ll"
936 yylval.i = YYLeng ();
937 if (post_quotes_b_) {
938 post_quotes_b_ = false;
939 return POST_QUOTES;
940 } else
941 return PRE_QUOTES;
943 YY_BREAK
944 case 21:
945 YY_RULE_SETUP
946 #line 184 "lexer.ll"
948 return scan_bare_word (YYText ());
951 YY_BREAK
952 case 22:
953 YY_RULE_SETUP
954 #line 189 "lexer.ll"
956 return scan_escaped_word (YYText ()+1);
958 YY_BREAK
959 case 23:
960 YY_RULE_SETUP
961 #line 193 "lexer.ll"
963 yylval.i = String_convert::dec2_i (String (YYText ()));
964 return DIGIT;
966 YY_BREAK
967 case 24:
968 YY_RULE_SETUP
969 #line 198 "lexer.ll"
971 yylval.i = String_convert::dec2_i (String (YYText ()));
972 return UNSIGNED;
974 YY_BREAK
975 case 25:
976 YY_RULE_SETUP
977 #line 203 "lexer.ll"
979 start_quote ();
981 YY_BREAK
983 case 26:
984 YY_RULE_SETUP
985 #line 208 "lexer.ll"
987 start_quote ();
989 YY_BREAK
991 case 27:
992 YY_RULE_SETUP
993 #line 212 "lexer.ll"
995 *yylval.string += escaped_char(YYText()[1]);
997 YY_BREAK
998 case 28:
999 YY_RULE_SETUP
1000 #line 215 "lexer.ll"
1002 *yylval.string += YYText ();
1004 YY_BREAK
1005 case 29:
1006 YY_RULE_SETUP
1007 #line 218 "lexer.ll"
1009 DOUT << "quoted string: `" << *yylval.string << "'\n";
1010 yy_pop_state ();
1011 return STRING;
1013 YY_BREAK
1014 case 30:
1015 YY_RULE_SETUP
1016 #line 223 "lexer.ll"
1018 *yylval.string += YYText ();
1020 YY_BREAK
1023 case 31:
1024 YY_RULE_SETUP
1025 #line 230 "lexer.ll"
1027 start_quote ();
1029 YY_BREAK
1030 case 32:
1031 YY_RULE_SETUP
1032 #line 233 "lexer.ll"
1034 yylval.i = String_convert::dec2_i (String (YYText ()));
1035 return UNSIGNED;
1037 YY_BREAK
1038 case 33:
1039 YY_RULE_SETUP
1040 #line 237 "lexer.ll"
1042 return scan_escaped_word (YYText ()+1);
1044 YY_BREAK
1045 case 34:
1046 YY_RULE_SETUP
1047 #line 240 "lexer.ll"
1049 /* ugr. This sux. */
1050 String s (YYText ());
1051 int i = 0;
1052 while ((i=s.index_i ("_")) != -1) // change word binding "_" to " "
1053 *(s.ch_l () + i) = ' ';
1054 if ((i=s.index_i ("\\,")) != -1) // change "\," to TeX's "\c "
1056 *(s.ch_l () + i + 1) = 'c';
1057 s = s.left_str (i+2) + " " + s.right_str (s.length_i ()-i-2);
1059 yylval.string = new String (s);
1060 DOUT << "lyric : `" << s << "'\n";
1061 return STRING;
1063 YY_BREAK
1064 case 35:
1065 YY_RULE_SETUP
1066 #line 255 "lexer.ll"
1068 return yylval.c = YYText ()[0];
1070 YY_BREAK
1072 case YY_STATE_EOF(INITIAL):
1073 case YY_STATE_EOF(incl):
1074 case YY_STATE_EOF(lyrics):
1075 case YY_STATE_EOF(notes):
1076 case YY_STATE_EOF(quote):
1077 #line 260 "lexer.ll"
1079 DOUT << "<<eof>>";
1081 if (! close_input ()) {
1082 yyterminate (); // can't move this, since it actually rets a YY_NULL
1085 YY_BREAK
1086 case 36:
1087 YY_RULE_SETUP
1088 #line 267 "lexer.ll"
1090 return scan_bare_word (YYText ());
1092 YY_BREAK
1093 case 37:
1094 YY_RULE_SETUP
1095 #line 270 "lexer.ll"
1097 return scan_escaped_word (YYText ()+1);
1099 YY_BREAK
1100 case 38:
1101 YY_RULE_SETUP
1102 #line 273 "lexer.ll"
1104 Real r;
1105 int cnv=sscanf (YYText (), "%lf", &r);
1106 assert (cnv == 1);
1107 DOUT << "REAL" << r<<'\n';
1108 yylval.real = r;
1109 return REAL;
1111 YY_BREAK
1112 case 39:
1113 YY_RULE_SETUP
1114 #line 282 "lexer.ll"
1116 yylval.i = String_convert::dec2_i (String (YYText ()));
1117 return UNSIGNED;
1119 YY_BREAK
1120 case 40:
1121 YY_RULE_SETUP
1122 #line 287 "lexer.ll"
1125 DOUT << "parens\n";
1126 return YYText ()[0];
1128 YY_BREAK
1129 case 41:
1130 YY_RULE_SETUP
1131 #line 292 "lexer.ll"
1133 char c = YYText ()[0];
1134 DOUT << "misc char" <<c<<"\n";
1135 return c;
1137 YY_BREAK
1138 case 42:
1139 YY_RULE_SETUP
1140 #line 298 "lexer.ll"
1142 return yylval.i = PLET;
1144 YY_BREAK
1145 case 43:
1146 YY_RULE_SETUP
1147 #line 302 "lexer.ll"
1149 return yylval.i = TELP;
1151 YY_BREAK
1152 case 44:
1153 YY_RULE_SETUP
1154 #line 306 "lexer.ll"
1156 return yylval.c = YYText ()[0];
1158 YY_BREAK
1159 case 45:
1160 YY_RULE_SETUP
1161 #line 310 "lexer.ll"
1163 char c= YYText ()[1];
1164 yylval.c = c;
1165 switch (c) {
1166 case '>':
1167 return E_BIGGER;
1168 case '<':
1169 return E_SMALLER;
1170 case '!':
1171 return E_EXCLAMATION;
1172 default:
1173 return E_CHAR;
1176 YY_BREAK
1177 case 46:
1178 YY_RULE_SETUP
1179 #line 325 "lexer.ll"
1181 String msg= String ("illegal character: ") +String (YYText ()[0]);
1182 LexerError (msg.ch_C ());
1183 return YYText ()[0];
1185 YY_BREAK
1186 case 47:
1187 YY_RULE_SETUP
1188 #line 331 "lexer.ll"
1189 YY_FATAL_ERROR( "flex scanner jammed" );
1190 YY_BREAK
1191 #line 1192 "lex.yy.cc"
1193 case YY_END_OF_BUFFER:
1195 /* Amount of text matched not including the EOB char. */
1196 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
1198 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1199 *yy_cp = yy_hold_char;
1200 YY_RESTORE_YY_MORE_OFFSET
1202 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
1204 /* We're scanning a new file or input source. It's
1205 * possible that this happened because the user
1206 * just pointed yyin at a new source and called
1207 * yylex(). If so, then we have to assure
1208 * consistency between yy_current_buffer and our
1209 * globals. Here is the right place to do so, because
1210 * this is the first action (other than possibly a
1211 * back-up) that will match for the new input source.
1213 yy_n_chars = yy_current_buffer->yy_n_chars;
1214 yy_current_buffer->yy_input_file = yyin;
1215 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
1218 /* Note that here we test for yy_c_buf_p "<=" to the position
1219 * of the first EOB in the buffer, since yy_c_buf_p will
1220 * already have been incremented past the NUL character
1221 * (since all states make transitions on EOB to the
1222 * end-of-buffer state). Contrast this with the test
1223 * in input().
1225 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1226 { /* This was really a NUL. */
1227 yy_state_type yy_next_state;
1229 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
1231 yy_current_state = yy_get_previous_state();
1233 /* Okay, we're now positioned to make the NUL
1234 * transition. We couldn't have
1235 * yy_get_previous_state() go ahead and do it
1236 * for us because it doesn't know how to deal
1237 * with the possibility of jamming (and we don't
1238 * want to build jamming into it because then it
1239 * will run more slowly).
1242 yy_next_state = yy_try_NUL_trans( yy_current_state );
1244 yy_bp = yytext_ptr + YY_MORE_ADJ;
1246 if ( yy_next_state )
1248 /* Consume the NUL. */
1249 yy_cp = ++yy_c_buf_p;
1250 yy_current_state = yy_next_state;
1251 goto yy_match;
1254 else
1256 yy_cp = yy_c_buf_p;
1257 goto yy_find_action;
1261 else switch ( yy_get_next_buffer() )
1263 case EOB_ACT_END_OF_FILE:
1265 yy_did_buffer_switch_on_eof = 0;
1267 if ( yywrap() )
1269 /* Note: because we've taken care in
1270 * yy_get_next_buffer() to have set up
1271 * yytext, we can now set up
1272 * yy_c_buf_p so that if some total
1273 * hoser (like flex itself) wants to
1274 * call the scanner after we return the
1275 * YY_NULL, it'll still work - another
1276 * YY_NULL will get returned.
1278 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1280 yy_act = YY_STATE_EOF(YY_START);
1281 goto do_action;
1284 else
1286 if ( ! yy_did_buffer_switch_on_eof )
1287 YY_NEW_FILE;
1289 break;
1292 case EOB_ACT_CONTINUE_SCAN:
1293 yy_c_buf_p =
1294 yytext_ptr + yy_amount_of_matched_text;
1296 yy_current_state = yy_get_previous_state();
1298 yy_cp = yy_c_buf_p;
1299 yy_bp = yytext_ptr + YY_MORE_ADJ;
1300 goto yy_match;
1302 case EOB_ACT_LAST_MATCH:
1303 yy_c_buf_p =
1304 &yy_current_buffer->yy_ch_buf[yy_n_chars];
1306 yy_current_state = yy_get_previous_state();
1308 yy_cp = yy_c_buf_p;
1309 yy_bp = yytext_ptr + YY_MORE_ADJ;
1310 goto yy_find_action;
1312 break;
1315 default:
1316 YY_FATAL_ERROR(
1317 "fatal flex scanner internal error--no action found" );
1318 } /* end of action switch */
1319 } /* end of scanning one token */
1320 } /* end of yylex */
1322 yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
1324 yyin = arg_yyin;
1325 yyout = arg_yyout;
1326 yy_c_buf_p = 0;
1327 yy_init = 1;
1328 yy_start = 0;
1329 yy_flex_debug = 0;
1330 yylineno = 1; // this will only get updated if %option yylineno
1332 yy_did_buffer_switch_on_eof = 0;
1334 yy_looking_for_trail_begin = 0;
1335 yy_more_flag = 0;
1336 yy_more_len = 0;
1337 yy_more_offset = yy_prev_more_offset = 0;
1339 yy_start_stack_ptr = yy_start_stack_depth = 0;
1340 yy_start_stack = 0;
1342 yy_current_buffer = 0;
1344 #ifdef YY_USES_REJECT
1345 yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
1346 #else
1347 yy_state_buf = 0;
1348 #endif
1351 yyFlexLexer::~yyFlexLexer()
1353 delete yy_state_buf;
1354 yy_delete_buffer( yy_current_buffer );
1357 void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
1359 if ( new_in )
1361 yy_delete_buffer( yy_current_buffer );
1362 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
1365 if ( new_out )
1366 yyout = new_out;
1369 #ifdef YY_INTERACTIVE
1370 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
1371 #else
1372 int yyFlexLexer::LexerInput( char* buf, int max_size )
1373 #endif
1375 if ( yyin->eof() || yyin->fail() )
1376 return 0;
1378 #ifdef YY_INTERACTIVE
1379 yyin->get( buf[0] );
1381 if ( yyin->eof() )
1382 return 0;
1384 if ( yyin->bad() )
1385 return -1;
1387 return 1;
1389 #else
1390 (void) yyin->read( buf, max_size );
1392 if ( yyin->bad() )
1393 return -1;
1394 else
1395 return yyin->gcount();
1396 #endif
1399 void yyFlexLexer::LexerOutput( const char* buf, int size )
1401 (void) yyout->write( buf, size );
1404 /* yy_get_next_buffer - try to read in a new buffer
1406 * Returns a code representing an action:
1407 * EOB_ACT_LAST_MATCH -
1408 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1409 * EOB_ACT_END_OF_FILE - end of file
1412 int yyFlexLexer::yy_get_next_buffer()
1414 register char *dest = yy_current_buffer->yy_ch_buf;
1415 register char *source = yytext_ptr;
1416 register int number_to_move, i;
1417 int ret_val;
1419 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1420 YY_FATAL_ERROR(
1421 "fatal flex scanner internal error--end of buffer missed" );
1423 if ( yy_current_buffer->yy_fill_buffer == 0 )
1424 { /* Don't try to fill the buffer, so this is an EOF. */
1425 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1427 /* We matched a single character, the EOB, so
1428 * treat this as a final EOF.
1430 return EOB_ACT_END_OF_FILE;
1433 else
1435 /* We matched some text prior to the EOB, first
1436 * process it.
1438 return EOB_ACT_LAST_MATCH;
1442 /* Try to read more data. */
1444 /* First move last chars to start of buffer. */
1445 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1447 for ( i = 0; i < number_to_move; ++i )
1448 *(dest++) = *(source++);
1450 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1451 /* don't do the read, it's not guaranteed to return an EOF,
1452 * just force an EOF
1454 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1456 else
1458 int num_to_read =
1459 yy_current_buffer->yy_buf_size - number_to_move - 1;
1461 while ( num_to_read <= 0 )
1462 { /* Not enough room in the buffer - grow it. */
1463 #ifdef YY_USES_REJECT
1464 YY_FATAL_ERROR(
1465 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1466 #else
1468 /* just a shorter name for the current buffer */
1469 YY_BUFFER_STATE b = yy_current_buffer;
1471 int yy_c_buf_p_offset =
1472 (int) (yy_c_buf_p - b->yy_ch_buf);
1474 if ( b->yy_is_our_buffer )
1476 int new_size = b->yy_buf_size * 2;
1478 if ( new_size <= 0 )
1479 b->yy_buf_size += b->yy_buf_size / 8;
1480 else
1481 b->yy_buf_size *= 2;
1483 b->yy_ch_buf = (char *)
1484 /* Include room in for 2 EOB chars. */
1485 yy_flex_realloc( (void *) b->yy_ch_buf,
1486 b->yy_buf_size + 2 );
1488 else
1489 /* Can't grow it, we don't own it. */
1490 b->yy_ch_buf = 0;
1492 if ( ! b->yy_ch_buf )
1493 YY_FATAL_ERROR(
1494 "fatal error - scanner input buffer overflow" );
1496 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1498 num_to_read = yy_current_buffer->yy_buf_size -
1499 number_to_move - 1;
1500 #endif
1503 if ( num_to_read > YY_READ_BUF_SIZE )
1504 num_to_read = YY_READ_BUF_SIZE;
1506 /* Read in more data. */
1507 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1508 yy_n_chars, num_to_read );
1510 yy_current_buffer->yy_n_chars = yy_n_chars;
1513 if ( yy_n_chars == 0 )
1515 if ( number_to_move == YY_MORE_ADJ )
1517 ret_val = EOB_ACT_END_OF_FILE;
1518 yyrestart( yyin );
1521 else
1523 ret_val = EOB_ACT_LAST_MATCH;
1524 yy_current_buffer->yy_buffer_status =
1525 YY_BUFFER_EOF_PENDING;
1529 else
1530 ret_val = EOB_ACT_CONTINUE_SCAN;
1532 yy_n_chars += number_to_move;
1533 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1534 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1536 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1538 return ret_val;
1542 /* yy_get_previous_state - get the state just before the EOB char was reached */
1544 yy_state_type yyFlexLexer::yy_get_previous_state()
1546 register yy_state_type yy_current_state;
1547 register char *yy_cp;
1549 yy_current_state = yy_start;
1551 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1553 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 2);
1554 if ( yy_accept[yy_current_state] )
1556 yy_last_accepting_state = yy_current_state;
1557 yy_last_accepting_cpos = yy_cp;
1559 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1561 yy_current_state = (int) yy_def[yy_current_state];
1562 if ( yy_current_state >= 124 )
1563 yy_c = yy_meta[(unsigned int) yy_c];
1565 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1568 return yy_current_state;
1572 /* yy_try_NUL_trans - try to make a transition on the NUL character
1574 * synopsis
1575 * next_state = yy_try_NUL_trans( current_state );
1578 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
1580 register int yy_is_jam;
1581 register char *yy_cp = yy_c_buf_p;
1583 register YY_CHAR yy_c = 2;
1584 if ( yy_accept[yy_current_state] )
1586 yy_last_accepting_state = yy_current_state;
1587 yy_last_accepting_cpos = yy_cp;
1589 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1591 yy_current_state = (int) yy_def[yy_current_state];
1592 if ( yy_current_state >= 124 )
1593 yy_c = yy_meta[(unsigned int) yy_c];
1595 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1596 yy_is_jam = (yy_current_state == 123);
1598 return yy_is_jam ? 0 : yy_current_state;
1602 void yyFlexLexer::yyunput( int c, register char* yy_bp )
1604 register char *yy_cp = yy_c_buf_p;
1606 /* undo effects of setting up yytext */
1607 *yy_cp = yy_hold_char;
1609 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1610 { /* need to shift things up to make room */
1611 /* +2 for EOB chars. */
1612 register int number_to_move = yy_n_chars + 2;
1613 register char *dest = &yy_current_buffer->yy_ch_buf[
1614 yy_current_buffer->yy_buf_size + 2];
1615 register char *source =
1616 &yy_current_buffer->yy_ch_buf[number_to_move];
1618 while ( source > yy_current_buffer->yy_ch_buf )
1619 *--dest = *--source;
1621 yy_cp += (int) (dest - source);
1622 yy_bp += (int) (dest - source);
1623 yy_current_buffer->yy_n_chars =
1624 yy_n_chars = yy_current_buffer->yy_buf_size;
1626 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1627 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1630 *--yy_cp = (char) c;
1633 yytext_ptr = yy_bp;
1634 yy_hold_char = *yy_cp;
1635 yy_c_buf_p = yy_cp;
1639 int yyFlexLexer::yyinput()
1641 int c;
1643 *yy_c_buf_p = yy_hold_char;
1645 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1647 /* yy_c_buf_p now points to the character we want to return.
1648 * If this occurs *before* the EOB characters, then it's a
1649 * valid NUL; if not, then we've hit the end of the buffer.
1651 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1652 /* This was really a NUL. */
1653 *yy_c_buf_p = '\0';
1655 else
1656 { /* need more input */
1657 int offset = yy_c_buf_p - yytext_ptr;
1658 ++yy_c_buf_p;
1660 switch ( yy_get_next_buffer() )
1662 case EOB_ACT_LAST_MATCH:
1663 /* This happens because yy_g_n_b()
1664 * sees that we've accumulated a
1665 * token and flags that we need to
1666 * try matching the token before
1667 * proceeding. But for input(),
1668 * there's no matching to consider.
1669 * So convert the EOB_ACT_LAST_MATCH
1670 * to EOB_ACT_END_OF_FILE.
1673 /* Reset buffer status. */
1674 yyrestart( yyin );
1676 /* fall through */
1678 case EOB_ACT_END_OF_FILE:
1680 if ( yywrap() )
1681 return EOF;
1683 if ( ! yy_did_buffer_switch_on_eof )
1684 YY_NEW_FILE;
1685 #ifdef __cplusplus
1686 return yyinput();
1687 #else
1688 return input();
1689 #endif
1692 case EOB_ACT_CONTINUE_SCAN:
1693 yy_c_buf_p = yytext_ptr + offset;
1694 break;
1699 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1700 *yy_c_buf_p = '\0'; /* preserve yytext */
1701 yy_hold_char = *++yy_c_buf_p;
1704 return c;
1708 void yyFlexLexer::yyrestart( istream* input_file )
1710 if ( ! yy_current_buffer )
1711 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1713 yy_init_buffer( yy_current_buffer, input_file );
1714 yy_load_buffer_state();
1718 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1720 if ( yy_current_buffer == new_buffer )
1721 return;
1723 if ( yy_current_buffer )
1725 /* Flush out information for old buffer. */
1726 *yy_c_buf_p = yy_hold_char;
1727 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1728 yy_current_buffer->yy_n_chars = yy_n_chars;
1731 yy_current_buffer = new_buffer;
1732 yy_load_buffer_state();
1734 /* We don't actually know whether we did this switch during
1735 * EOF (yywrap()) processing, but the only time this flag
1736 * is looked at is after yywrap() is called, so it's safe
1737 * to go ahead and always set it.
1739 yy_did_buffer_switch_on_eof = 1;
1743 void yyFlexLexer::yy_load_buffer_state()
1745 yy_n_chars = yy_current_buffer->yy_n_chars;
1746 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1747 yyin = yy_current_buffer->yy_input_file;
1748 yy_hold_char = *yy_c_buf_p;
1752 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
1754 YY_BUFFER_STATE b;
1756 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1757 if ( ! b )
1758 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1760 b->yy_buf_size = size;
1762 /* yy_ch_buf has to be 2 characters longer than the size given because
1763 * we need to put in 2 end-of-buffer characters.
1765 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1766 if ( ! b->yy_ch_buf )
1767 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1769 b->yy_is_our_buffer = 1;
1771 yy_init_buffer( b, file );
1773 return b;
1777 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1779 if ( ! b )
1780 return;
1782 if ( b == yy_current_buffer )
1783 yy_current_buffer = (YY_BUFFER_STATE) 0;
1785 if ( b->yy_is_our_buffer )
1786 yy_flex_free( (void *) b->yy_ch_buf );
1788 yy_flex_free( (void *) b );
1792 extern "C" int isatty YY_PROTO(( int ));
1793 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
1796 yy_flush_buffer( b );
1798 b->yy_input_file = file;
1799 b->yy_fill_buffer = 1;
1801 b->yy_is_interactive = 0;
1805 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1807 if ( ! b )
1808 return;
1810 b->yy_n_chars = 0;
1812 /* We always need two end-of-buffer characters. The first causes
1813 * a transition to the end-of-buffer state. The second causes
1814 * a jam in that state.
1816 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1817 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1819 b->yy_buf_pos = &b->yy_ch_buf[0];
1821 b->yy_at_bol = 1;
1822 b->yy_buffer_status = YY_BUFFER_NEW;
1824 if ( b == yy_current_buffer )
1825 yy_load_buffer_state();
1829 #ifndef YY_NO_SCAN_BUFFER
1830 #endif
1833 #ifndef YY_NO_SCAN_STRING
1834 #endif
1837 #ifndef YY_NO_SCAN_BYTES
1838 #endif
1841 #ifndef YY_NO_PUSH_STATE
1842 void yyFlexLexer::yy_push_state( int new_state )
1844 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1846 yy_size_t new_size;
1848 yy_start_stack_depth += YY_START_STACK_INCR;
1849 new_size = yy_start_stack_depth * sizeof( int );
1851 if ( ! yy_start_stack )
1852 yy_start_stack = (int *) yy_flex_alloc( new_size );
1854 else
1855 yy_start_stack = (int *) yy_flex_realloc(
1856 (void *) yy_start_stack, new_size );
1858 if ( ! yy_start_stack )
1859 YY_FATAL_ERROR(
1860 "out of memory expanding start-condition stack" );
1863 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1865 BEGIN(new_state);
1867 #endif
1870 #ifndef YY_NO_POP_STATE
1871 void yyFlexLexer::yy_pop_state()
1873 if ( --yy_start_stack_ptr < 0 )
1874 YY_FATAL_ERROR( "start-condition stack underflow" );
1876 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1878 #endif
1881 #ifndef YY_NO_TOP_STATE
1882 int yyFlexLexer::yy_top_state()
1884 return yy_start_stack[yy_start_stack_ptr - 1];
1886 #endif
1888 #ifndef YY_EXIT_FAILURE
1889 #define YY_EXIT_FAILURE 2
1890 #endif
1893 void yyFlexLexer::LexerError( yyconst char msg[] )
1895 cerr << msg << '\n';
1896 exit( YY_EXIT_FAILURE );
1900 /* Redefine yyless() so it works in section 3 code. */
1902 #undef yyless
1903 #define yyless(n) \
1904 do \
1906 /* Undo effects of setting up yytext. */ \
1907 yytext[yyleng] = yy_hold_char; \
1908 yy_c_buf_p = yytext + n; \
1909 yy_hold_char = *yy_c_buf_p; \
1910 *yy_c_buf_p = '\0'; \
1911 yyleng = n; \
1913 while ( 0 )
1916 /* Internal utility routines. */
1918 #ifndef yytext_ptr
1919 #ifdef YY_USE_PROTOS
1920 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1921 #else
1922 static void yy_flex_strncpy( s1, s2, n )
1923 char *s1;
1924 yyconst char *s2;
1925 int n;
1926 #endif
1928 register int i;
1929 for ( i = 0; i < n; ++i )
1930 s1[i] = s2[i];
1932 #endif
1934 #ifdef YY_NEED_STRLEN
1935 #ifdef YY_USE_PROTOS
1936 static int yy_flex_strlen( yyconst char *s )
1937 #else
1938 static int yy_flex_strlen( s )
1939 yyconst char *s;
1940 #endif
1942 register int n;
1943 for ( n = 0; s[n]; ++n )
1946 return n;
1948 #endif
1951 #ifdef YY_USE_PROTOS
1952 static void *yy_flex_alloc( yy_size_t size )
1953 #else
1954 static void *yy_flex_alloc( size )
1955 yy_size_t size;
1956 #endif
1958 return (void *) malloc( size );
1961 #ifdef YY_USE_PROTOS
1962 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1963 #else
1964 static void *yy_flex_realloc( ptr, size )
1965 void *ptr;
1966 yy_size_t size;
1967 #endif
1969 /* The cast to (char *) in the following accommodates both
1970 * implementations that use char* generic pointers, and those
1971 * that use void* generic pointers. It works with the latter
1972 * because both ANSI C and C++ allow castless assignment from
1973 * any pointer type to void*, and deal with argument conversions
1974 * as though doing an assignment.
1976 return (void *) realloc( (char *) ptr, size );
1979 #ifdef YY_USE_PROTOS
1980 static void yy_flex_free( void *ptr )
1981 #else
1982 static void yy_flex_free( ptr )
1983 void *ptr;
1984 #endif
1986 free( ptr );
1989 #if YY_MAIN
1990 int main()
1992 yylex();
1993 return 0;
1995 #endif
1996 #line 331 "lexer.ll"
1999 void
2000 My_lily_lexer::push_note_state ()
2002 yy_push_state (notes);
2005 void
2006 My_lily_lexer::push_lyric_state ()
2008 yy_push_state (lyrics);
2010 void
2011 My_lily_lexer::pop_state ()
2013 yy_pop_state ();
2017 My_lily_lexer::scan_escaped_word (String str)
2019 DOUT << "\\word: `" << str<<"'\n";
2020 int l = lookup_keyword (str);
2021 if (l != -1) {
2022 DOUT << "(keyword)\n";
2023 return l;
2025 Identifier * id = lookup_identifier (str);
2026 if (id) {
2027 DOUT << "(identifier)\n";
2028 yylval.id = id;
2029 return id->token_code_i_;
2031 if (YYSTATE != notes) {
2032 Melodic_req * mel_l = lookup_melodic_req_l (str);
2033 if (mel_l) {
2034 DOUT << "(notename)\n";
2035 yylval.melreq = mel_l;
2036 return NOTENAME_ID;
2039 String msg ("Unknown escaped string: `" + str + "'");
2040 LexerError (msg.ch_C ());
2041 DOUT << "(string)";
2042 String *sp = new String (str);
2043 yylval.string=sp;
2044 return STRING;
2048 My_lily_lexer::scan_bare_word (String str)
2050 DOUT << "word: `" << str<< "'\n";
2051 if (YYSTATE == notes){
2052 Melodic_req * mel_l = lookup_melodic_req_l (str);
2053 if (mel_l) {
2054 DOUT << "(notename)\n";
2055 yylval.melreq = mel_l;
2056 return NOTENAME_ID;
2060 yylval.string=new String (str);
2061 return STRING;
2064 bool
2065 My_lily_lexer::note_state_b () const
2067 return YY_START == notes;
2070 bool
2071 My_lily_lexer::lyric_state_b () const
2073 return YY_START == lyrics;
2076 void
2077 strip_trailing_white (String&s)
2079 int i=0;
2080 for (; i < s.length_i (); i++)
2081 if (!isspace (s[i]))
2082 break;
2084 s = s.nomid_str (0, i);
2087 void
2088 strip_leading_white (String&s)
2090 int i=s.length_i ();
2091 while (i--)
2092 if (!isspace (s[i]))
2093 break;
2095 s = s.left_str (i+1);