2 /* A lexical scanner generated by flex */
4 /* Scanner skeleton version:
5 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
14 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
28 /* Use prototypes in function declarations. */
31 /* The "const" storage-class-modifier is valid. */
34 #else /* ! __cplusplus */
42 #endif /* ! __cplusplus */
61 #define YY_PROTO(proto) proto
63 #define YY_PROTO(proto) ()
66 /* Returned upon end-of-file. */
69 /* Promotes a possibly negative, possibly signed char to an unsigned
70 * integer for use as an array index. If the signed char is negative,
71 * we want to instead treat it as an 8-bit unsigned char, hence the
74 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
76 /* Enter a start condition. This macro really ought to take a parameter,
77 * but we do it the disgusting crufty way forced on us by the ()-less
78 * definition of BEGIN.
80 #define BEGIN yy_start = 1 + 2 *
82 /* Translate the current start state into a value that can be later handed
83 * to BEGIN to return to the state. The YYSTATE alias is for lex
86 #define YY_START ((yy_start - 1) / 2)
87 #define YYSTATE YY_START
89 /* Action number for EOF rule of a given start state. */
90 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
92 /* Special action meaning "start processing a new file". */
93 #define YY_NEW_FILE yyrestart( yyin )
95 #define YY_END_OF_BUFFER_CHAR 0
97 /* Size of default input buffer. */
98 #define YY_BUF_SIZE 16384
100 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
104 #define EOB_ACT_CONTINUE_SCAN 0
105 #define EOB_ACT_END_OF_FILE 1
106 #define EOB_ACT_LAST_MATCH 2
108 /* The funky do-while in the following #define is used to turn the definition
109 * int a single C statement (which needs a semi-colon terminator). This
110 * avoids problems with code like:
112 * if ( condition_holds )
115 * do_something_else();
117 * Prior to using the do-while the compiler would get upset at the
118 * "else" because it interpreted the "if" statement as being all
119 * done when it reached the ';' after the yyless() call.
122 /* Return all but the first 'n' matched characters back to the input stream. */
127 /* Undo effects of setting up yytext. */ \
128 *yy_cp = yy_hold_char; \
129 YY_RESTORE_YY_MORE_OFFSET \
130 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
131 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
135 #define unput(c) yyunput( c, yytext_ptr )
137 /* The following is because we cannot portably get our hands on size_t
138 * (without autoconf's help, which isn't available because we want
139 * flex-generated scanners to compile on their own).
141 typedef unsigned int yy_size_t
;
144 struct yy_buffer_state
146 istream
* yy_input_file
;
148 char *yy_ch_buf
; /* input buffer */
149 char *yy_buf_pos
; /* current position in input buffer */
151 /* Size of input buffer in bytes, not including room for EOB
154 yy_size_t yy_buf_size
;
156 /* Number of characters read into yy_ch_buf, not including EOB
161 /* Whether we "own" the buffer - i.e., we know we created it,
162 * and can realloc() it to grow it, and should free() it to
165 int yy_is_our_buffer
;
167 /* Whether this is an "interactive" input source; if so, and
168 * if we're using stdio for input, then we want to use getc()
169 * instead of fread(), to make sure we stop fetching input after
172 int yy_is_interactive
;
174 /* Whether we're considered to be at the beginning of a line.
175 * If so, '^' rules will be active on the next match, otherwise
180 /* Whether to try to fill the input buffer when we reach the
185 int yy_buffer_status
;
186 #define YY_BUFFER_NEW 0
187 #define YY_BUFFER_NORMAL 1
188 /* When an EOF's been seen but there's still some text to process
189 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
190 * shouldn't try reading from the input source any more. We might
191 * still have a bunch of tokens to match, though, because of
192 * possible backing-up.
194 * When we actually see the EOF, we change the status to "new"
195 * (via yyrestart()), so that the user can continue scanning by
196 * just pointing yyin at a new input file.
198 #define YY_BUFFER_EOF_PENDING 2
202 /* We provide macros for accessing buffer states in case in the
203 * future we want to put the buffer states in a more general
206 #define YY_CURRENT_BUFFER yy_current_buffer
210 static void *yy_flex_alloc
YY_PROTO(( yy_size_t
));
211 static void *yy_flex_realloc
YY_PROTO(( void *, yy_size_t
));
212 static void yy_flex_free
YY_PROTO(( void * ));
214 #define yy_new_buffer yy_create_buffer
216 #define yy_set_interactive(is_interactive) \
218 if ( ! yy_current_buffer ) \
219 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
220 yy_current_buffer->yy_is_interactive = is_interactive; \
223 #define yy_set_bol(at_bol) \
225 if ( ! yy_current_buffer ) \
226 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
227 yy_current_buffer->yy_at_bol = at_bol; \
230 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
233 #define YY_USES_REJECT
234 typedef unsigned char YY_CHAR
;
235 #define yytext_ptr yytext
236 #define YY_INTERACTIVE
238 #include <FlexLexer.h>
239 int yyFlexLexer::yylex()
241 LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" );
245 #define YY_DECL int SExprLexer::yylex()
248 /* Done after the current pattern has been matched and before the
249 * corresponding action - sets up yytext.
251 #define YY_DO_BEFORE_ACTION \
252 yytext_ptr = yy_bp; \
253 yyleng = (int) (yy_cp - yy_bp); \
254 yy_hold_char = *yy_cp; \
258 #define YY_NUM_RULES 14
259 #define YY_END_OF_BUFFER 15
260 static yyconst
short int yy_acclist
[62] =
262 15, 13, 14, 1, 14, 12, 13, 14, 6, 13,
263 14, 3, 13, 14, 4, 13, 14, 11, 13, 14,
264 7, 11, 13, 14, 11, 13, 14, 11, 13, 14,
265 9, 11, 14, 13, 14, 11, 14, 5, 13, 14,
266 12, 14, 1, 11, 8, 11, 9, 11, 10, 11,
267 9, 11, 11, 2, 11, 9, 11, 9, 11, 10,
271 static yyconst
short int yy_accept
[35] =
273 1, 1, 1, 2, 4, 6, 9, 12, 15, 18,
274 21, 25, 28, 31, 34, 36, 38, 41, 43, 44,
275 45, 46, 47, 49, 51, 53, 54, 54, 55, 56,
279 static yyconst
int yy_ec
[256] =
281 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
282 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
283 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
284 1, 2, 4, 4, 4, 4, 4, 4, 5, 6,
285 7, 8, 8, 9, 10, 11, 8, 12, 12, 12,
286 12, 12, 12, 12, 12, 12, 12, 4, 13, 8,
287 8, 8, 8, 14, 15, 15, 15, 15, 15, 15,
288 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
289 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
290 4, 4, 4, 4, 8, 16, 15, 15, 15, 15,
292 17, 15, 15, 15, 15, 15, 15, 15, 15, 15,
293 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
294 15, 15, 18, 4, 18, 4, 1, 1, 1, 1,
295 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
296 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
297 1, 1, 1, 1, 1, 1, 1, 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,
303 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
304 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
305 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,
311 static yyconst
int yy_meta
[19] =
313 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
314 2, 2, 1, 1, 2, 1, 2, 1
317 static yyconst
short int yy_base
[36] =
319 0, 0, 43, 44, 17, 44, 44, 44, 44, 0,
320 28, 10, 29, 12, 37, 0, 44, 44, 22, 0,
321 44, 27, 0, 14, 15, 26, 34, 44, 24, 0,
325 static yyconst
short int yy_def
[36] =
327 33, 1, 33, 33, 33, 33, 33, 33, 33, 34,
328 34, 34, 34, 12, 35, 34, 33, 33, 33, 34,
329 33, 34, 14, 34, 34, 34, 35, 33, 34, 25,
333 static yyconst
short int yy_nxt
[63] =
335 4, 5, 5, 6, 7, 8, 9, 10, 11, 12,
336 13, 14, 15, 4, 16, 17, 16, 18, 19, 19,
337 22, 23, 25, 19, 19, 24, 30, 20, 26, 32,
338 29, 26, 27, 27, 31, 32, 28, 31, 24, 28,
339 24, 21, 33, 3, 33, 33, 33, 33, 33, 33,
340 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
344 static yyconst
short int yy_chk
[63] =
346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
347 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
348 12, 12, 14, 19, 19, 24, 25, 34, 14, 32,
349 24, 25, 35, 35, 31, 29, 27, 26, 22, 15,
350 13, 11, 3, 33, 33, 33, 33, 33, 33, 33,
351 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
357 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
358 yy_cp = yy_full_match; /* restore poss. backed-over text */ \
362 #define yymore() yymore_used_but_not_detected
363 #define YY_MORE_ADJ 0
364 #define YY_RESTORE_YY_MORE_OFFSET
365 #line 1 "proto_syntax.flex"
367 /* a flex++ scanner for Proto
368 Copyright (C) 2005-2008, Jonathan Bachrach, Jacob Beal, and contributors
369 listed in the AUTHORS file in the MIT Proto distribution's top directory.
371 This file is part of MIT Proto, and is distributed under the terms of
372 the GNU General Public License, with a linking exception, as described
373 in the file LICENSE in the MIT Proto distribution's top directory.
375 Used: alphanumeric, *+-./<=>?_
377 Reserved: !"#$%&:[\]^{|}~
379 #line 22 "proto_syntax.flex"
380 #define YY_BREAK { if(error) return 1; } break;
385 //int yywrap() { return 1; }
387 class SExprLexer
: public yyFlexLexer
{
388 SE_List
* base
; // the implicit wrapping "all" for compilation
389 stack
<SE_List
*> enclosure
; // what SExprs enclose the current parse?
390 stack
<bool> wraps
; // are these SExprs normal or character macro wrappers?
392 string name
; // name of code source (e.g. file, "command-line")
394 void compile_error(Attribute
* context
,string msg
) {
395 *cperr
<< context
->to_str() << ": " << msg
<< endl
;
400 SExprLexer(string name
, istream
* in
=0, ostream
* out
=0) : yyFlexLexer(in
,out
) {
401 error
= false; this->name
=name
;
402 base
= new SE_List(); base
->add(new SE_Symbol("ALL"));
403 enclosure
.push(base
); wraps
.push(false);
406 virtual ~SExprLexer() {} // nothing to clean up: base becomes a problem of others
408 // returns NULL on error
411 if(enclosure
.top()!=base
) {
412 compile_error(enclosure
.top()->attributes
["CONTEXT"],"Missing right parenthesis");
414 if(error
) { delete base
; return NULL
;
415 } else if(base
->len()==2) { return base
->children
[1]; // single SEXpr
416 } else { return base
; }
420 Context
* context() { return new Context(name
,lineno()); }
422 // start a new sexpr, contained within the current context
423 void start_compound_sexpr() {
424 SE_List
*e
= new SE_List(); e
->attributes
["CONTEXT"]=context();
425 enclosure
.top()->add(e
);
426 enclosure
.push(e
); wraps
.push(false);
429 void end_compound_sexpr() {
430 if(wraps
.top() && enclosure
.top()->children
.size()<=1) {
431 compile_error(enclosure
.top()->attributes
["CONTEXT"],
432 "Wrapper macro " + enclosure
.top()->op()->to_str() +
433 " is not applied to anything");
434 } else if(enclosure
.top()==base
) {
435 compile_error(context(),"Too many right parentheses");
437 enclosure
.pop(); wraps
.pop();
438 if(wraps
.top()) { // if the next layer is a macro wrapper, finish it too
439 end_compound_sexpr();
444 // single character macros like ' create wrappers around the next SExpr
445 void wrap_next_sexpr(SE_Symbol
* symbol
) {
446 symbol
->attributes
["CONTEXT"]=context();
447 SE_List
* s
= new SE_List();
448 s
->add(symbol
); enclosure
.top()->add(s
);
449 enclosure
.push(s
); wraps
.push(true);
452 void add_sexpr(SExpr
* s
) {
453 s
->attributes
["CONTEXT"]=context();
454 enclosure
.top()->add(s
);
455 if(wraps
.top()) { end_compound_sexpr(); }
458 int yylex(); // prototype for lexing function
461 #line 462 "lexer.cpp"
463 /* Macros after this point can all be overridden by user definitions in
467 #ifndef YY_SKIP_YYWRAP
469 extern "C" int yywrap
YY_PROTO(( void ));
471 extern int yywrap
YY_PROTO(( void ));
477 static void yy_flex_strncpy
YY_PROTO(( char *, yyconst
char *, int ));
480 #ifdef YY_NEED_STRLEN
481 static int yy_flex_strlen
YY_PROTO(( yyconst
char * ));
488 static int yy_start_stack_ptr
= 0;
489 static int yy_start_stack_depth
= 0;
490 static int *yy_start_stack
= 0;
491 #ifndef YY_NO_PUSH_STATE
492 static void yy_push_state
YY_PROTO(( int new_state
));
494 #ifndef YY_NO_POP_STATE
495 static void yy_pop_state
YY_PROTO(( void ));
497 #ifndef YY_NO_TOP_STATE
498 static int yy_top_state
YY_PROTO(( void ));
502 #define YY_NO_PUSH_STATE 1
503 #define YY_NO_POP_STATE 1
504 #define YY_NO_TOP_STATE 1
507 #ifdef YY_MALLOC_DECL
515 /* Just try to get by without declaring the routines. This will fail
516 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
517 * or sizeof(void*) != sizeof(int).
522 /* Amount of stuff to slurp up with each read. */
523 #ifndef YY_READ_BUF_SIZE
524 #define YY_READ_BUF_SIZE 8192
527 /* Copy whatever the last rule matched to the standard output. */
530 #define ECHO LexerOutput( yytext, yyleng )
533 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
534 * is returned in "result".
537 #define YY_INPUT(buf,result,max_size) \
538 if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
539 YY_FATAL_ERROR( "input in flex scanner failed" );
542 /* No semi-colon after return; correct usage is to write "yyterminate();" -
543 * we don't want an extra ';' after the "return" because that will cause
544 * some compilers to complain about unreachable statements.
547 #define yyterminate() return YY_NULL
550 /* Number of entries by which start-condition stack grows. */
551 #ifndef YY_START_STACK_INCR
552 #define YY_START_STACK_INCR 25
555 /* Report a fatal error. */
556 #ifndef YY_FATAL_ERROR
557 #define YY_FATAL_ERROR(msg) LexerError( msg )
560 /* Default declaration of generated scanner - a define so the user can
561 * easily add parameters.
564 #define YY_DECL int yyFlexLexer::yylex()
567 /* Code executed at the beginning of each rule, after yytext and yyleng
570 #ifndef YY_USER_ACTION
571 #define YY_USER_ACTION
574 /* Code executed at the end of each rule. */
576 #define YY_BREAK break;
579 #define YY_RULE_SETUP \
584 register yy_state_type yy_current_state
;
585 register char *yy_cp
, *yy_bp
;
588 #line 106 "proto_syntax.flex"
591 #line 592 "lexer.cpp"
602 yy_start
= 1; /* first start state */
610 if ( ! yy_current_buffer
)
612 yy_create_buffer( yyin
, YY_BUF_SIZE
);
614 yy_load_buffer_state();
617 while ( 1 ) /* loops until end-of-file is reached */
621 /* Support of yytext. */
622 *yy_cp
= yy_hold_char
;
624 /* yy_bp points to the position in yy_ch_buf of the start of
629 yy_current_state
= yy_start
;
630 yy_state_ptr
= yy_state_buf
;
631 *yy_state_ptr
++ = yy_current_state
;
635 register YY_CHAR yy_c
= yy_ec
[YY_SC_TO_UI(*yy_cp
)];
636 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
638 yy_current_state
= (int) yy_def
[yy_current_state
];
639 if ( yy_current_state
>= 34 )
640 yy_c
= yy_meta
[(unsigned int) yy_c
];
642 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
643 *yy_state_ptr
++ = yy_current_state
;
646 while ( yy_base
[yy_current_state
] != 44 );
649 yy_current_state
= *--yy_state_ptr
;
650 yy_lp
= yy_accept
[yy_current_state
];
651 find_rule
: /* we branch to this label when backing up */
652 for ( ; ; ) /* until we find what rule we matched */
654 if ( yy_lp
&& yy_lp
< yy_accept
[yy_current_state
+ 1] )
656 yy_act
= yy_acclist
[yy_lp
];
658 yy_full_match
= yy_cp
;
663 yy_current_state
= *--yy_state_ptr
;
664 yy_lp
= yy_accept
[yy_current_state
];
669 if ( yy_act
!= YY_END_OF_BUFFER
)
672 for ( yyl
= 0; yyl
< yyleng
; ++yyl
)
673 if ( yytext
[yyl
] == '\n' )
677 do_action
: /* This label is used only to access EOF actions. */
681 { /* beginning of action switch */
684 #line 108 "proto_syntax.flex"
685 /* consume whitespace */
688 *yy_cp
= yy_hold_char
; /* undo effects of setting up yytext */
689 yy_c_buf_p
= yy_cp
-= 1;
690 YY_DO_BEFORE_ACTION
; /* set up yytext again */
692 #line 109 "proto_syntax.flex"
693 /* consume comments */
697 #line 111 "proto_syntax.flex"
698 start_compound_sexpr();
702 #line 112 "proto_syntax.flex"
703 end_compound_sexpr();
707 #line 114 "proto_syntax.flex"
708 wrap_next_sexpr(new SE_Symbol("QUASIQUOTE"));
712 #line 115 "proto_syntax.flex"
713 wrap_next_sexpr(new SE_Symbol("QUOTE"));
717 #line 116 "proto_syntax.flex"
718 wrap_next_sexpr(new SE_Symbol("COMMA"));
722 #line 117 "proto_syntax.flex"
723 wrap_next_sexpr(new SE_Symbol("COMMA-SPLICE"));
726 #line 120 "proto_syntax.flex"
729 #line 120 "proto_syntax.flex"
730 add_sexpr(new SE_Scalar(atof(YYText())));
734 #line 122 "proto_syntax.flex"
735 add_sexpr(new SE_Symbol(YYText()));
739 #line 124 "proto_syntax.flex"
740 compile_error(context(),"Illegal use of reserved character '"+string(YYText())+"'");
744 #line 125 "proto_syntax.flex"
745 compile_error(context(),"Unrecognized character: '"+string(YYText())+"'");
749 #line 127 "proto_syntax.flex"
752 #line 753 "lexer.cpp"
753 case YY_STATE_EOF(INITIAL
):
756 case YY_END_OF_BUFFER
:
758 /* Amount of text matched not including the EOB char. */
759 int yy_amount_of_matched_text
= (int) (yy_cp
- yytext_ptr
) - 1;
761 /* Undo the effects of YY_DO_BEFORE_ACTION. */
762 *yy_cp
= yy_hold_char
;
763 YY_RESTORE_YY_MORE_OFFSET
765 if ( yy_current_buffer
->yy_buffer_status
== YY_BUFFER_NEW
)
767 /* We're scanning a new file or input source. It's
768 * possible that this happened because the user
769 * just pointed yyin at a new source and called
770 * yylex(). If so, then we have to assure
771 * consistency between yy_current_buffer and our
772 * globals. Here is the right place to do so, because
773 * this is the first action (other than possibly a
774 * back-up) that will match for the new input source.
776 yy_n_chars
= yy_current_buffer
->yy_n_chars
;
777 yy_current_buffer
->yy_input_file
= yyin
;
778 yy_current_buffer
->yy_buffer_status
= YY_BUFFER_NORMAL
;
781 /* Note that here we test for yy_c_buf_p "<=" to the position
782 * of the first EOB in the buffer, since yy_c_buf_p will
783 * already have been incremented past the NUL character
784 * (since all states make transitions on EOB to the
785 * end-of-buffer state). Contrast this with the test
788 if ( yy_c_buf_p
<= &yy_current_buffer
->yy_ch_buf
[yy_n_chars
] )
789 { /* This was really a NUL. */
790 yy_state_type yy_next_state
;
792 yy_c_buf_p
= yytext_ptr
+ yy_amount_of_matched_text
;
794 yy_current_state
= yy_get_previous_state();
796 /* Okay, we're now positioned to make the NUL
797 * transition. We couldn't have
798 * yy_get_previous_state() go ahead and do it
799 * for us because it doesn't know how to deal
800 * with the possibility of jamming (and we don't
801 * want to build jamming into it because then it
802 * will run more slowly).
805 yy_next_state
= yy_try_NUL_trans( yy_current_state
);
807 yy_bp
= yytext_ptr
+ YY_MORE_ADJ
;
811 /* Consume the NUL. */
812 yy_cp
= ++yy_c_buf_p
;
813 yy_current_state
= yy_next_state
;
824 else switch ( yy_get_next_buffer() )
826 case EOB_ACT_END_OF_FILE
:
828 yy_did_buffer_switch_on_eof
= 0;
832 /* Note: because we've taken care in
833 * yy_get_next_buffer() to have set up
834 * yytext, we can now set up
835 * yy_c_buf_p so that if some total
836 * hoser (like flex itself) wants to
837 * call the scanner after we return the
838 * YY_NULL, it'll still work - another
839 * YY_NULL will get returned.
841 yy_c_buf_p
= yytext_ptr
+ YY_MORE_ADJ
;
843 yy_act
= YY_STATE_EOF(YY_START
);
849 if ( ! yy_did_buffer_switch_on_eof
)
855 case EOB_ACT_CONTINUE_SCAN
:
857 yytext_ptr
+ yy_amount_of_matched_text
;
859 yy_current_state
= yy_get_previous_state();
862 yy_bp
= yytext_ptr
+ YY_MORE_ADJ
;
865 case EOB_ACT_LAST_MATCH
:
867 &yy_current_buffer
->yy_ch_buf
[yy_n_chars
];
869 yy_current_state
= yy_get_previous_state();
872 yy_bp
= yytext_ptr
+ YY_MORE_ADJ
;
880 "fatal flex scanner internal error--no action found" );
881 } /* end of action switch */
882 } /* end of scanning one token */
885 yyFlexLexer::yyFlexLexer( istream
* arg_yyin
, ostream
* arg_yyout
)
893 yylineno
= 1; // this will only get updated if %option yylineno
895 yy_did_buffer_switch_on_eof
= 0;
897 yy_looking_for_trail_begin
= 0;
900 yy_more_offset
= yy_prev_more_offset
= 0;
902 yy_start_stack_ptr
= yy_start_stack_depth
= 0;
905 yy_current_buffer
= 0;
907 #ifdef YY_USES_REJECT
908 yy_state_buf
= new yy_state_type
[YY_BUF_SIZE
+ 2];
914 yyFlexLexer::~yyFlexLexer()
917 yy_delete_buffer( yy_current_buffer
);
920 void yyFlexLexer::switch_streams( istream
* new_in
, ostream
* new_out
)
924 yy_delete_buffer( yy_current_buffer
);
925 yy_switch_to_buffer( yy_create_buffer( new_in
, YY_BUF_SIZE
) );
932 #ifdef YY_INTERACTIVE
933 int yyFlexLexer::LexerInput( char* buf
, int /* max_size */ )
935 int yyFlexLexer::LexerInput( char* buf
, int max_size
)
938 if ( yyin
->eof() || yyin
->fail() )
941 #ifdef YY_INTERACTIVE
953 (void) yyin
->read( buf
, max_size
);
958 return yyin
->gcount();
962 void yyFlexLexer::LexerOutput( const char* buf
, int size
)
964 (void) yyout
->write( buf
, size
);
967 /* yy_get_next_buffer - try to read in a new buffer
969 * Returns a code representing an action:
970 * EOB_ACT_LAST_MATCH -
971 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
972 * EOB_ACT_END_OF_FILE - end of file
975 int yyFlexLexer::yy_get_next_buffer()
977 register char *dest
= yy_current_buffer
->yy_ch_buf
;
978 register char *source
= yytext_ptr
;
979 register int number_to_move
, i
;
982 if ( yy_c_buf_p
> &yy_current_buffer
->yy_ch_buf
[yy_n_chars
+ 1] )
984 "fatal flex scanner internal error--end of buffer missed" );
986 if ( yy_current_buffer
->yy_fill_buffer
== 0 )
987 { /* Don't try to fill the buffer, so this is an EOF. */
988 if ( yy_c_buf_p
- yytext_ptr
- YY_MORE_ADJ
== 1 )
990 /* We matched a single character, the EOB, so
991 * treat this as a final EOF.
993 return EOB_ACT_END_OF_FILE
;
998 /* We matched some text prior to the EOB, first
1001 return EOB_ACT_LAST_MATCH
;
1005 /* Try to read more data. */
1007 /* First move last chars to start of buffer. */
1008 number_to_move
= (int) (yy_c_buf_p
- yytext_ptr
) - 1;
1010 for ( i
= 0; i
< number_to_move
; ++i
)
1011 *(dest
++) = *(source
++);
1013 if ( yy_current_buffer
->yy_buffer_status
== YY_BUFFER_EOF_PENDING
)
1014 /* don't do the read, it's not guaranteed to return an EOF,
1017 yy_current_buffer
->yy_n_chars
= yy_n_chars
= 0;
1022 yy_current_buffer
->yy_buf_size
- number_to_move
- 1;
1024 while ( num_to_read
<= 0 )
1025 { /* Not enough room in the buffer - grow it. */
1026 #ifdef YY_USES_REJECT
1028 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1031 /* just a shorter name for the current buffer */
1032 YY_BUFFER_STATE b
= yy_current_buffer
;
1034 int yy_c_buf_p_offset
=
1035 (int) (yy_c_buf_p
- b
->yy_ch_buf
);
1037 if ( b
->yy_is_our_buffer
)
1039 int new_size
= b
->yy_buf_size
* 2;
1041 if ( new_size
<= 0 )
1042 b
->yy_buf_size
+= b
->yy_buf_size
/ 8;
1044 b
->yy_buf_size
*= 2;
1046 b
->yy_ch_buf
= (char *)
1047 /* Include room in for 2 EOB chars. */
1048 yy_flex_realloc( (void *) b
->yy_ch_buf
,
1049 b
->yy_buf_size
+ 2 );
1052 /* Can't grow it, we don't own it. */
1055 if ( ! b
->yy_ch_buf
)
1057 "fatal error - scanner input buffer overflow" );
1059 yy_c_buf_p
= &b
->yy_ch_buf
[yy_c_buf_p_offset
];
1061 num_to_read
= yy_current_buffer
->yy_buf_size
-
1066 if ( num_to_read
> YY_READ_BUF_SIZE
)
1067 num_to_read
= YY_READ_BUF_SIZE
;
1069 /* Read in more data. */
1070 YY_INPUT( (&yy_current_buffer
->yy_ch_buf
[number_to_move
]),
1071 yy_n_chars
, num_to_read
);
1073 yy_current_buffer
->yy_n_chars
= yy_n_chars
;
1076 if ( yy_n_chars
== 0 )
1078 if ( number_to_move
== YY_MORE_ADJ
)
1080 ret_val
= EOB_ACT_END_OF_FILE
;
1086 ret_val
= EOB_ACT_LAST_MATCH
;
1087 yy_current_buffer
->yy_buffer_status
=
1088 YY_BUFFER_EOF_PENDING
;
1093 ret_val
= EOB_ACT_CONTINUE_SCAN
;
1095 yy_n_chars
+= number_to_move
;
1096 yy_current_buffer
->yy_ch_buf
[yy_n_chars
] = YY_END_OF_BUFFER_CHAR
;
1097 yy_current_buffer
->yy_ch_buf
[yy_n_chars
+ 1] = YY_END_OF_BUFFER_CHAR
;
1099 yytext_ptr
= &yy_current_buffer
->yy_ch_buf
[0];
1105 /* yy_get_previous_state - get the state just before the EOB char was reached */
1107 yy_state_type
yyFlexLexer::yy_get_previous_state()
1109 register yy_state_type yy_current_state
;
1110 register char *yy_cp
;
1112 yy_current_state
= yy_start
;
1113 yy_state_ptr
= yy_state_buf
;
1114 *yy_state_ptr
++ = yy_current_state
;
1116 for ( yy_cp
= yytext_ptr
+ YY_MORE_ADJ
; yy_cp
< yy_c_buf_p
; ++yy_cp
)
1118 register YY_CHAR yy_c
= (*yy_cp
? yy_ec
[YY_SC_TO_UI(*yy_cp
)] : 1);
1119 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1121 yy_current_state
= (int) yy_def
[yy_current_state
];
1122 if ( yy_current_state
>= 34 )
1123 yy_c
= yy_meta
[(unsigned int) yy_c
];
1125 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1126 *yy_state_ptr
++ = yy_current_state
;
1129 return yy_current_state
;
1133 /* yy_try_NUL_trans - try to make a transition on the NUL character
1136 * next_state = yy_try_NUL_trans( current_state );
1139 yy_state_type
yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state
)
1141 register int yy_is_jam
;
1143 register YY_CHAR yy_c
= 1;
1144 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1146 yy_current_state
= (int) yy_def
[yy_current_state
];
1147 if ( yy_current_state
>= 34 )
1148 yy_c
= yy_meta
[(unsigned int) yy_c
];
1150 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1151 yy_is_jam
= (yy_current_state
== 33);
1153 *yy_state_ptr
++ = yy_current_state
;
1155 return yy_is_jam
? 0 : yy_current_state
;
1159 void yyFlexLexer::yyunput( int c
, register char* yy_bp
)
1161 register char *yy_cp
= yy_c_buf_p
;
1163 /* undo effects of setting up yytext */
1164 *yy_cp
= yy_hold_char
;
1166 if ( yy_cp
< yy_current_buffer
->yy_ch_buf
+ 2 )
1167 { /* need to shift things up to make room */
1168 /* +2 for EOB chars. */
1169 register int number_to_move
= yy_n_chars
+ 2;
1170 register char *dest
= &yy_current_buffer
->yy_ch_buf
[
1171 yy_current_buffer
->yy_buf_size
+ 2];
1172 register char *source
=
1173 &yy_current_buffer
->yy_ch_buf
[number_to_move
];
1175 while ( source
> yy_current_buffer
->yy_ch_buf
)
1176 *--dest
= *--source
;
1178 yy_cp
+= (int) (dest
- source
);
1179 yy_bp
+= (int) (dest
- source
);
1180 yy_current_buffer
->yy_n_chars
=
1181 yy_n_chars
= yy_current_buffer
->yy_buf_size
;
1183 if ( yy_cp
< yy_current_buffer
->yy_ch_buf
+ 2 )
1184 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1187 *--yy_cp
= (char) c
;
1193 yy_hold_char
= *yy_cp
;
1198 int yyFlexLexer::yyinput()
1202 *yy_c_buf_p
= yy_hold_char
;
1204 if ( *yy_c_buf_p
== YY_END_OF_BUFFER_CHAR
)
1206 /* yy_c_buf_p now points to the character we want to return.
1207 * If this occurs *before* the EOB characters, then it's a
1208 * valid NUL; if not, then we've hit the end of the buffer.
1210 if ( yy_c_buf_p
< &yy_current_buffer
->yy_ch_buf
[yy_n_chars
] )
1211 /* This was really a NUL. */
1215 { /* need more input */
1216 int offset
= yy_c_buf_p
- yytext_ptr
;
1219 switch ( yy_get_next_buffer() )
1221 case EOB_ACT_LAST_MATCH
:
1222 /* This happens because yy_g_n_b()
1223 * sees that we've accumulated a
1224 * token and flags that we need to
1225 * try matching the token before
1226 * proceeding. But for input(),
1227 * there's no matching to consider.
1228 * So convert the EOB_ACT_LAST_MATCH
1229 * to EOB_ACT_END_OF_FILE.
1232 /* Reset buffer status. */
1237 case EOB_ACT_END_OF_FILE
:
1242 if ( ! yy_did_buffer_switch_on_eof
)
1251 case EOB_ACT_CONTINUE_SCAN
:
1252 yy_c_buf_p
= yytext_ptr
+ offset
;
1258 c
= *(unsigned char *) yy_c_buf_p
; /* cast for 8-bit char's */
1259 *yy_c_buf_p
= '\0'; /* preserve yytext */
1260 yy_hold_char
= *++yy_c_buf_p
;
1269 void yyFlexLexer::yyrestart( istream
* input_file
)
1271 if ( ! yy_current_buffer
)
1272 yy_current_buffer
= yy_create_buffer( yyin
, YY_BUF_SIZE
);
1274 yy_init_buffer( yy_current_buffer
, input_file
);
1275 yy_load_buffer_state();
1279 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer
)
1281 if ( yy_current_buffer
== new_buffer
)
1284 if ( yy_current_buffer
)
1286 /* Flush out information for old buffer. */
1287 *yy_c_buf_p
= yy_hold_char
;
1288 yy_current_buffer
->yy_buf_pos
= yy_c_buf_p
;
1289 yy_current_buffer
->yy_n_chars
= yy_n_chars
;
1292 yy_current_buffer
= new_buffer
;
1293 yy_load_buffer_state();
1295 /* We don't actually know whether we did this switch during
1296 * EOF (yywrap()) processing, but the only time this flag
1297 * is looked at is after yywrap() is called, so it's safe
1298 * to go ahead and always set it.
1300 yy_did_buffer_switch_on_eof
= 1;
1304 void yyFlexLexer::yy_load_buffer_state()
1306 yy_n_chars
= yy_current_buffer
->yy_n_chars
;
1307 yytext_ptr
= yy_c_buf_p
= yy_current_buffer
->yy_buf_pos
;
1308 yyin
= yy_current_buffer
->yy_input_file
;
1309 yy_hold_char
= *yy_c_buf_p
;
1313 YY_BUFFER_STATE
yyFlexLexer::yy_create_buffer( istream
* file
, int size
)
1317 b
= (YY_BUFFER_STATE
) yy_flex_alloc( sizeof( struct yy_buffer_state
) );
1319 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1321 b
->yy_buf_size
= size
;
1323 /* yy_ch_buf has to be 2 characters longer than the size given because
1324 * we need to put in 2 end-of-buffer characters.
1326 b
->yy_ch_buf
= (char *) yy_flex_alloc( b
->yy_buf_size
+ 2 );
1327 if ( ! b
->yy_ch_buf
)
1328 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1330 b
->yy_is_our_buffer
= 1;
1332 yy_init_buffer( b
, file
);
1338 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b
)
1343 if ( b
== yy_current_buffer
)
1344 yy_current_buffer
= (YY_BUFFER_STATE
) 0;
1346 if ( b
->yy_is_our_buffer
)
1347 yy_flex_free( (void *) b
->yy_ch_buf
);
1349 yy_flex_free( (void *) b
);
1353 extern "C" int isatty
YY_PROTO(( int ));
1354 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b
, istream
* file
)
1357 yy_flush_buffer( b
);
1359 b
->yy_input_file
= file
;
1360 b
->yy_fill_buffer
= 1;
1362 b
->yy_is_interactive
= 0;
1366 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b
)
1373 /* We always need two end-of-buffer characters. The first causes
1374 * a transition to the end-of-buffer state. The second causes
1375 * a jam in that state.
1377 b
->yy_ch_buf
[0] = YY_END_OF_BUFFER_CHAR
;
1378 b
->yy_ch_buf
[1] = YY_END_OF_BUFFER_CHAR
;
1380 b
->yy_buf_pos
= &b
->yy_ch_buf
[0];
1383 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1385 if ( b
== yy_current_buffer
)
1386 yy_load_buffer_state();
1390 #ifndef YY_NO_SCAN_BUFFER
1394 #ifndef YY_NO_SCAN_STRING
1398 #ifndef YY_NO_SCAN_BYTES
1402 #ifndef YY_NO_PUSH_STATE
1403 void yyFlexLexer::yy_push_state( int new_state
)
1405 if ( yy_start_stack_ptr
>= yy_start_stack_depth
)
1409 yy_start_stack_depth
+= YY_START_STACK_INCR
;
1410 new_size
= yy_start_stack_depth
* sizeof( int );
1412 if ( ! yy_start_stack
)
1413 yy_start_stack
= (int *) yy_flex_alloc( new_size
);
1416 yy_start_stack
= (int *) yy_flex_realloc(
1417 (void *) yy_start_stack
, new_size
);
1419 if ( ! yy_start_stack
)
1421 "out of memory expanding start-condition stack" );
1424 yy_start_stack
[yy_start_stack_ptr
++] = YY_START
;
1431 #ifndef YY_NO_POP_STATE
1432 void yyFlexLexer::yy_pop_state()
1434 if ( --yy_start_stack_ptr
< 0 )
1435 YY_FATAL_ERROR( "start-condition stack underflow" );
1437 BEGIN(yy_start_stack
[yy_start_stack_ptr
]);
1442 #ifndef YY_NO_TOP_STATE
1443 int yyFlexLexer::yy_top_state()
1445 return yy_start_stack
[yy_start_stack_ptr
- 1];
1449 #ifndef YY_EXIT_FAILURE
1450 #define YY_EXIT_FAILURE 2
1454 void yyFlexLexer::LexerError( yyconst
char msg
[] )
1456 cerr
<< msg
<< '\n';
1457 exit( YY_EXIT_FAILURE
);
1461 /* Redefine yyless() so it works in section 3 code. */
1467 /* Undo effects of setting up yytext. */ \
1468 yytext[yyleng] = yy_hold_char; \
1469 yy_c_buf_p = yytext + n; \
1470 yy_hold_char = *yy_c_buf_p; \
1471 *yy_c_buf_p = '\0'; \
1477 /* Internal utility routines. */
1480 #ifdef YY_USE_PROTOS
1481 static void yy_flex_strncpy( char *s1
, yyconst
char *s2
, int n
)
1483 static void yy_flex_strncpy( s1
, s2
, n
)
1490 for ( i
= 0; i
< n
; ++i
)
1495 #ifdef YY_NEED_STRLEN
1496 #ifdef YY_USE_PROTOS
1497 static int yy_flex_strlen( yyconst
char *s
)
1499 static int yy_flex_strlen( s
)
1504 for ( n
= 0; s
[n
]; ++n
)
1512 #ifdef YY_USE_PROTOS
1513 static void *yy_flex_alloc( yy_size_t size
)
1515 static void *yy_flex_alloc( size
)
1519 return (void *) malloc( size
);
1522 #ifdef YY_USE_PROTOS
1523 static void *yy_flex_realloc( void *ptr
, yy_size_t size
)
1525 static void *yy_flex_realloc( ptr
, size
)
1530 /* The cast to (char *) in the following accommodates both
1531 * implementations that use char* generic pointers, and those
1532 * that use void* generic pointers. It works with the latter
1533 * because both ANSI C and C++ allow castless assignment from
1534 * any pointer type to void*, and deal with argument conversions
1535 * as though doing an assignment.
1537 return (void *) realloc( (char *) ptr
, size
);
1540 #ifdef YY_USE_PROTOS
1541 static void yy_flex_free( void *ptr
)
1543 static void yy_flex_free( ptr
)
1557 #line 127 "proto_syntax.flex"
1560 SExpr
* read_sexpr(string name
, string in
)
1561 { return read_sexpr(name
,new istringstream(in
)); }
1562 SExpr
* read_sexpr(string name
, istream
* in
, ostream
* out
)
1563 { SExprLexer
lex(name
,in
,out
); return lex
.tokenize(); }