summaryrefslogtreecommitdiff
path: root/flex.skl
diff options
context:
space:
mode:
authorManoj Srivastava <srivasta@golden-gryphon.com>2006-02-26 11:25:45 -0800
committerManoj Srivastava <srivasta@golden-gryphon.com>2006-02-26 11:25:45 -0800
commit8b69e240c2db8dd998a1f285a33a9dc7952c5a4d (patch)
treecc09f9873e88f53ad1549606451e5c7c250f8b83 /flex.skl
parent174cabe1a0b3cc6b2a061106f74e9b1c04252eec (diff)
Imported Upstream version 2.5.34
Diffstat (limited to 'flex.skl')
-rw-r--r--flex.skl152
1 files changed, 134 insertions, 18 deletions
diff --git a/flex.skl b/flex.skl
index 683ead6..fabb270 100644
--- a/flex.skl
+++ b/flex.skl
@@ -54,6 +54,34 @@ m4_changequote([[, ]])
%# the generated scanner as a C-style comment. This is to aid those who
%# edit the skeleton.
%#
+
+%not-for-header
+%if-c-only
+%if-not-reentrant
+m4_ifelse(M4_YY_PREFIX,yy,,
+#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]]
+#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]]
+#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]]
+#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]]
+#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]]
+#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]]
+#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]]
+#define yyin M4_YY_PREFIX[[in]]
+#define yyleng M4_YY_PREFIX[[leng]]
+#define yylex M4_YY_PREFIX[[lex]]
+#define yylineno M4_YY_PREFIX[[lineno]]
+#define yyout M4_YY_PREFIX[[out]]
+#define yyrestart M4_YY_PREFIX[[restart]]
+#define yytext M4_YY_PREFIX[[text]]
+#define yywrap M4_YY_PREFIX[[wrap]]
+#define yyalloc M4_YY_PREFIX[[alloc]]
+#define yyrealloc M4_YY_PREFIX[[realloc]]
+#define yyfree M4_YY_PREFIX[[free]]
+)
+%endif
+%endif
+%ok-for-header
+
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION
#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION
@@ -106,6 +134,7 @@ m4preproc_define(`M4_GEN_PREFIX',
M4_GEN_PREFIX(`lex')
M4_GEN_PREFIX(`restart')
M4_GEN_PREFIX(`lex_init')
+ M4_GEN_PREFIX(`lex_init_extra')
M4_GEN_PREFIX(`lex_destroy')
M4_GEN_PREFIX(`get_debug')
M4_GEN_PREFIX(`set_debug')
@@ -200,11 +229,12 @@ m4preproc_include(`flexint.h')
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -302,7 +332,6 @@ m4_define( [[M4_YY_INCR_LINENO]],
}while(0)
]])
-int yylex_init M4_YY_PARAMS(yyscan_t* scanner);
%endif
@@ -412,13 +441,13 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
#define YY_END_OF_BUFFER_CHAR 0
]])
-m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
-[[
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* The state buf must be large enough to hold one state per character in the main buffer.
*/
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
@@ -750,9 +779,16 @@ m4_ifdef( [[M4_YY_NO_UNISTD_H]],,
#endif
]])
+m4_ifdef( [[M4_EXTRA_TYPE_DEFS]],
+[[
+#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS
+]],
+[[
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
+]]
+)
%if-c-only Reentrant structure and macros (non-C++).
%if-reentrant
@@ -793,6 +829,12 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
yy_state_type *yy_state_ptr;
char *yy_full_match;
int yy_lp;
+
+ /* These are only needed for trailing context rules,
+ * but there's no conditional variable for that yet. */
+ int yy_looking_for_trail_begin;
+ int yy_full_lp;
+ int *yy_full_state;
]])
m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]],
@@ -846,6 +888,10 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
]])
]])
+int yylex_init M4_YY_PARAMS(yyscan_t* scanner);
+
+int yylex_init_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
+
%endif
/* Accessor methods to globals.
@@ -1032,7 +1078,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
%endif
%if-c++-only C++ definition
#define ECHO LexerOutput( yytext, yyleng )
@@ -1140,9 +1186,9 @@ m4_ifdef( [[M4_YY_BISON_LVAL]],
m4_dnl The bison pure parser is used. Redefine yylex to
m4_dnl accept the lval parameter.
- m4_define( [[M4_YY_LEX_PROTO]],
+ m4_define( [[M4_YY_LEX_PROTO]], [[\]]
[[M4_YY_PARAMS(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]])
- m4_define( [[M4_YY_LEX_DECLARATION]],
+ m4_define( [[M4_YY_LEX_DECLARATION]], [[\]]
[[YYFARGS1(YYSTYPE *,yylval_param)]])
]])
@@ -1150,9 +1196,9 @@ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
[[
m4_dnl Locations are used. yylex should also accept the ylloc parameter.
- m4_define( [[M4_YY_LEX_PROTO]],
+ m4_define( [[M4_YY_LEX_PROTO]], [[\]]
[[M4_YY_PARAMS(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]])
- m4_define( [[M4_YY_LEX_DECLARATION]],
+ m4_define( [[M4_YY_LEX_DECLARATION]], [[\]]
[[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]])
]])
@@ -1235,6 +1281,8 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
/* Create the reject buffer large enough to save one state per allowed character. */
if ( ! YY_G(yy_state_buf) )
YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_state_buf) )
+ YY_FATAL_ERROR( "out of dynamic memory in yylex()" );
]])
if ( ! YY_G(yy_start) )
@@ -1427,6 +1475,8 @@ do_action: /* This label is used only to access EOF actions. */
%if-c++-only
%not-for-header
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
{
yyin = arg_yyin;
@@ -1447,9 +1497,9 @@ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
yy_start_stack_ptr = yy_start_stack_depth = 0;
yy_start_stack = NULL;
- YY_G(yy_buffer_stack) = 0;
- YY_G(yy_buffer_stack_top) = 0;
- YY_G(yy_buffer_stack_max) = 0;
+ yy_buffer_stack = 0;
+ yy_buffer_stack_top = 0;
+ yy_buffer_stack_max = 0;
m4_ifdef( [[M4_YY_USES_REJECT]],
@@ -1461,13 +1511,18 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
]])
}
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
yyFlexLexer::~yyFlexLexer()
{
delete [] yy_state_buf;
yyfree( yy_start_stack M4_YY_CALL_LAST_ARG );
yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+ yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG );
}
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
{
if ( new_in )
@@ -1629,7 +1684,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- YY_G(yy_n_chars), num_to_read );
+ YY_G(yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars);
}
@@ -1653,6 +1708,15 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
YY_G(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
@@ -2186,6 +2250,9 @@ void yyFlexLexer::yyensure_buffer_stack(void)
YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -2204,6 +2271,8 @@ void yyFlexLexer::yyensure_buffer_stack(void)
(YY_G(yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2262,7 +2331,7 @@ m4_ifdef( [[M4_YY_NO_SCAN_STRING]],,
%if-c-only
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
+ * @param yystr a NUL-terminated string to scan
* M4_YY_DOC_PARAM
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
@@ -2347,8 +2416,7 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
(void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG );
if ( ! YY_G(yy_start_stack) )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
+ YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
}
YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
@@ -2716,7 +2784,51 @@ int yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-%endif
+
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to yyalloc in
+ * the yyextra field.
+ */
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+int yylex_init_extra( yy_user_defined, ptr_yy_globals )
+ YY_EXTRA_TYPE yy_user_defined;
+ yyscan_t* ptr_yy_globals;
+]],
+[[
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
+]])
+{
+ struct yyguts_t dummy_yyguts;
+
+ yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+%endif if-c-only
+
%if-c-only
static int yy_init_globals YYFARGS0(void)
@@ -2954,6 +3066,8 @@ static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *
/* Allocate enough space for the version and name fields */
bytes = th->th_hsize - 14;
th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! th->th_version )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" );
/* we read it all into th_version, and point th_name into that data */
if (fread (th->th_version, 1, bytes, rd->fp) != bytes){
@@ -3033,6 +3147,8 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read
else
/* We point to the address of a pointer. */
*dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! p )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" );
}
/* If it's a struct, we read 2 integers to get one element */