#define YY_PROTO(proto) ()
#endif
-%% section 1 definitions go here
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
/* Returned upon end-of-file. */
-#define YY_END_TOK 0
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-%- Standard (non-C++) definition
-/* 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 )
-%+ C++ definition
-#define ECHO LexerOutput( yytext, yyleng )
-%*
-#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) \
-%% fread()/read() definition of YY_INPUT goes here unless we're doing C++
-%+ C++ definition
- if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-%*
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
#define YY_NULL 0
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
/* 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 YY_NEW_FILE yyrestart( yyin )
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-%- Standard (non-C++) definition
-#define YY_DECL int yylex YY_PROTO(( void ))
-%+ C++ definition
-#define YY_DECL int yyFlexLexer::yylex()
-%*
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
#define YY_END_OF_BUFFER_CHAR 0
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
-#endif
-
typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern int yyleng;
int yyleng;
-%% yyin/yyout and (if -l option) yylineno definition & initialization goes here
-
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 1; /* whether we need to initialize */
#define yy_new_buffer yy_create_buffer
-%% declarations of yytext/yytext_ptr (and C++ include, if used) go here
+%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
%- Standard (non-C++) definition
#ifdef __cplusplus
*/
#define YY_DO_BEFORE_ACTION \
yytext_ptr = yy_bp; \
-%% code to fiddle yytext and yyleng for yymore() goes here
+%% code to fiddle yytext and yyleng for yymore() goes here
yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
%% code to copy yytext_ptr to yytext[] goes here, if %array
yy_c_buf_p = yy_cp;
-%% data tables for the DFA go here
+%% data tables for the DFA and the user's section 1 definitions go here
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+/* 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
+%- Standard (non-C++) definition
+/* 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 )
+%+ C++ definition
+#define ECHO LexerOutput( yytext, yyleng )
+%*
+#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) \
+%% fread()/read() definition of YY_INPUT goes here unless we're doing C++
+%+ C++ definition
+ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+%*
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+%- Standard (non-C++) definition
+#define YY_DECL int yylex YY_PROTO(( void ))
+%+ C++ definition
+#define YY_DECL int yyFlexLexer::yylex()
+%*
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
+#endif
YY_DECL
{
*
* action_array - array to hold the rule actions
* action_size - size of action_array
- * prolog - pointer to where the prolog starts in action_array
+ * defs1_offset - index where the user's section 1 definitions start
+ * in action_array
+ * prolog_offset - index where the prolog starts in action_array
* action_offset - index where the non-prolog starts in action_array
* action_index - index where the next action should go, with respect
- * to "action"
- * action - pointer to where non-prolog starts; equal to
- * &action_array[action_offset]
+ * to "action_array"
*/
extern int datapos, dataline, linenum;
extern int num_input_files;
extern char *program_name;
-extern char *action_array, *prolog, *action;
-extern int action_size, action_offset, action_index;
+extern char *action_array;
+extern int action_size;
+extern int defs1_offset, prolog_offset, action_offset, action_index;
/* Variables for stack of states having only one out-transition:
/* Spit out a "# line" statement. */
extern void line_directive_out PROTO((FILE*));
+/* Mark the current position in the action array as the end of the section 1
+ * user defs.
+ */
+extern void mark_defs1 PROTO((void));
+
/* Mark the current position in the action array as the end of the prolog. */
extern void mark_prolog PROTO((void));
extern int myctoi PROTO((char []));
/* Return a printable version of the given character, which might be
- * 8-bit
+ * 8-bit.
*/
extern char *readable_form PROTO((int));
indent_puts( "#define YY_MORE_ADJ 0" );
}
+ fputs( &action_array[defs1_offset], stdout );
+
+ skelout();
+
+ if ( ! C_plus_plus )
+ {
+ if ( use_read )
+ {
+ printf(
+"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\\n" );
+ printf(
+ "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
+ }
+
+ else
+ {
+ printf(
+ "\tif ( yy_current_buffer->is_interactive ) \\\n" );
+ printf(
+ "\t\tresult = (buf[0] = getc( yyin )) == EOF ? 0 : 1; \\\n" );
+ printf(
+"\telse if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0)\\\n" );
+ printf( "\t\t && ferror( yyin ) ) \\\n" );
+ printf(
+ "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
+ }
+ }
+
skelout();
/* Copy prolog to output file. */
- fputs( prolog, stdout );
+ fputs( &action_array[prolog_offset], stdout );
skelout();
skelout();
indent_up();
gen_bu_action();
- fputs( action, stdout );
+ fputs( &action_array[action_offset], stdout );
/* generate cases for any missing EOF rules */
for ( i = 1; i <= lastsc; ++i )
int datapos, dataline, linenum;
FILE *skelfile = NULL;
int skel_ind = 0;
-char *action_array, *prolog, *action;
-int action_size, action_offset, action_index;
+char *action_array;
+int action_size, defs1_offset, prolog_offset, action_offset, action_index;
char *infilename = NULL;
int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
/* Initialize dynamic array for holding the rule actions. */
action_size = 2048; /* default size of action array in bytes */
- prolog = action = action_array =
- allocate_character_array( action_size );
- action_offset = action_index = 0;
+ action_array = allocate_character_array( action_size );
+ defs1_offset = prolog_offset = action_offset = action_index = 0;
+ action_array[0] = '\0';
program_name = argv[0];
{
skelout();
+ line_directive_out( (FILE *) 0 );
+
if ( yyparse() )
{
pinpoint_message( "fatal parse error" );
if ( ddebug )
puts( "\n#define FLEX_DEBUG" );
- skelout();
-
- if ( ! C_plus_plus )
- {
- if ( use_read )
- {
- printf(
-"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\\n" );
- printf(
- "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
- }
-
- else
- {
- printf(
- "\tif ( yy_current_buffer->is_interactive ) \\\n" );
- printf(
- "\t\tresult = (buf[0] = getc( yyin )) == EOF ? 0 : 1; \\\n" );
- printf(
-"\telse if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0)\\\n" );
- printf( "\t\t && ferror( yyin ) ) \\\n" );
- printf(
- "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
- }
- }
-
- skelout();
-
if ( lex_compat )
{
printf( "FILE *yyin = stdin, *yyout = stdout;\n" );
else
printf( "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;\n" );
- skelout();
-
if ( C_plus_plus )
printf( "\n#include \"FlexLexer.h\"\n" );
- line_directive_out( stdout );
-
- if ( useecs )
- numecs = cre8ecs( nextecm, ecgroup, csize );
else
- numecs = csize;
-
- /* Now map the equivalence class for NUL to its expected place. */
- ecgroup[0] = ecgroup[csize];
- NUL_ec = abs( ecgroup[0] );
-
- if ( useecs )
- ccl2ecl();
-
- if ( ! C_plus_plus )
{
if ( yytext_is_array )
{
puts( "#define yytext_ptr yytext" );
}
}
- }
+ if ( useecs )
+ numecs = cre8ecs( nextecm, ecgroup, csize );
+ else
+ numecs = csize;
+
+ /* Now map the equivalence class for NUL to its expected place. */
+ ecgroup[0] = ecgroup[csize];
+ NUL_ec = abs( ecgroup[0] );
+
+ if ( useecs )
+ ccl2ecl();
+ }
/* set_up_initial_allocations - allocate memory for internal tables */
{
int len = strlen( new_text );
- while ( len + action_index + action_offset >= action_size - 10
- /* slop */ )
+ while ( len + action_index >= action_size - 10 /* slop */ )
{
action_size *= 2;
- prolog = action_array =
+ action_array =
reallocate_character_array( action_array, action_size );
- action = &action_array[action_offset];
}
- strcpy( &action[action_index], new_text );
+ strcpy( &action_array[action_index], new_text );
action_index += len;
}
}
+/* mark_defs1 - mark the current position in the action array as
+ * representing where the user's section 1 definitions end
+ * and the prolog begins
+ */
+void mark_defs1()
+ {
+ defs1_offset = 0;
+ action_array[action_index++] = '\0';
+ action_offset = prolog_offset = action_index;
+ action_array[action_index] = '\0';
+ }
+
+
/* mark_prolog - mark the current position in the action array as
- * representing the action prolog
+ * representing the end of the action prolog
*/
void mark_prolog()
{
- prolog = action_array;
action_array[action_index++] = '\0';
action_offset = action_index;
- action = &action_array[action_offset];
- action_index = 0;
- action[action_index] = '\0';
+ action_array[action_index] = '\0';
}
#define ACTION_ECHO add_action( yytext )
#define MARK_END_OF_PROLOG mark_prolog();
-#undef YY_DECL
#define YY_DECL \
int flexscan()
^{WS} indented_code = true; BEGIN(CODEBLOCK);
-^"/*" ECHO; BEGIN(C_COMMENT);
+^"/*" ACTION_ECHO; BEGIN(C_COMMENT);
^"%s"{NAME}? return SCDECL;
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} {
++linenum;
- line_directive_out( stdout );
+ line_directive_out( (FILE *) 0 );
indented_code = false;
BEGIN(CODEBLOCK);
}
^"%%".* {
sectnum = 2;
- line_directive_out( stdout );
bracelevel = 0;
+ mark_defs1();
+ line_directive_out( (FILE *) 0 );
BEGIN(SECT2PROLOG);
return SECTEND;
}
{OPTWS}{NL} ++linenum; return '\n';
-<C_COMMENT>"*/" ECHO; BEGIN(INITIAL);
-<C_COMMENT>"*/".*{NL} ++linenum; ECHO; BEGIN(INITIAL);
-<C_COMMENT>[^*\n]+ ECHO;
-<C_COMMENT>"*" ECHO;
-<C_COMMENT>{NL} ++linenum; ECHO;
+<C_COMMENT>"*/" ACTION_ECHO; BEGIN(INITIAL);
+<C_COMMENT>"*/".*{NL} ++linenum; ACTION_ECHO; BEGIN(INITIAL);
+<C_COMMENT>[^*\n]+ ACTION_ECHO;
+<C_COMMENT>"*" ACTION_ECHO;
+<C_COMMENT>{NL} ++linenum; ACTION_ECHO;
<CODEBLOCK>^"%}".*{NL} ++linenum; BEGIN(INITIAL);
-<CODEBLOCK>"reject" ECHO; CHECK_REJECT(yytext);
-<CODEBLOCK>"yymore" ECHO; CHECK_YYMORE(yytext);
-<CODEBLOCK>{NAME}|{NOT_NAME}|. ECHO;
+<CODEBLOCK>"reject" ACTION_ECHO; CHECK_REJECT(yytext);
+<CODEBLOCK>"yymore" ACTION_ECHO; CHECK_YYMORE(yytext);
+<CODEBLOCK>{NAME}|{NOT_NAME}|. ACTION_ECHO;
<CODEBLOCK>{NL} {
++linenum;
- ECHO;
+ ACTION_ECHO;
if ( indented_code )
BEGIN(INITIAL);
}
if ( bracelevel <= 0 )
{ /* not in %{ ... %} */
yyless( 0 ); /* put it all back */
- MARK_END_OF_PROLOG;
+ mark_prolog();
BEGIN(SECT2);
}
else
<SECT2PROLOG>{NL} ++linenum; ACTION_ECHO;
<SECT2PROLOG><<EOF>> {
- MARK_END_OF_PROLOG;
+ mark_prolog();
sectnum = 0;
yyterminate(); /* to stop the parser */
}