/* 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 CTL_Y__FLEX_MAJOR_VERSION 2 #define CTL_Y__FLEX_MINOR_VERSION 5 #include #include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include /* Use prototypes in function declarations. */ #define CTL_Y__USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define CTL_Y__USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define CTL_Y__USE_PROTOS #define CTL_Y__USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include #include #define CTL_Y__USE_CONST #define CTL_Y__USE_PROTOS #endif #ifdef CTL_Y__USE_CONST #define ctp_y_const const #else #define ctp_y_const #endif #ifdef CTL_Y__USE_PROTOS #define CTL_Y__PROTO(proto) proto #else #define CTL_Y__PROTO(proto) () #endif /* Returned upon end-of-file. */ #define CTL_Y__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 CTL_Y__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 ctp_y__start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The CTL_Y_STATE alias is for lex * compatibility. */ #define CTL_Y__START ((ctp_y__start - 1) / 2) #define CTL_Y_STATE CTL_Y__START /* Action number for EOF rule of a given start state. */ #define CTL_Y__STATE_EOF(state) (CTL_Y__END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define CTL_Y__NEW_FILE ctp_y_restart( ctp_y_in ) #define CTL_Y__END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define CTL_Y__BUF_SIZE 16384 typedef struct ctp_y__buffer_state *CTL_Y__BUFFER_STATE; extern int ctp_y_leng; extern FILE *ctp_y_in, *ctp_y_out; #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 ) * ctp_y_less( 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 ctp_y_less() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define ctp_y_less(n) \ do \ { \ /* Undo effects of setting up ctp_y_text. */ \ *ctp_y__cp = ctp_y__hold_char; \ CTL_Y__RESTORE_CTL_Y__MORE_OFFSET \ ctp_y__c_buf_p = ctp_y__cp = ctp_y__bp + n - CTL_Y__MORE_ADJ; \ CTL_Y__DO_BEFORE_ACTION; /* set up ctp_y_text again */ \ } \ while ( 0 ) #define unput(c) ctp_y_unput( c, ctp_y_text_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 ctp_y__size_t; struct ctp_y__buffer_state { FILE *ctp_y__input_file; char *ctp_y__ch_buf; /* input buffer */ char *ctp_y__buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ ctp_y__size_t ctp_y__buf_size; /* Number of characters read into ctp_y__ch_buf, not including EOB * characters. */ int ctp_y__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 ctp_y__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 ctp_y__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 ctp_y__at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int ctp_y__fill_buffer; int ctp_y__buffer_status; #define CTL_Y__BUFFER_NEW 0 #define CTL_Y__BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as CTL_Y__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 ctp_y_restart()), so that the user can continue scanning by * just pointing ctp_y_in at a new input file. */ #define CTL_Y__BUFFER_EOF_PENDING 2 }; static CTL_Y__BUFFER_STATE ctp_y__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 CTL_Y__CURRENT_BUFFER ctp_y__current_buffer /* ctp_y__hold_char holds the character lost when ctp_y_text is formed. */ static char ctp_y__hold_char; static int ctp_y__n_chars; /* number of characters read into ctp_y__ch_buf */ int ctp_y_leng; /* Points to current character in buffer. */ static char *ctp_y__c_buf_p = (char *) 0; static int ctp_y__init = 1; /* whether we need to initialize */ static int ctp_y__start = 0; /* start state number */ /* Flag which is used to allow ctp_y_wrap()'s to do buffer switches * instead of setting up a fresh ctp_y_in. A bit of a hack ... */ static int ctp_y__did_buffer_switch_on_eof; void ctp_y_restart CTL_Y__PROTO(( FILE *input_file )); void ctp_y__switch_to_buffer CTL_Y__PROTO(( CTL_Y__BUFFER_STATE new_buffer )); void ctp_y__load_buffer_state CTL_Y__PROTO(( void )); CTL_Y__BUFFER_STATE ctp_y__create_buffer CTL_Y__PROTO(( FILE *file, int size )); void ctp_y__delete_buffer CTL_Y__PROTO(( CTL_Y__BUFFER_STATE b )); void ctp_y__init_buffer CTL_Y__PROTO(( CTL_Y__BUFFER_STATE b, FILE *file )); void ctp_y__flush_buffer CTL_Y__PROTO(( CTL_Y__BUFFER_STATE b )); #define CTL_Y__FLUSH_BUFFER ctp_y__flush_buffer( ctp_y__current_buffer ) CTL_Y__BUFFER_STATE ctp_y__scan_buffer CTL_Y__PROTO(( char *base, ctp_y__size_t size )); CTL_Y__BUFFER_STATE ctp_y__scan_string CTL_Y__PROTO(( ctp_y_const char *ctp_y__str )); CTL_Y__BUFFER_STATE ctp_y__scan_bytes CTL_Y__PROTO(( ctp_y_const char *bytes, int len )); static void *ctp_y__flex_alloc CTL_Y__PROTO(( ctp_y__size_t )); static void *ctp_y__flex_realloc CTL_Y__PROTO(( void *, ctp_y__size_t )); static void ctp_y__flex_free CTL_Y__PROTO(( void * )); #define ctp_y__new_buffer ctp_y__create_buffer #define ctp_y__set_interactive(is_interactive) \ { \ if ( ! ctp_y__current_buffer ) \ ctp_y__current_buffer = ctp_y__create_buffer( ctp_y_in, CTL_Y__BUF_SIZE ); \ ctp_y__current_buffer->ctp_y__is_interactive = is_interactive; \ } #define ctp_y__set_bol(at_bol) \ { \ if ( ! ctp_y__current_buffer ) \ ctp_y__current_buffer = ctp_y__create_buffer( ctp_y_in, CTL_Y__BUF_SIZE ); \ ctp_y__current_buffer->ctp_y__at_bol = at_bol; \ } #define CTL_Y__AT_BOL() (ctp_y__current_buffer->ctp_y__at_bol) typedef unsigned char CTL_Y__CHAR; FILE *ctp_y_in = (FILE *) 0, *ctp_y_out = (FILE *) 0; typedef int ctp_y__state_type; extern char *ctp_y_text; #define ctp_y_text_ptr ctp_y_text static ctp_y__state_type ctp_y__get_previous_state CTL_Y__PROTO(( void )); static ctp_y__state_type ctp_y__try_NUL_trans CTL_Y__PROTO(( ctp_y__state_type current_state )); static int ctp_y__get_next_buffer CTL_Y__PROTO(( void )); static void ctp_y__fatal_error CTL_Y__PROTO(( ctp_y_const char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up ctp_y_text. */ #define CTL_Y__DO_BEFORE_ACTION \ ctp_y_text_ptr = ctp_y__bp; \ ctp_y_leng = (int) (ctp_y__cp - ctp_y__bp); \ ctp_y__hold_char = *ctp_y__cp; \ *ctp_y__cp = '\0'; \ ctp_y__c_buf_p = ctp_y__cp; #define CTL_Y__NUM_RULES 36 #define CTL_Y__END_OF_BUFFER 37 static ctp_y_const short int ctp_y__accept[99] = { 0, 0, 0, 37, 35, 1, 33, 25, 35, 35, 2, 3, 4, 5, 9, 10, 11, 12, 26, 27, 29, 14, 15, 18, 20, 19, 28, 28, 24, 0, 31, 0, 31, 0, 8, 0, 7, 21, 0, 0, 29, 0, 0, 0, 13, 0, 16, 23, 22, 17, 28, 0, 0, 0, 30, 0, 34, 0, 29, 0, 0, 29, 6, 0, 0, 29, 0, 0, 0, 29, 0, 0, 0, 29, 0, 29, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 29, 29, 0, 29, 0, 0 } ; static ctp_y_const int ctp_y__ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, 22, 23, 24, 7, 7, 25, 26, 25, 25, 27, 25, 28, 28, 28, 28, 28, 28, 28, 28, 29, 28, 28, 28, 28, 28, 28, 28, 28, 30, 28, 28, 7, 7, 7, 7, 31, 7, 32, 33, 32, 32, 34, 32, 35, 35, 35, 35, 35, 35, 35, 35, 36, 35, 35, 35, 35, 35, 35, 35, 35, 37, 35, 35, 7, 38, 7, 7, 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 ctp_y_const int ctp_y__meta[39] = { 0, 1, 2, 1, 2, 3, 4, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 6, 2, 7, 8, 2, 2, 2, 2, 7, 7, 7, 9, 9, 9, 10, 7, 7, 7, 9, 9, 9, 2 } ; static ctp_y_const short int ctp_y__base[116] = { 0, 0, 0, 222, 223, 223, 223, 223, 216, 212, 223, 0, 223, 223, 206, 223, 223, 23, 223, 195, 42, 194, 223, 26, 192, 192, 183, 35, 223, 207, 203, 199, 197, 194, 223, 198, 223, 223, 0, 181, 0, 0, 37, 179, 223, 171, 223, 223, 223, 223, 163, 161, 0, 0, 223, 188, 223, 40, 33, 24, 171, 39, 223, 49, 37, 38, 0, 57, 69, 58, 168, 0, 62, 56, 64, 68, 163, 223, 73, 86, 88, 89, 87, 92, 74, 93, 162, 83, 102, 104, 91, 93, 159, 96, 97, 145, 99, 115, 223, 134, 143, 152, 156, 166, 125, 124, 122, 119, 173, 178, 186, 192, 118, 114, 199, 203 } ; static ctp_y_const short int ctp_y__def[116] = { 0, 98, 1, 98, 98, 98, 98, 98, 99, 100, 98, 101, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 102, 102, 98, 99, 98, 100, 98, 98, 98, 103, 98, 98, 104, 98, 20, 105, 98, 98, 98, 98, 98, 98, 98, 98, 102, 102, 106, 107, 98, 103, 98, 108, 98, 109, 98, 98, 98, 110, 111, 98, 112, 108, 108, 98, 98, 113, 109, 98, 109, 98, 98, 98, 110, 110, 111, 111, 98, 114, 115, 98, 98, 98, 114, 114, 115, 115, 98, 98, 98, 98, 98, 98, 0, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98 } ; static ctp_y_const short int ctp_y__nxt[262] = { 0, 4, 5, 6, 7, 8, 4, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 26, 26, 27, 27, 4, 26, 27, 26, 26, 27, 27, 28, 35, 52, 71, 45, 53, 73, 77, 65, 36, 38, 46, 47, 60, 69, 60, 77, 74, 61, 66, 75, 39, 42, 40, 41, 65, 70, 82, 51, 42, 81, 42, 76, 68, 82, 43, 66, 98, 42, 69, 77, 71, 79, 98, 73, 85, 98, 42, 98, 75, 68, 70, 85, 98, 42, 74, 73, 98, 77, 98, 65, 76, 98, 86, 94, 86, 79, 91, 87, 92, 65, 92, 98, 73, 93, 98, 95, 96, 94, 98, 96, 81, 98, 84, 91, 89, 98, 83, 64, 97, 95, 63, 97, 59, 57, 89, 96, 98, 29, 29, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 33, 33, 33, 33, 33, 33, 33, 33, 50, 94, 50, 50, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 67, 93, 67, 67, 87, 75, 67, 72, 72, 72, 69, 72, 78, 61, 56, 98, 78, 51, 62, 78, 80, 40, 80, 58, 56, 80, 88, 54, 31, 88, 32, 29, 88, 90, 90, 30, 90, 51, 49, 48, 44, 37, 34, 32, 30, 98, 3, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98 } ; static ctp_y_const short int ctp_y__chk[262] = { 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, 17, 27, 59, 23, 27, 59, 64, 57, 17, 20, 23, 23, 42, 58, 42, 63, 59, 42, 57, 61, 20, 58, 20, 20, 67, 58, 65, 27, 58, 64, 20, 61, 57, 65, 20, 67, 68, 20, 69, 78, 72, 63, 74, 72, 73, 74, 69, 68, 75, 67, 69, 73, 79, 69, 72, 84, 74, 80, 81, 83, 75, 68, 82, 87, 82, 78, 84, 82, 85, 88, 85, 89, 90, 85, 91, 87, 93, 94, 79, 96, 80, 81, 113, 90, 83, 91, 112, 107, 93, 94, 106, 96, 105, 104, 88, 97, 89, 99, 99, 99, 99, 99, 99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, 101, 101, 102, 95, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 108, 92, 108, 108, 86, 76, 108, 109, 109, 109, 70, 109, 110, 60, 55, 51, 110, 50, 45, 110, 111, 43, 111, 39, 35, 111, 114, 33, 32, 114, 31, 30, 114, 115, 115, 29, 115, 26, 25, 24, 21, 19, 14, 9, 8, 3, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98 } ; static ctp_y__state_type ctp_y__last_accepting_state; static char *ctp_y__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 ctp_y_more() ctp_y_more_used_but_not_detected #define CTL_Y__MORE_ADJ 0 #define CTL_Y__RESTORE_CTL_Y__MORE_OFFSET char *ctp_y_text; #line 1 "../../../src/ctp/src/ctp_l.l" #define INITIAL 0 /*------------------------------------------------------------\ | | | This file is part of the Alliance CAD System Copyright | | (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| | | | Home page : http://www-asim.lip6.fr/alliance/ | | E-mail : mailto:alliance-users@asim.lip6.fr | | | | This progam is free software; you can redistribute it | | and/or modify it under the terms of the GNU Library General| | Public License as published by the Free Software Foundation | | either version 2 of the License, or (at your option) any | | later version. | | | | Alliance VLSI CAD System is distributed in the hope that | | it will be useful, but WITHOUT ANY WARRANTY; | | without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | | Public License for more details. | | | | You should have received a copy of the GNU General Public | | License along with the GNU C Library; see the file COPYING. | | If not, write to the Free Software Foundation, Inc., | | 675 Mass Ave, Cambridge, MA 02139, USA. | | | \------------------------------------------------------------*/ #line 28 "../../../src/ctp/src/ctp_l.l" #include #include #include #include #include "mut.h" #include "aut.h" #include "vex.h" #include "ctl.h" typedef struct ctp_expr { vexexpr *IDENT; /* identifier or constant name */ vexexpr *VEX; /* pointer on bvl_abllst list */ short WIDTH; short TYPE; } ctp_vexstr; typedef struct { char *NAME; /* identifier name */ long LEFT; /* vector's left index */ long RIGHT; /* vector's right index */ short WIDTH; char FLAG; } ctp_name; #include "ctp_y.h" #include "ctp_bedef.h" #include "ctp_blex.h" static el_mc tab_mc []= { {"abs" ,ABS}, {"af" ,_AF}, {"ag" ,_AG}, {"and" ,tok_AND}, {"array" ,ARRAY}, {"assume" ,_ASSUME}, {"au" ,_AU}, {"ax" ,_AX}, {"begin" ,_BEGIN}, {"define" ,_DEFINE}, {"downto" ,DOWNTO}, {"ef" ,_EF}, {"eg" ,_EG}, {"end" ,_END}, {"error" ,ERROR}, {"eu" ,_EU}, {"event" ,_EVENT}, {"ex" ,_EX}, {"false" ,_FALSE}, {"high" ,_HIGH}, {"ift" ,_IFT}, {"initial" ,_INITIAL}, {"is" ,IS}, {"left" ,_LEFT}, {"length" ,_LENGTH}, {"low" ,_LOW}, {"mod" ,MOD}, {"nand" ,_NAND}, {"nor" ,_NOR}, {"not" ,_NOT}, {"nxor" ,_NXOR}, {"of" ,OF}, {"or" ,_OR}, {"others" ,OTHERS}, {"range" ,_RANGE}, {"rem" ,REM}, {"reset_cond" ,_RESET_COND}, {"reverse_range" ,_REV_RANGE}, {"right" ,_RIGHT}, {"stable" ,_STABLE}, {"subtype" ,SUBTYPE}, {"to" ,TO}, {"true" ,_TRUE }, {"type" ,_TYPE}, {"variable" ,_VARIABLE}, {"xnor" ,_NXOR}, {"xor" ,_XOR} }; static int find_mc(s) char *s; { char loc[512]; int l; el_mc *pt; l=strlen(s); strcpy(loc,s); while(l--) loc[l]=tolower(loc[l]); /* conversion en minuscules */ pt= (el_mc *) bsearch(loc, (char *)tab_mc,CTP_NB_MC,sizeof(el_mc), (int (*)(const void *, const void *)) strcmp); if (pt==NULL) return(-1); return(pt->kval); } /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef CTL_Y__SKIP_CTL_Y_WRAP #ifdef __cplusplus extern "C" int ctp_y_wrap CTL_Y__PROTO(( void )); #else extern int ctp_y_wrap CTL_Y__PROTO(( void )); #endif #endif #ifndef CTL_Y__NO_UNPUT static void ctp_y_unput CTL_Y__PROTO(( int c, char *buf_ptr )); #endif #ifndef ctp_y_text_ptr static void ctp_y__flex_strncpy CTL_Y__PROTO(( char *, ctp_y_const char *, int )); #endif #ifdef CTL_Y__NEED_STRLEN static int ctp_y__flex_strlen CTL_Y__PROTO(( ctp_y_const char * )); #endif #ifndef CTL_Y__NO_INPUT #ifdef __cplusplus static int ctp_y_input CTL_Y__PROTO(( void )); #else static int input CTL_Y__PROTO(( void )); #endif #endif #if CTL_Y__STACK_USED static int ctp_y__start_stack_ptr = 0; static int ctp_y__start_stack_depth = 0; static int *ctp_y__start_stack = 0; #ifndef CTL_Y__NO_PUSH_STATE static void ctp_y__push_state CTL_Y__PROTO(( int new_state )); #endif #ifndef CTL_Y__NO_POP_STATE static void ctp_y__pop_state CTL_Y__PROTO(( void )); #endif #ifndef CTL_Y__NO_TOP_STATE static int ctp_y__top_state CTL_Y__PROTO(( void )); #endif #else #define CTL_Y__NO_PUSH_STATE 1 #define CTL_Y__NO_POP_STATE 1 #define CTL_Y__NO_TOP_STATE 1 #endif #ifdef CTL_Y__MALLOC_DECL CTL_Y__MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include #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 CTL_Y__READ_BUF_SIZE #define CTL_Y__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( ctp_y_text, ctp_y_leng, 1, ctp_y_out ) #endif /* Gets input and stuffs it into "buf". number of characters read, or CTL_Y__NULL, * is returned in "result". */ #ifndef CTL_Y__INPUT #define CTL_Y__INPUT(buf,result,max_size) \ if ( ctp_y__current_buffer->ctp_y__is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( ctp_y_in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( ctp_y_in ) ) \ CTL_Y__FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else if ( ((result = fread( buf, 1, max_size, ctp_y_in )) == 0) \ && ferror( ctp_y_in ) ) \ CTL_Y__FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "ctp_y_terminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef ctp_y_terminate #define ctp_y_terminate() return CTL_Y__NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef CTL_Y__START_STACK_INCR #define CTL_Y__START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef CTL_Y__FATAL_ERROR #define CTL_Y__FATAL_ERROR(msg) ctp_y__fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef CTL_Y__DECL #define CTL_Y__DECL int ctp_y_lex CTL_Y__PROTO(( void )) #endif /* Code executed at the beginning of each rule, after ctp_y_text and ctp_y_leng * have been set up. */ #ifndef CTL_Y__USER_ACTION #define CTL_Y__USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef CTL_Y__BREAK #define CTL_Y__BREAK break; #endif #define CTL_Y__RULE_SETUP \ CTL_Y__USER_ACTION CTL_Y__DECL { register ctp_y__state_type ctp_y__current_state; register char *ctp_y__cp = NULL, *ctp_y__bp = NULL; register int ctp_y__act; #line 154 "../../../src/ctp/src/ctp_l.l" if ( ctp_y__init ) { ctp_y__init = 0; #ifdef CTL_Y__USER_INIT CTL_Y__USER_INIT; #endif if ( ! ctp_y__start ) ctp_y__start = 1; /* first start state */ if ( ! ctp_y_in ) ctp_y_in = stdin; if ( ! ctp_y_out ) ctp_y_out = stdout; if ( ! ctp_y__current_buffer ) ctp_y__current_buffer = ctp_y__create_buffer( ctp_y_in, CTL_Y__BUF_SIZE ); ctp_y__load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { ctp_y__cp = ctp_y__c_buf_p; /* Support of ctp_y_text. */ *ctp_y__cp = ctp_y__hold_char; /* ctp_y__bp points to the position in ctp_y__ch_buf of the start of * the current run. */ ctp_y__bp = ctp_y__cp; ctp_y__current_state = ctp_y__start; ctp_y__match: do { register CTL_Y__CHAR ctp_y__c = ctp_y__ec[CTL_Y__SC_TO_UI(*ctp_y__cp)]; if ( ctp_y__accept[ctp_y__current_state] ) { ctp_y__last_accepting_state = ctp_y__current_state; ctp_y__last_accepting_cpos = ctp_y__cp; } while ( ctp_y__chk[ctp_y__base[ctp_y__current_state] + ctp_y__c] != ctp_y__current_state ) { ctp_y__current_state = (int) ctp_y__def[ctp_y__current_state]; if ( ctp_y__current_state >= 99 ) ctp_y__c = ctp_y__meta[(unsigned int) ctp_y__c]; } ctp_y__current_state = ctp_y__nxt[ctp_y__base[ctp_y__current_state] + (unsigned int) ctp_y__c]; ++ctp_y__cp; } while ( ctp_y__base[ctp_y__current_state] != 223 ); ctp_y__find_action: ctp_y__act = ctp_y__accept[ctp_y__current_state]; if ( ctp_y__act == 0 ) { /* have to back up */ ctp_y__cp = ctp_y__last_accepting_cpos; ctp_y__current_state = ctp_y__last_accepting_state; ctp_y__act = ctp_y__accept[ctp_y__current_state]; } CTL_Y__DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( ctp_y__act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of CTL_Y__DO_BEFORE_ACTION */ *ctp_y__cp = ctp_y__hold_char; ctp_y__cp = ctp_y__last_accepting_cpos; ctp_y__current_state = ctp_y__last_accepting_state; goto ctp_y__find_action; case 1: CTL_Y__RULE_SETUP #line 155 "../../../src/ctp/src/ctp_l.l" ; CTL_Y__BREAK case 2: CTL_Y__RULE_SETUP #line 156 "../../../src/ctp/src/ctp_l.l" { return(Ampersand); } CTL_Y__BREAK case 3: CTL_Y__RULE_SETUP #line 157 "../../../src/ctp/src/ctp_l.l" { return(Apostrophe); } CTL_Y__BREAK case 4: CTL_Y__RULE_SETUP #line 158 "../../../src/ctp/src/ctp_l.l" { return(LeftParen); } CTL_Y__BREAK case 5: CTL_Y__RULE_SETUP #line 159 "../../../src/ctp/src/ctp_l.l" { return(RightParen); } CTL_Y__BREAK case 6: CTL_Y__RULE_SETUP #line 160 "../../../src/ctp/src/ctp_l.l" { return(Equiv); } CTL_Y__BREAK case 7: CTL_Y__RULE_SETUP #line 161 "../../../src/ctp/src/ctp_l.l" { return(Imply); } CTL_Y__BREAK case 8: CTL_Y__RULE_SETUP #line 162 "../../../src/ctp/src/ctp_l.l" { return(DoubleStar); } CTL_Y__BREAK case 9: CTL_Y__RULE_SETUP #line 163 "../../../src/ctp/src/ctp_l.l" { return(Star); } CTL_Y__BREAK case 10: CTL_Y__RULE_SETUP #line 164 "../../../src/ctp/src/ctp_l.l" { return(Plus); } CTL_Y__BREAK case 11: CTL_Y__RULE_SETUP #line 165 "../../../src/ctp/src/ctp_l.l" { return(Comma); } CTL_Y__BREAK case 12: CTL_Y__RULE_SETUP #line 166 "../../../src/ctp/src/ctp_l.l" { return(Minus); } CTL_Y__BREAK case 13: CTL_Y__RULE_SETUP #line 167 "../../../src/ctp/src/ctp_l.l" { return(VarAsgn); } CTL_Y__BREAK case 14: CTL_Y__RULE_SETUP #line 168 "../../../src/ctp/src/ctp_l.l" { return(Colon); } CTL_Y__BREAK case 15: CTL_Y__RULE_SETUP #line 169 "../../../src/ctp/src/ctp_l.l" { return(Semicolon); } CTL_Y__BREAK case 16: CTL_Y__RULE_SETUP #line 170 "../../../src/ctp/src/ctp_l.l" { return(_LESym); } CTL_Y__BREAK case 17: CTL_Y__RULE_SETUP #line 171 "../../../src/ctp/src/ctp_l.l" { return(_GESym); } CTL_Y__BREAK case 18: CTL_Y__RULE_SETUP #line 172 "../../../src/ctp/src/ctp_l.l" { return(_LTSym); } CTL_Y__BREAK case 19: CTL_Y__RULE_SETUP #line 173 "../../../src/ctp/src/ctp_l.l" { return(_GTSym); } CTL_Y__BREAK case 20: CTL_Y__RULE_SETUP #line 174 "../../../src/ctp/src/ctp_l.l" { return(_EQSym); } CTL_Y__BREAK case 21: CTL_Y__RULE_SETUP #line 175 "../../../src/ctp/src/ctp_l.l" { return(_NESym); } CTL_Y__BREAK case 22: CTL_Y__RULE_SETUP #line 176 "../../../src/ctp/src/ctp_l.l" { return(Arrow); } CTL_Y__BREAK case 23: CTL_Y__RULE_SETUP #line 177 "../../../src/ctp/src/ctp_l.l" { return(Box); } CTL_Y__BREAK case 24: CTL_Y__RULE_SETUP #line 178 "../../../src/ctp/src/ctp_l.l" { return(Bar); } CTL_Y__BREAK case 25: CTL_Y__RULE_SETUP #line 179 "../../../src/ctp/src/ctp_l.l" { return(Bar); } CTL_Y__BREAK case 26: CTL_Y__RULE_SETUP #line 180 "../../../src/ctp/src/ctp_l.l" { return(Dot); } CTL_Y__BREAK case 27: CTL_Y__RULE_SETUP #line 181 "../../../src/ctp/src/ctp_l.l" { return(Slash); } CTL_Y__BREAK case 28: CTL_Y__RULE_SETUP #line 183 "../../../src/ctp/src/ctp_l.l" { int itoken; itoken=find_mc(ctp_y_text); if (itoken== -1) { ctp_y_lval.text = namealloc(ctp_y_text); return ( Identifier ); } else { return ( itoken ); } } CTL_Y__BREAK case 29: CTL_Y__RULE_SETUP #line 196 "../../../src/ctp/src/ctp_l.l" { ctp_y_lval.text = mbkalloc((unsigned int)strlen(ctp_y_text)+1); strcpy(ctp_y_lval.text,ctp_y_text); return ( AbstractLit ); } CTL_Y__BREAK case 30: CTL_Y__RULE_SETUP #line 201 "../../../src/ctp/src/ctp_l.l" { ctp_y_lval.text = namealloc (ctp_y_text); return ( CharacterLit ); } CTL_Y__BREAK case 31: CTL_Y__RULE_SETUP #line 205 "../../../src/ctp/src/ctp_l.l" { ctp_y_lval.text = namealloc (ctp_y_text); return ( StringLit ); } CTL_Y__BREAK case 32: CTL_Y__RULE_SETUP #line 209 "../../../src/ctp/src/ctp_l.l" { ctp_y_lval.text = namealloc (ctp_y_text); return ( BitStringLit ); } CTL_Y__BREAK case 33: CTL_Y__RULE_SETUP #line 213 "../../../src/ctp/src/ctp_l.l" { CTP_LINNUM++; } CTL_Y__BREAK case 34: *ctp_y__cp = ctp_y__hold_char; /* undo effects of setting up ctp_y_text */ ctp_y__c_buf_p = ctp_y__cp -= 1; CTL_Y__DO_BEFORE_ACTION; /* set up ctp_y_text again */ CTL_Y__RULE_SETUP #line 216 "../../../src/ctp/src/ctp_l.l" { /* comment */ /* nothing */ } CTL_Y__BREAK case 35: CTL_Y__RULE_SETUP #line 220 "../../../src/ctp/src/ctp_l.l" { return (*ctp_y_text); } CTL_Y__BREAK case 36: CTL_Y__RULE_SETUP #line 223 "../../../src/ctp/src/ctp_l.l" ECHO; CTL_Y__BREAK case CTL_Y__STATE_EOF(INITIAL): ctp_y_terminate(); case CTL_Y__END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int ctp_y__amount_of_matched_text = (int) (ctp_y__cp - ctp_y_text_ptr) - 1; /* Undo the effects of CTL_Y__DO_BEFORE_ACTION. */ *ctp_y__cp = ctp_y__hold_char; CTL_Y__RESTORE_CTL_Y__MORE_OFFSET if ( ctp_y__current_buffer->ctp_y__buffer_status == CTL_Y__BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed ctp_y_in at a new source and called * ctp_y_lex(). If so, then we have to assure * consistency between ctp_y__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. */ ctp_y__n_chars = ctp_y__current_buffer->ctp_y__n_chars; ctp_y__current_buffer->ctp_y__input_file = ctp_y_in; ctp_y__current_buffer->ctp_y__buffer_status = CTL_Y__BUFFER_NORMAL; } /* Note that here we test for ctp_y__c_buf_p "<=" to the position * of the first EOB in the buffer, since ctp_y__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 ( ctp_y__c_buf_p <= &ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars] ) { /* This was really a NUL. */ ctp_y__state_type ctp_y__next_state; ctp_y__c_buf_p = ctp_y_text_ptr + ctp_y__amount_of_matched_text; ctp_y__current_state = ctp_y__get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * ctp_y__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). */ ctp_y__next_state = ctp_y__try_NUL_trans( ctp_y__current_state ); ctp_y__bp = ctp_y_text_ptr + CTL_Y__MORE_ADJ; if ( ctp_y__next_state ) { /* Consume the NUL. */ ctp_y__cp = ++ctp_y__c_buf_p; ctp_y__current_state = ctp_y__next_state; goto ctp_y__match; } else { ctp_y__cp = ctp_y__c_buf_p; goto ctp_y__find_action; } } else switch ( ctp_y__get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { ctp_y__did_buffer_switch_on_eof = 0; if ( ctp_y_wrap() ) { /* Note: because we've taken care in * ctp_y__get_next_buffer() to have set up * ctp_y_text, we can now set up * ctp_y__c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * CTL_Y__NULL, it'll still work - another * CTL_Y__NULL will get returned. */ ctp_y__c_buf_p = ctp_y_text_ptr + CTL_Y__MORE_ADJ; ctp_y__act = CTL_Y__STATE_EOF(CTL_Y__START); goto do_action; } else { if ( ! ctp_y__did_buffer_switch_on_eof ) CTL_Y__NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: ctp_y__c_buf_p = ctp_y_text_ptr + ctp_y__amount_of_matched_text; ctp_y__current_state = ctp_y__get_previous_state(); ctp_y__cp = ctp_y__c_buf_p; ctp_y__bp = ctp_y_text_ptr + CTL_Y__MORE_ADJ; goto ctp_y__match; case EOB_ACT_LAST_MATCH: ctp_y__c_buf_p = &ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars]; ctp_y__current_state = ctp_y__get_previous_state(); ctp_y__cp = ctp_y__c_buf_p; ctp_y__bp = ctp_y_text_ptr + CTL_Y__MORE_ADJ; goto ctp_y__find_action; } break; } default: CTL_Y__FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of ctp_y_lex */ /* ctp_y__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 ctp_y__get_next_buffer() { register char *dest = ctp_y__current_buffer->ctp_y__ch_buf; register char *source = ctp_y_text_ptr; register int number_to_move, i; int ret_val; if ( ctp_y__c_buf_p > &ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars + 1] ) CTL_Y__FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( ctp_y__current_buffer->ctp_y__fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( ctp_y__c_buf_p - ctp_y_text_ptr - CTL_Y__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) (ctp_y__c_buf_p - ctp_y_text_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( ctp_y__current_buffer->ctp_y__buffer_status == CTL_Y__BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ ctp_y__current_buffer->ctp_y__n_chars = ctp_y__n_chars = 0; else { int num_to_read = ctp_y__current_buffer->ctp_y__buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef CTL_Y__USES_REJECT CTL_Y__FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ CTL_Y__BUFFER_STATE b = ctp_y__current_buffer; int ctp_y__c_buf_p_offset = (int) (ctp_y__c_buf_p - b->ctp_y__ch_buf); if ( b->ctp_y__is_our_buffer ) { int new_size = b->ctp_y__buf_size * 2; if ( new_size <= 0 ) b->ctp_y__buf_size += b->ctp_y__buf_size / 8; else b->ctp_y__buf_size *= 2; b->ctp_y__ch_buf = (char *) /* Include room in for 2 EOB chars. */ ctp_y__flex_realloc( (void *) b->ctp_y__ch_buf, b->ctp_y__buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->ctp_y__ch_buf = 0; if ( ! b->ctp_y__ch_buf ) CTL_Y__FATAL_ERROR( "fatal error - scanner input buffer overflow" ); ctp_y__c_buf_p = &b->ctp_y__ch_buf[ctp_y__c_buf_p_offset]; num_to_read = ctp_y__current_buffer->ctp_y__buf_size - number_to_move - 1; #endif } if ( num_to_read > CTL_Y__READ_BUF_SIZE ) num_to_read = CTL_Y__READ_BUF_SIZE; /* Read in more data. */ CTL_Y__INPUT( (&ctp_y__current_buffer->ctp_y__ch_buf[number_to_move]), ctp_y__n_chars, num_to_read ); ctp_y__current_buffer->ctp_y__n_chars = ctp_y__n_chars; } if ( ctp_y__n_chars == 0 ) { if ( number_to_move == CTL_Y__MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; ctp_y_restart( ctp_y_in ); } else { ret_val = EOB_ACT_LAST_MATCH; ctp_y__current_buffer->ctp_y__buffer_status = CTL_Y__BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; ctp_y__n_chars += number_to_move; ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars] = CTL_Y__END_OF_BUFFER_CHAR; ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars + 1] = CTL_Y__END_OF_BUFFER_CHAR; ctp_y_text_ptr = &ctp_y__current_buffer->ctp_y__ch_buf[0]; return ret_val; } /* ctp_y__get_previous_state - get the state just before the EOB char was reached */ static ctp_y__state_type ctp_y__get_previous_state() { register ctp_y__state_type ctp_y__current_state; register char *ctp_y__cp; ctp_y__current_state = ctp_y__start; for ( ctp_y__cp = ctp_y_text_ptr + CTL_Y__MORE_ADJ; ctp_y__cp < ctp_y__c_buf_p; ++ctp_y__cp ) { register CTL_Y__CHAR ctp_y__c = (*ctp_y__cp ? ctp_y__ec[CTL_Y__SC_TO_UI(*ctp_y__cp)] : 1); if ( ctp_y__accept[ctp_y__current_state] ) { ctp_y__last_accepting_state = ctp_y__current_state; ctp_y__last_accepting_cpos = ctp_y__cp; } while ( ctp_y__chk[ctp_y__base[ctp_y__current_state] + ctp_y__c] != ctp_y__current_state ) { ctp_y__current_state = (int) ctp_y__def[ctp_y__current_state]; if ( ctp_y__current_state >= 99 ) ctp_y__c = ctp_y__meta[(unsigned int) ctp_y__c]; } ctp_y__current_state = ctp_y__nxt[ctp_y__base[ctp_y__current_state] + (unsigned int) ctp_y__c]; } return ctp_y__current_state; } /* ctp_y__try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = ctp_y__try_NUL_trans( current_state ); */ #ifdef CTL_Y__USE_PROTOS static ctp_y__state_type ctp_y__try_NUL_trans( ctp_y__state_type ctp_y__current_state ) #else static ctp_y__state_type ctp_y__try_NUL_trans( ctp_y__current_state ) ctp_y__state_type ctp_y__current_state; #endif { register int ctp_y__is_jam; register char *ctp_y__cp = ctp_y__c_buf_p; register CTL_Y__CHAR ctp_y__c = 1; if ( ctp_y__accept[ctp_y__current_state] ) { ctp_y__last_accepting_state = ctp_y__current_state; ctp_y__last_accepting_cpos = ctp_y__cp; } while ( ctp_y__chk[ctp_y__base[ctp_y__current_state] + ctp_y__c] != ctp_y__current_state ) { ctp_y__current_state = (int) ctp_y__def[ctp_y__current_state]; if ( ctp_y__current_state >= 99 ) ctp_y__c = ctp_y__meta[(unsigned int) ctp_y__c]; } ctp_y__current_state = ctp_y__nxt[ctp_y__base[ctp_y__current_state] + (unsigned int) ctp_y__c]; ctp_y__is_jam = (ctp_y__current_state == 98); return ctp_y__is_jam ? 0 : ctp_y__current_state; } #ifndef CTL_Y__NO_UNPUT #ifdef CTL_Y__USE_PROTOS static void ctp_y_unput( int c, register char *ctp_y__bp ) #else static void ctp_y_unput( c, ctp_y__bp ) int c; register char *ctp_y__bp; #endif { register char *ctp_y__cp = ctp_y__c_buf_p; /* undo effects of setting up ctp_y_text */ *ctp_y__cp = ctp_y__hold_char; if ( ctp_y__cp < ctp_y__current_buffer->ctp_y__ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = ctp_y__n_chars + 2; register char *dest = &ctp_y__current_buffer->ctp_y__ch_buf[ ctp_y__current_buffer->ctp_y__buf_size + 2]; register char *source = &ctp_y__current_buffer->ctp_y__ch_buf[number_to_move]; while ( source > ctp_y__current_buffer->ctp_y__ch_buf ) *--dest = *--source; ctp_y__cp += (int) (dest - source); ctp_y__bp += (int) (dest - source); ctp_y__current_buffer->ctp_y__n_chars = ctp_y__n_chars = ctp_y__current_buffer->ctp_y__buf_size; if ( ctp_y__cp < ctp_y__current_buffer->ctp_y__ch_buf + 2 ) CTL_Y__FATAL_ERROR( "flex scanner push-back overflow" ); } *--ctp_y__cp = (char) c; ctp_y_text_ptr = ctp_y__bp; ctp_y__hold_char = *ctp_y__cp; ctp_y__c_buf_p = ctp_y__cp; } #endif /* ifndef CTL_Y__NO_UNPUT */ #ifndef CTL_Y__NO_INPUT #ifdef __cplusplus static int ctp_y_input() #else static int input() #endif { int c; *ctp_y__c_buf_p = ctp_y__hold_char; if ( *ctp_y__c_buf_p == CTL_Y__END_OF_BUFFER_CHAR ) { /* ctp_y__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 ( ctp_y__c_buf_p < &ctp_y__current_buffer->ctp_y__ch_buf[ctp_y__n_chars] ) /* This was really a NUL. */ *ctp_y__c_buf_p = '\0'; else { /* need more input */ int offset = ctp_y__c_buf_p - ctp_y_text_ptr; ++ctp_y__c_buf_p; switch ( ctp_y__get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because ctp_y__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. */ ctp_y_restart( ctp_y_in ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( ctp_y_wrap() ) return EOF; if ( ! ctp_y__did_buffer_switch_on_eof ) CTL_Y__NEW_FILE; #ifdef __cplusplus return ctp_y_input(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: ctp_y__c_buf_p = ctp_y_text_ptr + offset; break; } } } c = *(unsigned char *) ctp_y__c_buf_p; /* cast for 8-bit char's */ *ctp_y__c_buf_p = '\0'; /* preserve ctp_y_text */ ctp_y__hold_char = *++ctp_y__c_buf_p; return c; } #endif /* CTL_Y__NO_INPUT */ #ifdef CTL_Y__USE_PROTOS void ctp_y_restart( FILE *input_file ) #else void ctp_y_restart( input_file ) FILE *input_file; #endif { if ( ! ctp_y__current_buffer ) ctp_y__current_buffer = ctp_y__create_buffer( ctp_y_in, CTL_Y__BUF_SIZE ); ctp_y__init_buffer( ctp_y__current_buffer, input_file ); ctp_y__load_buffer_state(); } #ifdef CTL_Y__USE_PROTOS void ctp_y__switch_to_buffer( CTL_Y__BUFFER_STATE new_buffer ) #else void ctp_y__switch_to_buffer( new_buffer ) CTL_Y__BUFFER_STATE new_buffer; #endif { if ( ctp_y__current_buffer == new_buffer ) return; if ( ctp_y__current_buffer ) { /* Flush out information for old buffer. */ *ctp_y__c_buf_p = ctp_y__hold_char; ctp_y__current_buffer->ctp_y__buf_pos = ctp_y__c_buf_p; ctp_y__current_buffer->ctp_y__n_chars = ctp_y__n_chars; } ctp_y__current_buffer = new_buffer; ctp_y__load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (ctp_y_wrap()) processing, but the only time this flag * is looked at is after ctp_y_wrap() is called, so it's safe * to go ahead and always set it. */ ctp_y__did_buffer_switch_on_eof = 1; } #ifdef CTL_Y__USE_PROTOS void ctp_y__load_buffer_state( void ) #else void ctp_y__load_buffer_state() #endif { ctp_y__n_chars = ctp_y__current_buffer->ctp_y__n_chars; ctp_y_text_ptr = ctp_y__c_buf_p = ctp_y__current_buffer->ctp_y__buf_pos; ctp_y_in = ctp_y__current_buffer->ctp_y__input_file; ctp_y__hold_char = *ctp_y__c_buf_p; } #ifdef CTL_Y__USE_PROTOS CTL_Y__BUFFER_STATE ctp_y__create_buffer( FILE *file, int size ) #else CTL_Y__BUFFER_STATE ctp_y__create_buffer( file, size ) FILE *file; int size; #endif { CTL_Y__BUFFER_STATE b; b = (CTL_Y__BUFFER_STATE) ctp_y__flex_alloc( sizeof( struct ctp_y__buffer_state ) ); if ( ! b ) CTL_Y__FATAL_ERROR( "out of dynamic memory in ctp_y__create_buffer()" ); b->ctp_y__buf_size = size; /* ctp_y__ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->ctp_y__ch_buf = (char *) ctp_y__flex_alloc( b->ctp_y__buf_size + 2 ); if ( ! b->ctp_y__ch_buf ) CTL_Y__FATAL_ERROR( "out of dynamic memory in ctp_y__create_buffer()" ); b->ctp_y__is_our_buffer = 1; ctp_y__init_buffer( b, file ); return b; } #ifdef CTL_Y__USE_PROTOS void ctp_y__delete_buffer( CTL_Y__BUFFER_STATE b ) #else void ctp_y__delete_buffer( b ) CTL_Y__BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == ctp_y__current_buffer ) ctp_y__current_buffer = (CTL_Y__BUFFER_STATE) 0; if ( b->ctp_y__is_our_buffer ) ctp_y__flex_free( (void *) b->ctp_y__ch_buf ); ctp_y__flex_free( (void *) b ); } #ifdef CTL_Y__USE_PROTOS void ctp_y__init_buffer( CTL_Y__BUFFER_STATE b, FILE *file ) #else void ctp_y__init_buffer( b, file ) CTL_Y__BUFFER_STATE b; FILE *file; #endif { ctp_y__flush_buffer( b ); b->ctp_y__input_file = file; b->ctp_y__fill_buffer = 1; #if CTL_Y__ALWAYS_INTERACTIVE b->ctp_y__is_interactive = 1; #else #if CTL_Y__NEVER_INTERACTIVE b->ctp_y__is_interactive = 0; #else b->ctp_y__is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef CTL_Y__USE_PROTOS void ctp_y__flush_buffer( CTL_Y__BUFFER_STATE b ) #else void ctp_y__flush_buffer( b ) CTL_Y__BUFFER_STATE b; #endif { if ( ! b ) return; b->ctp_y__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->ctp_y__ch_buf[0] = CTL_Y__END_OF_BUFFER_CHAR; b->ctp_y__ch_buf[1] = CTL_Y__END_OF_BUFFER_CHAR; b->ctp_y__buf_pos = &b->ctp_y__ch_buf[0]; b->ctp_y__at_bol = 1; b->ctp_y__buffer_status = CTL_Y__BUFFER_NEW; if ( b == ctp_y__current_buffer ) ctp_y__load_buffer_state(); } #ifndef CTL_Y__NO_SCAN_BUFFER #ifdef CTL_Y__USE_PROTOS CTL_Y__BUFFER_STATE ctp_y__scan_buffer( char *base, ctp_y__size_t size ) #else CTL_Y__BUFFER_STATE ctp_y__scan_buffer( base, size ) char *base; ctp_y__size_t size; #endif { CTL_Y__BUFFER_STATE b; if ( size < 2 || base[size-2] != CTL_Y__END_OF_BUFFER_CHAR || base[size-1] != CTL_Y__END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (CTL_Y__BUFFER_STATE) ctp_y__flex_alloc( sizeof( struct ctp_y__buffer_state ) ); if ( ! b ) CTL_Y__FATAL_ERROR( "out of dynamic memory in ctp_y__scan_buffer()" ); b->ctp_y__buf_size = size - 2; /* "- 2" to take care of EOB's */ b->ctp_y__buf_pos = b->ctp_y__ch_buf = base; b->ctp_y__is_our_buffer = 0; b->ctp_y__input_file = 0; b->ctp_y__n_chars = b->ctp_y__buf_size; b->ctp_y__is_interactive = 0; b->ctp_y__at_bol = 1; b->ctp_y__fill_buffer = 0; b->ctp_y__buffer_status = CTL_Y__BUFFER_NEW; ctp_y__switch_to_buffer( b ); return b; } #endif #ifndef CTL_Y__NO_SCAN_STRING #ifdef CTL_Y__USE_PROTOS CTL_Y__BUFFER_STATE ctp_y__scan_string( ctp_y_const char *ctp_y__str ) #else CTL_Y__BUFFER_STATE ctp_y__scan_string( ctp_y__str ) ctp_y_const char *ctp_y__str; #endif { int len; for ( len = 0; ctp_y__str[len]; ++len ) ; return ctp_y__scan_bytes( ctp_y__str, len ); } #endif #ifndef CTL_Y__NO_SCAN_BYTES #ifdef CTL_Y__USE_PROTOS CTL_Y__BUFFER_STATE ctp_y__scan_bytes( ctp_y_const char *bytes, int len ) #else CTL_Y__BUFFER_STATE ctp_y__scan_bytes( bytes, len ) ctp_y_const char *bytes; int len; #endif { CTL_Y__BUFFER_STATE b; char *buf; ctp_y__size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) ctp_y__flex_alloc( n ); if ( ! buf ) CTL_Y__FATAL_ERROR( "out of dynamic memory in ctp_y__scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = CTL_Y__END_OF_BUFFER_CHAR; b = ctp_y__scan_buffer( buf, n ); if ( ! b ) CTL_Y__FATAL_ERROR( "bad buffer in ctp_y__scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->ctp_y__is_our_buffer = 1; return b; } #endif #ifndef CTL_Y__NO_PUSH_STATE #ifdef CTL_Y__USE_PROTOS static void ctp_y__push_state( int new_state ) #else static void ctp_y__push_state( new_state ) int new_state; #endif { if ( ctp_y__start_stack_ptr >= ctp_y__start_stack_depth ) { ctp_y__size_t new_size; ctp_y__start_stack_depth += CTL_Y__START_STACK_INCR; new_size = ctp_y__start_stack_depth * sizeof( int ); if ( ! ctp_y__start_stack ) ctp_y__start_stack = (int *) ctp_y__flex_alloc( new_size ); else ctp_y__start_stack = (int *) ctp_y__flex_realloc( (void *) ctp_y__start_stack, new_size ); if ( ! ctp_y__start_stack ) CTL_Y__FATAL_ERROR( "out of memory expanding start-condition stack" ); } ctp_y__start_stack[ctp_y__start_stack_ptr++] = CTL_Y__START; BEGIN(new_state); } #endif #ifndef CTL_Y__NO_POP_STATE static void ctp_y__pop_state() { if ( --ctp_y__start_stack_ptr < 0 ) CTL_Y__FATAL_ERROR( "start-condition stack underflow" ); BEGIN(ctp_y__start_stack[ctp_y__start_stack_ptr]); } #endif #ifndef CTL_Y__NO_TOP_STATE static int ctp_y__top_state() { return ctp_y__start_stack[ctp_y__start_stack_ptr - 1]; } #endif #ifndef CTL_Y__EXIT_FAILURE #define CTL_Y__EXIT_FAILURE 2 #endif #ifdef CTL_Y__USE_PROTOS static void ctp_y__fatal_error( ctp_y_const char msg[] ) #else static void ctp_y__fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( CTL_Y__EXIT_FAILURE ); } /* Redefine ctp_y_less() so it works in section 3 code. */ #undef ctp_y_less #define ctp_y_less(n) \ do \ { \ /* Undo effects of setting up ctp_y_text. */ \ ctp_y_text[ctp_y_leng] = ctp_y__hold_char; \ ctp_y__c_buf_p = ctp_y_text + n; \ ctp_y__hold_char = *ctp_y__c_buf_p; \ *ctp_y__c_buf_p = '\0'; \ ctp_y_leng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef ctp_y_text_ptr #ifdef CTL_Y__USE_PROTOS static void ctp_y__flex_strncpy( char *s1, ctp_y_const char *s2, int n ) #else static void ctp_y__flex_strncpy( s1, s2, n ) char *s1; ctp_y_const char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef CTL_Y__NEED_STRLEN #ifdef CTL_Y__USE_PROTOS static int ctp_y__flex_strlen( ctp_y_const char *s ) #else static int ctp_y__flex_strlen( s ) ctp_y_const char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef CTL_Y__USE_PROTOS static void *ctp_y__flex_alloc( ctp_y__size_t size ) #else static void *ctp_y__flex_alloc( size ) ctp_y__size_t size; #endif { return (void *) malloc( size ); } #ifdef CTL_Y__USE_PROTOS static void *ctp_y__flex_realloc( void *ptr, ctp_y__size_t size ) #else static void *ctp_y__flex_realloc( ptr, size ) void *ptr; ctp_y__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 CTL_Y__USE_PROTOS static void ctp_y__flex_free( void *ptr ) #else static void ctp_y__flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if CTL_Y__MAIN int main() { ctp_y_lex(); return 0; } #endif #line 223 "../../../src/ctp/src/ctp_l.l"