summaryrefslogtreecommitdiff
path: root/examples/hello_calc2/lex.l
blob: eb58f2304d5520688072a621d5cdae9885c4f86f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%{
#include <stdio.h>

#define yylval calc_lval

#include "parser.h"
%}

%option noyywrap

digit		[0-9]
number		{digit}+\.?|{digit}*\.{digit}+
id			[a-zA-Z]+

%%

[ ]				{ /* Skip spaces. */ }
{number}		{ sscanf (yytext, "%lf", &yylval.value); return NUMBER; }
\n|[-+\/*^()]	{ return yytext[0]; }

%%

YYSTYPE calc_lval;