










Sig: Expresiones Regulares en Perl
Sup: Expresiones Regulares en Flex
Ant: Las opciones interactive
Err: Si hallas una errata ...
Las acciones asociadas con los patrones se agrupan en
la rutina de análisis léxico yylex() en una sentencia
switch y se separan mediante llamadas a la
macro YY_BREAK. Asi, al compilar con
flex el siguiente fichero .l
$ cat interactive.l
%%
. printf("::%c",yytext[0]);
\n printf("::%c",yytext[0]);
tenemos el fichero de salida lex.yy.c
que aparece a continuación (hemos omitido
las líneas de código en las que estamos menos interesados,
sustituyendolas por puntos suspensivos)
/* A lexical scanner generated by flex */
....
#define YY_NUM_RULES 3
#line 1 "interactive.l"
#define INITIAL 0
#line 363 "lex.yy.c"
....
YY_DECL {
....
#line 1 "interactive.l"
#line 516 "lex.yy.c"
....
if ( yy_init ) {
yy_init = 0;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! yy_start ) yy_start = 1; /* first start state */
if ( ! yyin ) yyin = stdin;
if ( ! yyout ) yyout = stdout;
if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
yy_load_buffer_state();
}
while ( 1 ) /* loops until end-of-file is reached */ {
............................
yy_match:
do {
.....
}
............
yy_find_action:
............
YY_DO_BEFORE_ACTION;
do_action: /* This label is used only to access EOF actions. */
switch ( yy_act ) { /* beginning of action switch */
case 0:
...................
goto yy_find_action;
case 1:
YY_RULE_SETUP
#line 2 "interactive.l"
printf("::%c",yytext[0]);
YY_BREAK
case 2:
YY_RULE_SETUP
#line 3 "interactive.l"
printf("::%c",yytext[0]);
YY_BREAK
case 3:
YY_RULE_SETUP
#line 4 "interactive.l"
ECHO;
YY_BREAK
#line 614 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
case YY_END_OF_BUFFER:
{ ..... }
default:
YY_FATAL_ERROR("fatal flex scanner internal error--no action found");
} /* end of action switch */
} /* end of scanning one token */
} /* end of yylex */
#if YY_MAIN
int main()
{ yylex(); return 0; }
#endif
#line 4 "interactive.l"
Por defecto, la macro











Sig: Expresiones Regulares en Perl
Sup: Expresiones Regulares en Flex
Ant: Las opciones interactive
Err: Si hallas una errata ...
Casiano Rodríguez León
2012-05-22