next up previous contents index PLPL moodlepserratamodulosperlmonksperldocapuntes LHPgoogleetsiiullpcgull
Sig: Usando Text::Balanced Sup: Construcción de Analizadores Léxicos Ant: La Clase Parse::CLex Err: Si hallas una errata ...

El Módulo Parse::Flex

lhp@nereida:/tmp/Parse-Flex-0.11/t$ cat -n cas.l
 1  %{
 2  #define YY_DECL char* yylex(void)
 3  %}
 4
 5  %pointer
 6  %option yylineno noyywrap
 7
 8  NUM   [0-9]+
 9  WORD  [a-zA-Z][A-Za-z0-9_]*
10  EMAIL ({WORD}[.]?)+[@]({WORD}.)+[a-z]{2,3}
11
12  %%
13  {EMAIL}       return "EMAIL"  ;
14  {NUM}         return "NUM"    ;
15  {WORD}        return "WORD"   ;
16  [a-zA-Z]/\    return "CHAR"   ;
17  \n
18  [\t ]
19  .
20  <<EOF>>       return  ""      ;
21  %%
22
lhp@nereida:/tmp/Parse-Flex-0.11/t$ makelexer.pl cas.l  
lhp@nereida:/tmp/Parse-Flex-0.11/t$ ls -ltr | tail -2
-rw-r--r--  1 lhp lhp  1933 2006-06-28 19:07 Flexer28424.pm
-rwxr-xr-x  1 lhp lhp 38077 2006-06-28 19:07 Flexer28424.so
lhp@nereida:/tmp/Parse-Flex-0.11/t$ perl -MFlexer28424 -de 0
Loading DB routines from perl5db.pl version 1.28
main::(-e:1):   0
  DB<1> $x = gen_walker()
  DB<2> x $x->()
tut@titi.top
0  'EMAIL'
1  'tut@titi.top'
  DB<3> x $x->()
funchal
0  'WORD'
1  'funchal'
  DB<4> x $x->()
432
0  'NUM'
1  432
  DB<5> x $x->()
;
      .:::
fin
0  'WORD'
1  'fin'
  DB<6> q


next up previous contents index PLPL moodlepserratamodulosperlmonksperldocapuntes LHPgoogleetsiiullpcgull
Sig: Usando Text::Balanced Sup: Construcción de Analizadores Léxicos Ant: La Clase Parse::CLex Err: Si hallas una errata ...
Casiano Rodríguez León
2013-03-05