source: trunk/flex/examples/manual/expr.lex@ 3032

Last change on this file since 3032 was 3031, checked in by bird, 18 years ago

flex 2.5.33.

File size: 619 bytes
Line 
1/*
2 * expr.lex : Scanner for a simple
3 * expression parser.
4 */
5
6%{
7#include "y.tab.h"
8
9%}
10
11%%
12
13[0-9]+ { yylval.val = atol(yytext);
14 return(NUMBER);
15 }
16[0-9]+\.[0-9]+ {
17 sscanf(yytext,"%f",&yylval.val);
18 return(NUMBER);
19 }
20"+" return(PLUS);
21"-" return(MINUS);
22"*" return(MULT);
23"/" return(DIV);
24"^" return(EXPON);
25"(" return(LB);
26")" return(RB);
27\n return(EOL);
28[\t ]* /* throw away whitespace */
29. { yyerror("Illegal character");
30 return(EOL);
31 }
32%%
33
34
35
Note: See TracBrowser for help on using the repository browser.