blob: be84321bc423f051f40fa8722f6cc6d72ad8e140 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/* Expression calculator */
%{
#include <string>
#include "parser.hpp"
int current_line = 0;
#define YY_NO_UNISTD_H
%}
/* prevent the lexer from looking for isatty */
%option never-interactive
digit [0-9]
number [1-9]{digit}*
fnumber {digit}+"."{digit}*
ident [a-zA-Z_][a-zA-Z_0-9]*
%%
{number}|{fnumber} { yylval = yytext; return NUMBER; }
{ident} { yylval = yytext; return IDENT; }
"+" { return PLUS; }
"-" { return MINUS; }
"*" { return MULT; }
"/" { return DIV; }
"=" { return ASSIGN; }
"(" { return '('; }
")" { return ')'; }
[ \t] { }
\n { ++current_line; }
%%
int yywrap()
{
return 1;
}
|