/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
*/
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif
#ifdef __cplusplus
#include <stdlib.h>
#include <unistd.h>
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
#if __STDC__
#define YY_USE_PROTOS
#define YY_USE_CONST
#endif /* __STDC__ */
#endif /* ! __cplusplus */
#ifdef __TURBOC__
#pragma warn -rch
#pragma warn -use
#include <io.h>
#include <stdlib.h>
#define YY_USE_CONST
#define YY_USE_PROTOS
#endif
#ifdef YY_USE_CONST
#define amd_yyconst const
#else
#define amd_yyconst
#endif
#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN amd_yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((amd_yy_start - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE amd_yyrestart( amd_yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#define YY_BUF_SIZE 16384
typedef struct amd_yy_buffer_state *YY_BUFFER_STATE;
extern int amd_yyleng;
extern FILE *amd_yyin, *amd_yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
/* The funky do-while in the following #define is used to turn the definition
* int a single C statement (which needs a semi-colon terminator). This
* avoids problems with code like:
*
* if ( condition_holds )
* amd_yyless( 5 );
* else
* do_something_else();
*
* Prior to using the do-while the compiler would get upset at the
* "else" because it interpreted the "if" statement as being all
* done when it reached the ';' after the amd_yyless() call.
*/
/* Return all but the first 'n' matched characters back to the input stream. */
#define amd_yyless(n) \
do \
{ \
/* Undo effects of setting up amd_yytext. */ \
*amd_yy_cp = amd_yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \
amd_yy_c_buf_p = amd_yy_cp = amd_yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up amd_yytext again */ \
} \
while ( 0 )
#define unput(c) amd_yyunput( c, amd_yytext_ptr )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
*/
typedef unsigned int amd_yy_size_t;
struct amd_yy_buffer_state
{
FILE *amd_yy_input_file;
char *amd_yy_ch_buf; /* input buffer */
char *amd_yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
amd_yy_size_t amd_yy_buf_size;
/* Number of characters read into amd_yy_ch_buf, not including EOB
* characters.
*/
int amd_yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int amd_yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int amd_yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int amd_yy_at_bol;
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int amd_yy_fill_buffer;
int amd_yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via amd_yyrestart()), so that the user can continue scanning by
* just pointing amd_yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
static YY_BUFFER_STATE amd_yy_current_buffer = 0;
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*/
#define YY_CURRENT_BUFFER amd_yy_current_buffer
/* amd_yy_hold_char holds the character lost when amd_yytext is formed. */
static char amd_yy_hold_char;
static int amd_yy_n_chars; /* number of characters read into amd_yy_ch_buf */
int amd_yyleng;
/* Points to current character in buffer. */
static char *amd_yy_c_buf_p = (char *) 0;
static int amd_yy_init = 1; /* whether we need to initialize */
static int amd_yy_start = 0; /* start state number */
/* Flag which is used to allow amd_yywrap()'s to do buffer switches
* instead of setting up a fresh amd_yyin. A bit of a hack ...
*/
static int amd_yy_did_buffer_switch_on_eof;
void amd_yyrestart YY_PROTO(( FILE *input_file ));
void amd_yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
void amd_yy_load_buffer_state YY_PROTO(( void ));
YY_BUFFER_STATE amd_yy_create_buffer YY_PROTO(( FILE *file, int size ));
void amd_yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
void amd_yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
void amd_yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
#define YY_FLUSH_BUFFER amd_yy_flush_buffer( amd_yy_current_buffer )
YY_BUFFER_STATE amd_yy_scan_buffer YY_PROTO(( char *base, amd_yy_size_t size ));
YY_BUFFER_STATE amd_yy_scan_string YY_PROTO(( amd_yyconst char *amd_yy_str ));
YY_BUFFER_STATE amd_yy_scan_bytes YY_PROTO(( amd_yyconst char *bytes, int len ));
static void *amd_yy_flex_alloc YY_PROTO(( amd_yy_size_t ));
static void *amd_yy_flex_realloc YY_PROTO(( void *, amd_yy_size_t ));
static void amd_yy_flex_free YY_PROTO(( void * ));
#define amd_yy_new_buffer amd_yy_create_buffer
#define amd_yy_set_interactive(is_interactive) \
{ \
if ( ! amd_yy_current_buffer ) \
amd_yy_current_buffer = amd_yy_create_buffer( amd_yyin, YY_BUF_SIZE ); \
amd_yy_current_buffer->amd_yy_is_interactive = is_interactive; \
}
#define amd_yy_set_bol(at_bol) \
{ \
if ( ! amd_yy_current_buffer ) \
amd_yy_current_buffer = amd_yy_create_buffer( amd_yyin, YY_BUF_SIZE ); \
amd_yy_current_buffer->amd_yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (amd_yy_current_buffer->amd_yy_at_bol)
#define amd_yywrap() 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
FILE *amd_yyin = (FILE *) 0, *amd_yyout = (FILE *) 0;
typedef int amd_yy_state_type;
extern char *amd_yytext;
#define amd_yytext_ptr amd_yytext
static amd_yy_state_type amd_yy_get_previous_state YY_PROTO(( void ));
static amd_yy_state_type amd_yy_try_NUL_trans YY_PROTO(( amd_yy_state_type current_state ));
static int amd_yy_get_next_buffer YY_PROTO(( void ));
static void amd_yy_fatal_error YY_PROTO(( amd_yyconst char msg[] ));
/* Done after the current pattern has been matched and before the
* corresponding action - sets up amd_yytext.
*/
#define YY_DO_BEFORE_ACTION \
amd_yytext_ptr = amd_yy_bp; \
amd_yyleng = (int) (amd_yy_cp - amd_yy_bp); \
amd_yy_hold_char = *amd_yy_cp; \
*amd_yy_cp = '\0'; \
amd_yy_c_buf_p = amd_yy_cp;
#define YY_NUM_RULES 69
#define YY_END_OF_BUFFER 70
static amd_yyconst short int amd_yy_accept[134] =
{ 0,
0, 0, 0, 0, 0, 0, 12, 12, 0, 0,
0, 0, 0, 0, 70, 68, 32, 33, 33, 32,
65, 10, 65, 65, 65, 65, 67, 65, 65, 65,
65, 65, 65, 27, 27, 65, 65, 65, 65, 30,
66, 65, 65, 65, 65, 4, 1, 2, 2, 1,
4, 3, 12, 12, 11, 69, 8, 7, 5, 5,
7, 8, 9, 69, 32, 33, 46, 29, 40, 50,
41, 59, 55, 57, 39, 51, 36, 52, 37, 62,
63, 44, 38, 27, 31, 31, 60, 61, 54, 47,
45, 48, 53, 30, 56, 43, 42, 49, 58, 1,
2, 12, 26, 23, 13, 13, 25, 22, 19, 21,
16, 20, 17, 18, 26, 8, 7, 5, 6, 6,
35, 64, 28, 34, 13, 25, 13, 24, 15, 14,
24, 15, 0
} ;
static amd_yyconst int amd_yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 22,
22, 23, 23, 23, 23, 24, 24, 25, 17, 26,
27, 28, 29, 30, 31, 31, 31, 31, 31, 31,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
33, 34, 35, 36, 32, 30, 37, 38, 31, 31,
31, 39, 32, 32, 32, 32, 32, 32, 32, 40,
32, 32, 32, 41, 32, 42, 32, 43, 32, 44,
32, 32, 45, 46, 47, 17, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
static amd_yyconst int amd_yy_meta[48] =
{ 0,
1, 1, 2, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 1, 1, 1, 1, 1, 1,
4, 5, 1, 6, 1, 1, 4, 4, 4, 5,
5, 5, 5, 5, 1, 1, 1
} ;
static amd_yyconst short int amd_yy_base[146] =
{ 0,
0, 0, 0, 0, 47, 55, 63, 70, 77, 82,
87, 91, 97, 104, 210, 296, 107, 296, 206, 108,
179, 296, 296, 96, 178, 42, 296, 89, 177, 99,
103, 35, 176, 114, 118, 118, 49, 175, 75, 0,
296, 187, 161, 98, 173, 296, 122, 296, 182, 143,
296, 296, 0, 0, 296, 152, 0, 144, 296, 154,
145, 0, 125, 296, 149, 296, 296, 139, 296, 106,
296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
104, 296, 296, 0, 0, 176, 296, 296, 296, 296,
296, 296, 296, 0, 296, 296, 296, 69, 296, 150,
296, 0, 296, 296, 144, 148, 156, 296, 296, 296,
296, 296, 296, 296, 200, 0, 151, 296, 296, 65,
296, 296, 0, 296, 161, 296, 296, 0, 0, 296,
296, 296, 296, 239, 245, 251, 257, 260, 262, 267,
272, 278, 283, 289, 57
} ;
static amd_yyconst short int amd_yy_def[146] =
{ 0,
133, 1, 1, 1, 134, 134, 135, 135, 136, 136,
137, 137, 137, 137, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 138, 138, 133, 133, 133, 133, 139,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 140, 140, 133, 141, 142, 142, 133, 142,
142, 142, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 35, 138, 133, 133, 133, 133, 133,
133, 133, 133, 139, 133, 133, 133, 133, 133, 133,
133, 140, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 143, 142, 142, 133, 133, 133,
133, 133, 86, 133, 133, 133, 133, 144, 145, 133,
133, 133, 0, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133
} ;
static amd_yyconst short int amd_yy_nxt[344] =
{ 0,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 23, 29, 30, 23, 31, 32, 33,
34, 35, 35, 35, 36, 37, 38, 39, 23, 27,
40, 40, 23, 41, 42, 43, 40, 40, 40, 40,
40, 40, 40, 40, 23, 44, 45, 46, 47, 48,
49, 50, 70, 81, 52, 46, 47, 48, 49, 50,
132, 82, 52, 53, 53, 53, 53, 119, 71, 55,
53, 53, 53, 53, 89, 90, 55, 57, 58, 59,
60, 61, 57, 58, 59, 60, 61, 16, 16, 16,
16, 16, 16, 16, 16, 124, 56, 16, 16, 16,
16, 92, 93, 56, 16, 16, 16, 16, 65, 65,
63, 65, 65, 72, 76, 63, 68, 68, 68, 68,
78, 73, 122, 100, 97, 77, 100, 119, 120, 79,
80, 87, 121, 74, 84, 84, 84, 84, 84, 84,
84, 84, 88, 98, 100, 117, 117, 100, 117, 117,
65, 100, 117, 65, 100, 117, 118, 86, 104, 68,
68, 68, 68, 104, 125, 125, 125, 126, 127, 127,
127, 126, 105, 105, 106, 107, 126, 126, 126, 126,
104, 130, 130, 130, 101, 104, 99, 96, 108, 109,
110, 111, 112, 113, 114, 115, 123, 123, 123, 123,
95, 91, 83, 75, 69, 67, 123, 85, 66, 133,
133, 133, 123, 123, 123, 85, 85, 85, 85, 85,
129, 129, 129, 129, 133, 133, 133, 133, 133, 133,
129, 133, 133, 133, 133, 133, 129, 129, 129, 51,
51, 51, 51, 51, 51, 54, 54, 54, 54, 54,
54, 62, 62, 62, 62, 62, 62, 64, 64, 64,
64, 64, 64, 85, 85, 94, 94, 102, 102, 133,
102, 102, 103, 103, 103, 103, 103, 103, 116, 133,
116, 116, 116, 128, 128, 128, 128, 128, 128, 131,
131, 131, 133, 131, 131, 15, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133
} ;
static amd_yyconst short int amd_yy_chk[344] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 5, 5, 5,
5, 5, 26, 32, 5, 6, 6, 6, 6, 6,
145, 32, 6, 7, 7, 7, 7, 120, 26, 7,
8, 8, 8, 8, 37, 37, 8, 9, 9, 9,
9, 9, 10, 10, 10, 10, 10, 11, 11, 11,
11, 12, 12, 12, 12, 98, 7, 13, 13, 13,
13, 39, 39, 8, 14, 14, 14, 14, 17, 20,
9, 17, 20, 28, 30, 10, 24, 24, 24, 24,
31, 28, 81, 47, 44, 30, 47, 63, 63, 31,
31, 36, 70, 28, 34, 34, 34, 34, 35, 35,
35, 35, 36, 44, 50, 58, 61, 50, 58, 61,
65, 100, 117, 65, 100, 117, 60, 34, 56, 68,
68, 68, 68, 56, 105, 105, 105, 105, 106, 106,
106, 106, 56, 56, 56, 56, 107, 107, 107, 107,
56, 125, 125, 125, 49, 56, 45, 43, 56, 56,
56, 56, 56, 56, 56, 56, 86, 86, 86, 86,
42, 38, 33, 29, 25, 21, 86, 86, 19, 15,
0, 0, 86, 86, 86, 86, 86, 86, 86, 86,
115, 115, 115, 115, 0, 0, 0, 0, 0, 0,
115, 0, 0, 0, 0, 0, 115, 115, 115, 134,
134, 134, 134, 134, 134, 135, 135, 135, 135, 135,
135, 136, 136, 136, 136, 136, 136, 137, 137, 137,
137, 137, 137, 138, 138, 139, 139, 140, 140, 0,
140, 140, 141, 141, 141, 141, 141, 141, 142, 0,
142, 142, 142, 143, 143, 143, 143, 143, 143, 144,
144, 144, 0, 144, 144, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
133, 133, 133
} ;
static amd_yy_state_type amd_yy_last_accepting_state;
static char *amd_yy_last_accepting_cpos;
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
#define REJECT reject_used_but_not_detected
#define amd_yymore() amd_yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *amd_yytext;
#line 1 "lexer.yy"
#define INITIAL 0
#line 2 "lexer.yy"
#include <stdio.h>
#include <stdlib.h>
#include "compiler.h"
#include "parser.h"
#define YY_DECL int amd_yylex(AMD_YYSTYPE *amd_yylval, amd_parse_param_t *param)
static int amd_yyinteger(AMD_YYSTYPE *lvalp);
static int amd_yyidentifier(AMD_YYSTYPE *lvalp, amd_parse_param_t *param);
#define YY_NO_INPUT 1
#define YY_NO_UNPUT 1
#define YY_NO_TOP_STATE 1
/* %option debug */
#define CODE 1
#define BLANK 2
#define STRING 3
#define PPLINE 4
#define CCOMMENT 5
#define CPPCOMMENT 6
#line 514 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int amd_yywrap YY_PROTO(( void ));
#else
extern int amd_yywrap YY_PROTO(( void ));
#endif
#endif
#ifndef YY_NO_UNPUT
static void amd_yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif
#ifndef amd_yytext_ptr
static void amd_yy_flex_strncpy YY_PROTO(( char *, amd_yyconst char *, int ));
#endif
#ifdef YY_NEED_STRLEN
static int amd_yy_flex_strlen YY_PROTO(( amd_yyconst char * ));
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int amd_yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
#endif
#if YY_STACK_USED
static int amd_yy_start_stack_ptr = 0;
static int amd_yy_start_stack_depth = 0;
static int *amd_yy_start_stack = 0;
#ifndef YY_NO_PUSH_STATE
static void amd_yy_push_state YY_PROTO(( int new_state ));
#endif
#ifndef YY_NO_POP_STATE
static void amd_yy_pop_state YY_PROTO(( void ));
#endif
#ifndef YY_NO_TOP_STATE
static int amd_yy_top_state YY_PROTO(( void ));
#endif
#else
#define YY_NO_PUSH_STATE 1
#define YY_NO_POP_STATE 1
#define YY_NO_TOP_STATE 1
#endif
#ifdef YY_MALLOC_DECL
YY_MALLOC_DECL
#else
#if __STDC__
#ifndef __cplusplus
#include <stdlib.h>
#endif
#else
/* Just try to get by without declaring the routines. This will fail
* miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
* or sizeof(void*) != sizeof(int).
*/
#endif
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO (void) fwrite( amd_yytext, amd_yyleng, 1, amd_yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if ( amd_yy_current_buffer->amd_yy_is_interactive ) \
{ \
int c = '*', n; \
for ( n = 0; n < max_size && \
(c = getc( amd_yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( amd_yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else if ( ((result = fread( buf, 1, max_size, amd_yyin )) == 0) \
&& ferror( amd_yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" );
#endif
/* No semi-colon after return; correct usage is to write "amd_yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#ifndef amd_yyterminate
#define amd_yyterminate() return YY_NULL
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) amd_yy_fatal_error( msg )
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL int amd_yylex YY_PROTO(( void ))
#endif
/* Code executed at the beginning of each rule, after amd_yytext and amd_yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif
#define YY_RULE_SETUP \
YY_USER_ACTION
YY_DECL
{
register amd_yy_state_type amd_yy_current_state;
register char *amd_yy_cp, *amd_yy_bp;
register int amd_yy_act;
#line 48 "lexer.yy"
#line 668 "lex.yy.c"
if ( amd_yy_init )
{
amd_yy_init = 0;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! amd_yy_start )
amd_yy_start = 1; /* first start state */
if ( ! amd_yyin )
amd_yyin = stdin;
if ( ! amd_yyout )
amd_yyout = stdout;
if ( ! amd_yy_current_buffer )
amd_yy_current_buffer =
amd_yy_create_buffer( amd_yyin, YY_BUF_SIZE );
amd_yy_load_buffer_state();
}
while ( 1 ) /* loops until end-of-file is reached */
{
amd_yy_cp = amd_yy_c_buf_p;
/* Support of amd_yytext. */
*amd_yy_cp = amd_yy_hold_char;
/* amd_yy_bp points to the position in amd_yy_ch_buf of the start of
* the current run.
*/
amd_yy_bp = amd_yy_cp;
amd_yy_current_state = amd_yy_start;
amd_yy_match:
do
{
register YY_CHAR amd_yy_c = amd_yy_ec[YY_SC_TO_UI(*amd_yy_cp)];
if ( amd_yy_accept[amd_yy_current_state] )
{
amd_yy_last_accepting_state = amd_yy_current_state;
amd_yy_last_accepting_cpos = amd_yy_cp;
}
while ( amd_yy_chk[amd_yy_base[amd_yy_current_state] + amd_yy_c] != amd_yy_current_state )
{
amd_yy_current_state = (int) amd_yy_def[amd_yy_current_state];
if ( amd_yy_current_state >= 134 )
amd_yy_c = amd_yy_meta[(unsigned int) amd_yy_c];
}
amd_yy_current_state = amd_yy_nxt[amd_yy_base[amd_yy_current_state] + (unsigned int) amd_yy_c];
++amd_yy_cp;
}
while ( amd_yy_base[amd_yy_current_state] != 296 );
amd_yy_find_action:
amd_yy_act = amd_yy_accept[amd_yy_current_state];
if ( amd_yy_act == 0 )
{ /* have to back up */
amd_yy_cp = amd_yy_last_accepting_cpos;
amd_yy_current_state = amd_yy_last_accepting_state;
amd_yy_act = amd_yy_accept[amd_yy_current_state];
}
YY_DO_BEFORE_ACTION;
do_action: /* This label is used only to access EOF actions. */
switch ( amd_yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*amd_yy_cp = amd_yy_hold_char;
amd_yy_cp = amd_yy_last_accepting_cpos;
amd_yy_current_state = amd_yy_last_accepting_state;
goto amd_yy_find_action;
case 1:
YY_RULE_SETUP
#line 50 "lexer.yy"
{ BEGIN(CODE); }
YY_BREAK
case 2:
YY_RULE_SETUP
#line 51 "lexer.yy"
{ /* Optimise for blank lines. */ }
YY_BREAK
case 3:
YY_RULE_SETUP
#line 52 "lexer.yy"
{ BEGIN(PPLINE); }
YY_BREAK
case 4:
YY_RULE_SETUP
#line 53 "lexer.yy"
{ amd_yyless(0); BEGIN(CODE); }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 55 "lexer.yy"
{ BEGIN(BLANK); }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 56 "lexer.yy"
{ }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 57 "lexer.yy"
{ }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 58 "lexer.yy"
{ }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 59 "lexer.yy"
{ }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 62 "lexer.yy"
{ BEGIN(STRING); amd_yylval->sv = newSVpv("", 0); }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 63 "lexer.yy"
{ BEGIN(INITIAL); return L_STRING; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 64 "lexer.yy"
{ sv_catpv(amd_yylval->sv, amd_yytext); }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 66 "lexer.yy"
{ /* octal char */ }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 67 "lexer.yy"
{ /* octal char */ }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 68 "lexer.yy"
{ /* hex char */ }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 69 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\n"); }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 70 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\t"); }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 71 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\v"); }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 72 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\b"); }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 73 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\r"); }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 74 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\f"); }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 75 "lexer.yy"
{ sv_catpv(amd_yylval->sv, "\a"); }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 76 "lexer.yy"
{ sv_catpvn(amd_yylval->sv, (amd_yytext + 1), 1); }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 77 "lexer.yy"
{
amd_yywarnf("Bad hexadecimal escape %s", amd_yytext);
sv_catpv(amd_yylval->sv, amd_yytext);
}
YY_BREAK
case 25:
YY_RULE_SETUP
#line 81 "lexer.yy"
{
amd_yywarnf("Bad octal escape %s", amd_yytext);
sv_catpv(amd_yylval->sv, amd_yytext);
}
YY_BREAK
case 26:
YY_RULE_SETUP
#line 85 "lexer.yy"
{
warn("Unknown escape character \\%c",amd_yytext[1]);
sv_catpvn(amd_yylval->sv, (amd_yytext + 1), 1);
}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 90 "lexer.yy"
{ return amd_yyinteger(amd_yylval); }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 91 "lexer.yy"
{ return amd_yyinteger(amd_yylval); }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 92 "lexer.yy"
{ amd_yylval->number = atol(amd_yytext); return L_PARAMETER; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 93 "lexer.yy"
{ return amd_yyidentifier(amd_yylval, param); }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 94 "lexer.yy"
{ warn("Letters in number and not hex"); }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 96 "lexer.yy"
{ }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 97 "lexer.yy"
{ BEGIN(BLANK); /* increment lineno */ }
YY_BREAK
/* \\ \n should never happen after the preprocessor */
case 34:
YY_RULE_SETUP
#line 100 "lexer.yy"
{ return L_LOR_EQ; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 101 "lexer.yy"
{ return L_LAND_EQ; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 103 "lexer.yy"
{ return L_PLUS_EQ; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 104 "lexer.yy"
{ return L_MINUS_EQ; }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 105 "lexer.yy"
{ return L_DIV_EQ; }
YY_BREAK
case 39:
YY_RULE_SETUP
#line 106 "lexer.yy"
{ return L_TIMES_EQ; }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 107 "lexer.yy"
{ return L_MOD_EQ; }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 108 "lexer.yy"
{ return L_AND_EQ; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 109 "lexer.yy"
{ return L_OR_EQ; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 110 "lexer.yy"
{ return L_XOR_EQ; }
YY_BREAK
case 44:
YY_RULE_SETUP
#line 111 "lexer.yy"
{ return L_DOT_EQ; }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 113 "lexer.yy"
{ return L_EQ; }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 114 "lexer.yy"
{ return L_NE; }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 115 "lexer.yy"
{ return L_LE; }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 116 "lexer.yy"
{ return L_GE; }
YY_BREAK
case 49:
YY_RULE_SETUP
#line 118 "lexer.yy"
{ return L_LOR; }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 119 "lexer.yy"
{ return L_LAND; }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 121 "lexer.yy"
{ return L_INC; }
YY_BREAK
case 52:
YY_RULE_SETUP
#line 122 "lexer.yy"
{ return L_DEC; }
YY_BREAK
case 53:
YY_RULE_SETUP
#line 124 "lexer.yy"
{ return L_RSH; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 125 "lexer.yy"
{ return L_LSH; }
YY_BREAK
case 55:
YY_RULE_SETUP
#line 127 "lexer.yy"
{ return L_MAP_START; }
YY_BREAK
case 56:
YY_RULE_SETUP
#line 128 "lexer.yy"
{ return L_MAP_END; }
YY_BREAK
case 57:
YY_RULE_SETUP
#line 129 "lexer.yy"
{ return L_ARRAY_START; }
YY_BREAK
case 58:
YY_RULE_SETUP
#line 130 "lexer.yy"
{ return L_ARRAY_END; }
YY_BREAK
case 59:
YY_RULE_SETUP
#line 131 "lexer.yy"
{ return L_FUNCTION_START; }
YY_BREAK
case 60:
YY_RULE_SETUP
#line 132 "lexer.yy"
{ return L_FUNCTION_END; }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 134 "lexer.yy"
{ return L_COLONCOLON; }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 135 "lexer.yy"
{ return L_ARROW; }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 136 "lexer.yy"
{ return L_RANGE; }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 138 "lexer.yy"
{ return L_ELLIPSIS; }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 140 "lexer.yy"
{ return *amd_yytext; }
YY_BREAK
/* Strays */
case 66:
YY_RULE_SETUP
#line 144 "lexer.yy"
{ amd_yyerrorf("Stray \\ in program\n"); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 145 "lexer.yy"
{ amd_yyerrorf("Illegal character (hex %d) '%c'\n",
*amd_yytext, *amd_yytext); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 147 "lexer.yy"
{ amd_yyerrorf("Unexpected non-ASCII %d\n", *amd_yytext); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(CODE):
case YY_STATE_EOF(BLANK):
case YY_STATE_EOF(STRING):
case YY_STATE_EOF(PPLINE):
case YY_STATE_EOF(CCOMMENT):
case YY_STATE_EOF(CPPCOMMENT):
#line 148 "lexer.yy"
{ return 0; }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 150 "lexer.yy"
ECHO;
YY_BREAK
#line 1118 "lex.yy.c"
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int amd_yy_amount_of_matched_text = (int) (amd_yy_cp - amd_yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*amd_yy_cp = amd_yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( amd_yy_current_buffer->amd_yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed amd_yyin at a new source and called
* amd_yylex(). If so, then we have to assure
* consistency between amd_yy_current_buffer and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
amd_yy_n_chars = amd_yy_current_buffer->amd_yy_n_chars;
amd_yy_current_buffer->amd_yy_input_file = amd_yyin;
amd_yy_current_buffer->amd_yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for amd_yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since amd_yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( amd_yy_c_buf_p <= &amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars] )
{ /* This was really a NUL. */
amd_yy_state_type amd_yy_next_state;
amd_yy_c_buf_p = amd_yytext_ptr + amd_yy_amount_of_matched_text;
amd_yy_current_state = amd_yy_get_previous_state();
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* amd_yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
amd_yy_next_state = amd_yy_try_NUL_trans( amd_yy_current_state );
amd_yy_bp = amd_yytext_ptr + YY_MORE_ADJ;
if ( amd_yy_next_state )
{
/* Consume the NUL. */
amd_yy_cp = ++amd_yy_c_buf_p;
amd_yy_current_state = amd_yy_next_state;
goto amd_yy_match;
}
else
{
amd_yy_cp = amd_yy_c_buf_p;
goto amd_yy_find_action;
}
}
else switch ( amd_yy_get_next_buffer() )
{
case EOB_ACT_END_OF_FILE:
{
amd_yy_did_buffer_switch_on_eof = 0;
if ( amd_yywrap() )
{
/* Note: because we've taken care in
* amd_yy_get_next_buffer() to have set up
* amd_yytext, we can now set up
* amd_yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
amd_yy_c_buf_p = amd_yytext_ptr + YY_MORE_ADJ;
amd_yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! amd_yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
amd_yy_c_buf_p =
amd_yytext_ptr + amd_yy_amount_of_matched_text;
amd_yy_current_state = amd_yy_get_previous_state();
amd_yy_cp = amd_yy_c_buf_p;
amd_yy_bp = amd_yytext_ptr + YY_MORE_ADJ;
goto amd_yy_match;
case EOB_ACT_LAST_MATCH:
amd_yy_c_buf_p =
&amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars];
amd_yy_current_state = amd_yy_get_previous_state();
amd_yy_cp = amd_yy_c_buf_p;
amd_yy_bp = amd_yytext_ptr + YY_MORE_ADJ;
goto amd_yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of amd_yylex */
/* amd_yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
static int amd_yy_get_next_buffer()
{
register char *dest = amd_yy_current_buffer->amd_yy_ch_buf;
register char *source = amd_yytext_ptr;
register int number_to_move, i;
int ret_val;
if ( amd_yy_c_buf_p > &amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( amd_yy_current_buffer->amd_yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( amd_yy_c_buf_p - amd_yytext_ptr - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
}
else
{
/* We matched some text prior to the EOB, first
* process it.
*/
return EOB_ACT_LAST_MATCH;
}
}
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) (amd_yy_c_buf_p - amd_yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( amd_yy_current_buffer->amd_yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
amd_yy_current_buffer->amd_yy_n_chars = amd_yy_n_chars = 0;
else
{
int num_to_read =
amd_yy_current_buffer->amd_yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
#ifdef YY_USES_REJECT
YY_FATAL_ERROR(
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
#else
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = amd_yy_current_buffer;
int amd_yy_c_buf_p_offset =
(int) (amd_yy_c_buf_p - b->amd_yy_ch_buf);
if ( b->amd_yy_is_our_buffer )
{
int new_size = b->amd_yy_buf_size * 2;
if ( new_size <= 0 )
b->amd_yy_buf_size += b->amd_yy_buf_size / 8;
else
b->amd_yy_buf_size *= 2;
b->amd_yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
amd_yy_flex_realloc( (void *) b->amd_yy_ch_buf,
b->amd_yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
b->amd_yy_ch_buf = 0;
if ( ! b->amd_yy_ch_buf )
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
amd_yy_c_buf_p = &b->amd_yy_ch_buf[amd_yy_c_buf_p_offset];
num_to_read = amd_yy_current_buffer->amd_yy_buf_size -
number_to_move - 1;
#endif
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
YY_INPUT( (&amd_yy_current_buffer->amd_yy_ch_buf[number_to_move]),
amd_yy_n_chars, num_to_read );
amd_yy_current_buffer->amd_yy_n_chars = amd_yy_n_chars;
}
if ( amd_yy_n_chars == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
amd_yyrestart( amd_yyin );
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
amd_yy_current_buffer->amd_yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
amd_yy_n_chars += number_to_move;
amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars] = YY_END_OF_BUFFER_CHAR;
amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
amd_yytext_ptr = &amd_yy_current_buffer->amd_yy_ch_buf[0];
return ret_val;
}
/* amd_yy_get_previous_state - get the state just before the EOB char was reached */
static amd_yy_state_type amd_yy_get_previous_state()
{
register amd_yy_state_type amd_yy_current_state;
register char *amd_yy_cp;
amd_yy_current_state = amd_yy_start;
for ( amd_yy_cp = amd_yytext_ptr + YY_MORE_ADJ; amd_yy_cp < amd_yy_c_buf_p; ++amd_yy_cp )
{
register YY_CHAR amd_yy_c = (*amd_yy_cp ? amd_yy_ec[YY_SC_TO_UI(*amd_yy_cp)] : 1);
if ( amd_yy_accept[amd_yy_current_state] )
{
amd_yy_last_accepting_state = amd_yy_current_state;
amd_yy_last_accepting_cpos = amd_yy_cp;
}
while ( amd_yy_chk[amd_yy_base[amd_yy_current_state] + amd_yy_c] != amd_yy_current_state )
{
amd_yy_current_state = (int) amd_yy_def[amd_yy_current_state];
if ( amd_yy_current_state >= 134 )
amd_yy_c = amd_yy_meta[(unsigned int) amd_yy_c];
}
amd_yy_current_state = amd_yy_nxt[amd_yy_base[amd_yy_current_state] + (unsigned int) amd_yy_c];
}
return amd_yy_current_state;
}
/* amd_yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = amd_yy_try_NUL_trans( current_state );
*/
#ifdef YY_USE_PROTOS
static amd_yy_state_type amd_yy_try_NUL_trans( amd_yy_state_type amd_yy_current_state )
#else
static amd_yy_state_type amd_yy_try_NUL_trans( amd_yy_current_state )
amd_yy_state_type amd_yy_current_state;
#endif
{
register int amd_yy_is_jam;
register char *amd_yy_cp = amd_yy_c_buf_p;
register YY_CHAR amd_yy_c = 1;
if ( amd_yy_accept[amd_yy_current_state] )
{
amd_yy_last_accepting_state = amd_yy_current_state;
amd_yy_last_accepting_cpos = amd_yy_cp;
}
while ( amd_yy_chk[amd_yy_base[amd_yy_current_state] + amd_yy_c] != amd_yy_current_state )
{
amd_yy_current_state = (int) amd_yy_def[amd_yy_current_state];
if ( amd_yy_current_state >= 134 )
amd_yy_c = amd_yy_meta[(unsigned int) amd_yy_c];
}
amd_yy_current_state = amd_yy_nxt[amd_yy_base[amd_yy_current_state] + (unsigned int) amd_yy_c];
amd_yy_is_jam = (amd_yy_current_state == 133);
return amd_yy_is_jam ? 0 : amd_yy_current_state;
}
#ifndef YY_NO_UNPUT
#ifdef YY_USE_PROTOS
static void amd_yyunput( int c, register char *amd_yy_bp )
#else
static void amd_yyunput( c, amd_yy_bp )
int c;
register char *amd_yy_bp;
#endif
{
register char *amd_yy_cp = amd_yy_c_buf_p;
/* undo effects of setting up amd_yytext */
*amd_yy_cp = amd_yy_hold_char;
if ( amd_yy_cp < amd_yy_current_buffer->amd_yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = amd_yy_n_chars + 2;
register char *dest = &amd_yy_current_buffer->amd_yy_ch_buf[
amd_yy_current_buffer->amd_yy_buf_size + 2];
register char *source =
&amd_yy_current_buffer->amd_yy_ch_buf[number_to_move];
while ( source > amd_yy_current_buffer->amd_yy_ch_buf )
*--dest = *--source;
amd_yy_cp += (int) (dest - source);
amd_yy_bp += (int) (dest - source);
amd_yy_current_buffer->amd_yy_n_chars =
amd_yy_n_chars = amd_yy_current_buffer->amd_yy_buf_size;
if ( amd_yy_cp < amd_yy_current_buffer->amd_yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
*--amd_yy_cp = (char) c;
amd_yytext_ptr = amd_yy_bp;
amd_yy_hold_char = *amd_yy_cp;
amd_yy_c_buf_p = amd_yy_cp;
}
#endif /* ifndef YY_NO_UNPUT */
#ifdef __cplusplus
static int amd_yyinput()
#else
static int input()
#endif
{
int c;
*amd_yy_c_buf_p = amd_yy_hold_char;
if ( *amd_yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
{
/* amd_yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( amd_yy_c_buf_p < &amd_yy_current_buffer->amd_yy_ch_buf[amd_yy_n_chars] )
/* This was really a NUL. */
*amd_yy_c_buf_p = '\0';
else
{ /* need more input */
int offset = amd_yy_c_buf_p - amd_yytext_ptr;
++amd_yy_c_buf_p;
switch ( amd_yy_get_next_buffer() )
{
case EOB_ACT_LAST_MATCH:
/* This happens because amd_yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
amd_yyrestart( amd_yyin );
/* fall through */
case EOB_ACT_END_OF_FILE:
{
if ( amd_yywrap() )
return EOF;
if ( ! amd_yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
return amd_yyinput();
#else
return input();
#endif
}
case EOB_ACT_CONTINUE_SCAN:
amd_yy_c_buf_p = amd_yytext_ptr + offset;
break;
}
}
}
c = *(unsigned char *) amd_yy_c_buf_p; /* cast for 8-bit char's */
*amd_yy_c_buf_p = '\0'; /* preserve amd_yytext */
amd_yy_hold_char = *++amd_yy_c_buf_p;
return c;
}
#ifdef YY_USE_PROTOS
void amd_yyrestart( FILE *input_file )
#else
void amd_yyrestart( input_file )
FILE *input_file;
#endif
{
if ( ! amd_yy_current_buffer )
amd_yy_current_buffer = amd_yy_create_buffer( amd_yyin, YY_BUF_SIZE );
amd_yy_init_buffer( amd_yy_current_buffer, input_file );
amd_yy_load_buffer_state();
}
#ifdef YY_USE_PROTOS
void amd_yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
#else
void amd_yy_switch_to_buffer( new_buffer )
YY_BUFFER_STATE new_buffer;
#endif
{
if ( amd_yy_current_buffer == new_buffer )
return;
if ( amd_yy_current_buffer )
{
/* Flush out information for old buffer. */
*amd_yy_c_buf_p = amd_yy_hold_char;
amd_yy_current_buffer->amd_yy_buf_pos = amd_yy_c_buf_p;
amd_yy_current_buffer->amd_yy_n_chars = amd_yy_n_chars;
}
amd_yy_current_buffer = new_buffer;
amd_yy_load_buffer_state();
/* We don't actually know whether we did this switch during
* EOF (amd_yywrap()) processing, but the only time this flag
* is looked at is after amd_yywrap() is called, so it's safe
* to go ahead and always set it.
*/
amd_yy_did_buffer_switch_on_eof = 1;
}
#ifdef YY_USE_PROTOS
void amd_yy_load_buffer_state( void )
#else
void amd_yy_load_buffer_state()
#endif
{
amd_yy_n_chars = amd_yy_current_buffer->amd_yy_n_chars;
amd_yytext_ptr = amd_yy_c_buf_p = amd_yy_current_buffer->amd_yy_buf_pos;
amd_yyin = amd_yy_current_buffer->amd_yy_input_file;
amd_yy_hold_char = *amd_yy_c_buf_p;
}
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE amd_yy_create_buffer( FILE *file, int size )
#else
YY_BUFFER_STATE amd_yy_create_buffer( file, size )
FILE *file;
int size;
#endif
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) amd_yy_flex_alloc( sizeof( struct amd_yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in amd_yy_create_buffer()" );
b->amd_yy_buf_size = size;
/* amd_yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->amd_yy_ch_buf = (char *) amd_yy_flex_alloc( b->amd_yy_buf_size + 2 );
if ( ! b->amd_yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in amd_yy_create_buffer()" );
b->amd_yy_is_our_buffer = 1;
amd_yy_init_buffer( b, file );
return b;
}
#ifdef YY_USE_PROTOS
void amd_yy_delete_buffer( YY_BUFFER_STATE b )
#else
void amd_yy_delete_buffer( b )
YY_BUFFER_STATE b;
#endif
{
if ( ! b )
return;
if ( b == amd_yy_current_buffer )
amd_yy_current_buffer = (YY_BUFFER_STATE) 0;
if ( b->amd_yy_is_our_buffer )
amd_yy_flex_free( (void *) b->amd_yy_ch_buf );
amd_yy_flex_free( (void *) b );
}
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
#include<unistd.h>
#endif
#endif
#ifdef YY_USE_PROTOS
void amd_yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#else
void amd_yy_init_buffer( b, file )
YY_BUFFER_STATE b;
FILE *file;
#endif
{
amd_yy_flush_buffer( b );
b->amd_yy_input_file = file;
b->amd_yy_fill_buffer = 1;
#if YY_ALWAYS_INTERACTIVE
b->amd_yy_is_interactive = 1;
#else
#if YY_NEVER_INTERACTIVE
b->amd_yy_is_interactive = 0;
#else
b->amd_yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
#endif
#endif
}
#ifdef YY_USE_PROTOS
void amd_yy_flush_buffer( YY_BUFFER_STATE b )
#else
void amd_yy_flush_buffer( b )
YY_BUFFER_STATE b;
#endif
{
if ( ! b )
return;
b->amd_yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->amd_yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->amd_yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->amd_yy_buf_pos = &b->amd_yy_ch_buf[0];
b->amd_yy_at_bol = 1;
b->amd_yy_buffer_status = YY_BUFFER_NEW;
if ( b == amd_yy_current_buffer )
amd_yy_load_buffer_state();
}
#ifndef YY_NO_SCAN_BUFFER
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE amd_yy_scan_buffer( char *base, amd_yy_size_t size )
#else
YY_BUFFER_STATE amd_yy_scan_buffer( base, size )
char *base;
amd_yy_size_t size;
#endif
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) amd_yy_flex_alloc( sizeof( struct amd_yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in amd_yy_scan_buffer()" );
b->amd_yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->amd_yy_buf_pos = b->amd_yy_ch_buf = base;
b->amd_yy_is_our_buffer = 0;
b->amd_yy_input_file = 0;
b->amd_yy_n_chars = b->amd_yy_buf_size;
b->amd_yy_is_interactive = 0;
b->amd_yy_at_bol = 1;
b->amd_yy_fill_buffer = 0;
b->amd_yy_buffer_status = YY_BUFFER_NEW;
amd_yy_switch_to_buffer( b );
return b;
}
#endif
#ifndef YY_NO_SCAN_STRING
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE amd_yy_scan_string( amd_yyconst char *amd_yy_str )
#else
YY_BUFFER_STATE amd_yy_scan_string( amd_yy_str )
amd_yyconst char *amd_yy_str;
#endif
{
int len;
for ( len = 0; amd_yy_str[len]; ++len )
;
return amd_yy_scan_bytes( amd_yy_str, len );
}
#endif
#ifndef YY_NO_SCAN_BYTES
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE amd_yy_scan_bytes( amd_yyconst char *bytes, int len )
#else
YY_BUFFER_STATE amd_yy_scan_bytes( bytes, len )
amd_yyconst char *bytes;
int len;
#endif
{
YY_BUFFER_STATE b;
char *buf;
amd_yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2;
buf = (char *) amd_yy_flex_alloc( n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in amd_yy_scan_bytes()" );
for ( i = 0; i < len; ++i )
buf[i] = bytes[i];
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
b = amd_yy_scan_buffer( buf, n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in amd_yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->amd_yy_is_our_buffer = 1;
return b;
}
#endif
#ifndef YY_NO_PUSH_STATE
#ifdef YY_USE_PROTOS
static void amd_yy_push_state( int new_state )
#else
static void amd_yy_push_state( new_state )
int new_state;
#endif
{
if ( amd_yy_start_stack_ptr >= amd_yy_start_stack_depth )
{
amd_yy_size_t new_size;
amd_yy_start_stack_depth += YY_START_STACK_INCR;
new_size = amd_yy_start_stack_depth * sizeof( int );
if ( ! amd_yy_start_stack )
amd_yy_start_stack = (int *) amd_yy_flex_alloc( new_size );
else
amd_yy_start_stack = (int *) amd_yy_flex_realloc(
(void *) amd_yy_start_stack, new_size );
if ( ! amd_yy_start_stack )
YY_FATAL_ERROR(
"out of memory expanding start-condition stack" );
}
amd_yy_start_stack[amd_yy_start_stack_ptr++] = YY_START;
BEGIN(new_state);
}
#endif
#ifndef YY_NO_POP_STATE
static void amd_yy_pop_state()
{
if ( --amd_yy_start_stack_ptr < 0 )
YY_FATAL_ERROR( "start-condition stack underflow" );
BEGIN(amd_yy_start_stack[amd_yy_start_stack_ptr]);
}
#endif
#ifndef YY_NO_TOP_STATE
static int amd_yy_top_state()
{
return amd_yy_start_stack[amd_yy_start_stack_ptr - 1];
}
#endif
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
#ifdef YY_USE_PROTOS
static void amd_yy_fatal_error( amd_yyconst char msg[] )
#else
static void amd_yy_fatal_error( msg )
char msg[];
#endif
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
/* Redefine amd_yyless() so it works in section 3 code. */
#undef amd_yyless
#define amd_yyless(n) \
do \
{ \
/* Undo effects of setting up amd_yytext. */ \
amd_yytext[amd_yyleng] = amd_yy_hold_char; \
amd_yy_c_buf_p = amd_yytext + n; \
amd_yy_hold_char = *amd_yy_c_buf_p; \
*amd_yy_c_buf_p = '\0'; \
amd_yyleng = n; \
} \
while ( 0 )
/* Internal utility routines. */
#ifndef amd_yytext_ptr
#ifdef YY_USE_PROTOS
static void amd_yy_flex_strncpy( char *s1, amd_yyconst char *s2, int n )
#else
static void amd_yy_flex_strncpy( s1, s2, n )
char *s1;
amd_yyconst char *s2;
int n;
#endif
{
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
#ifdef YY_USE_PROTOS
static int amd_yy_flex_strlen( amd_yyconst char *s )
#else
static int amd_yy_flex_strlen( s )
amd_yyconst char *s;
#endif
{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
#ifdef YY_USE_PROTOS
static void *amd_yy_flex_alloc( amd_yy_size_t size )
#else
static void *amd_yy_flex_alloc( size )
amd_yy_size_t size;
#endif
{
return (void *) malloc( size );
}
#ifdef YY_USE_PROTOS
static void *amd_yy_flex_realloc( void *ptr, amd_yy_size_t size )
#else
static void *amd_yy_flex_realloc( ptr, size )
void *ptr;
amd_yy_size_t size;
#endif
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
#ifdef YY_USE_PROTOS
static void amd_yy_flex_free( void *ptr )
#else
static void amd_yy_flex_free( ptr )
void *ptr;
#endif
{
free( ptr );
}
#if YY_MAIN
int main()
{
amd_yylex();
return 0;
}
#endif
#line 150 "lexer.yy"
void
amd_yywarnv(const char *fmt, va_list args)
{
char msg[BUFSIZ];
vsnprintf(msg, BUFSIZ, fmt, args);
fprintf(stderr, "%s", msg);
}
void
amd_yywarnf(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
amd_yywarnv(fmt, args);
va_end(args);
}
void
amd_yyerrorf(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
amd_yywarnv(fmt, args);
va_end(args);
exit(1);
}
void
amd_yyerror(const char *str)
{
amd_yyerrorf("Parse error: %s\n", str);
}
static int
amd_yyinteger(AMD_YYSTYPE *lvalp)
{
unsigned long val;
char *ep;
val = strtoul(amd_yytext, &ep, 0);
if (*ep) {
amd_yywarnf("Invalid integer %s: character %c is invalid\n",
amd_yytext, *ep);
val = 0;
}
lvalp->number = val;
return L_INTEGER;
}
static int
amd_yyidentifier(AMD_YYSTYPE *lvalp, amd_parse_param_t *param)
{
SV **svp;
SV *sv;
SV **lvp;
#if 0
fprintf(stderr, "amd_yyidentifier: %s\n", amd_yytext);
fflush(stderr);
#endif
svp = hv_fetch(amd_kwtab, amd_yytext, amd_yyleng, FALSE);
if (svp) {
lvalp->number = 0;
lvp = hv_fetch(amd_lvaltab, amd_yytext, amd_yyleng, FALSE);
if (lvp) {
*lvalp = *(INT2PTR(AMD_YYSTYPE *, SvIV(*lvp)));
}
return SvIV(*svp);
}
/* Throw the thing in some sort of hash table so we get an SV? */
svp = hv_fetch(param->symtab, amd_yytext, amd_yyleng, FALSE);
if (svp) {
sv = *svp;
}
else {
sv = newSVpv(amd_yytext, amd_yyleng);
hv_store(param->symtab, amd_yytext, amd_yyleng, sv, 0);
}
lvalp->sv = sv;
return L_IDENTIFIER;
}
void
amd_yyunput_map_end()
{
amd_yyless(1);
}
void
amd_yylex_init(const char *str)
{
amd_yy_scan_string(str);
BEGIN(BLANK);
}
int
amd_yylex_verbose(AMD_YYSTYPE *amd_yylval, amd_parse_param_t *param)
{
int tok;
tok = amd_yylex(amd_yylval, param);
fprintf(stderr, "L: %d (%s) [%s]\n", tok, amd_yytokname(tok), amd_yytext);
return tok;
}
int
test_lexer(const char *str)
{
AMD_YYSTYPE amd_yylval;
amd_parse_param_t param;
memset(¶m, 0, sizeof(param));
param.program = NULL;
param.symtab = newHV();
amd_yylex_init(str);
while (amd_yylex_verbose(&amd_yylval, ¶m))
;
return 0;
}