1  %{
 2
 3  #define UNDEFINED   0
 4  #define HCONSTANT   1
 5  #define OCONSTANT   2
 6  #define DCONSTANT   3
 7
 8  %}
 9
10  D           [0-9]
11  O           [0-7]
12  H           [a-fA-F0-9]
13  IS          (u|U|l|L)*
14
15  %%
16  0[xX]{H}+{IS}?   { return HCONSTANT; }
17  0{O}+{IS}?       { return OCONSTANT; }
18  {D}+{IS}?        { return DCONSTANT; }
19  [ \t\n]+
20  .                { return UNDEFINED; }
21  %%
22
23  static char name[4][16] = {
24      "nezname", "sestnactkove", "osmickove", "desitkove"
25  };
26
27  int main() {
28      int token;
29      while (token = yylex()) {
30          printf("Nalezeno %s cislo\n", name[token]);
31      }
32  }