FYI: Reply from HP-UX
[git/dscho.git] / flex-2.5.33 / examples / testxxLexer.l
blobe2aed333c57e88a6e169d3c3013ee310d132318c
1         // An example of using the flex C++ scanner class.
3 %option C++ noyywrap
5 %{
6 int mylineno = 0;
7 %}
9 string  \"[^\n"]+\"
11 ws      [ \t]+
13 alpha   [A-Za-z]
14 dig     [0-9]
15 name    ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)*
16 num1    [-+]?{dig}+\.?([eE][-+]?{dig}+)?
17 num2    [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
18 number  {num1}|{num2}
22 {ws}    /* skip blanks and tabs */
24 "/*"            {
25                 int c;
27                 while((c = yyinput()) != 0)
28                         {
29                         if(c == '\n')
30                                 ++mylineno;
32                         else if(c == '*')
33                                 {
34                                 if((c = yyinput()) == '/')
35                                         break;
36                                 else
37                                         unput(c);
38                                 }
39                         }
40                 }
42 {number}        FLEX_STD cout << "number " << YYText() << '\n';
44 \n              mylineno++;
46 {name}          FLEX_STD cout << "name " << YYText() << '\n';
48 {string}        FLEX_STD cout << "string " << YYText() << '\n';
52 int main( int /* argc */, char** /* argv */ )
53         {
54         FlexLexer* lexer = new yyFlexLexer;
55         while(lexer->yylex() != 0)
56                 ;
57         return 0;
58         }