forked from devaigergely81/flex-bison-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
while.l
56 lines (52 loc) · 2.49 KB
/
while.l
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%option c++ noyywrap yylineno
%{
#include <iostream>
#include <cstdlib>
#include <list>
#include "implementation.hh"
#include "while.tab.hh"
using namespace yy;
%}
%%
for return parser::token::FOR;
to return parser::token::TO;
program return parser::token::PRG;
begin return parser::token::BEG;
end return parser::token::END;
boolean return parser::token::BOO;
natural return parser::token::NAT;
read return parser::token::REA;
write return parser::token::WRI;
if return parser::token::IF;
then return parser::token::THE;
else return parser::token::ELS;
endif return parser::token::EIF;
while return parser::token::WHI;
do return parser::token::DO;
done return parser::token::DON;
true return parser::token::TRU;
false return parser::token::FAL;
":=" return parser::token::ASN;
"+" return parser::token::ADD;
"-" return parser::token::SUB;
"*" return parser::token::MUL;
"/" return parser::token::DIV;
"%" return parser::token::MOD;
"<" return parser::token::LS;
">" return parser::token::GR;
"<=" return parser::token::LSE;
">=" return parser::token::GRE;
"=" return parser::token::EQ;
and return parser::token::AND;
or return parser::token::OR;
not return parser::token::NOT;
"(" return parser::token::OP;
")" return parser::token::CL;
\: return parser::token::COL;
\? return parser::token::QUE;
"," return parser::token::COM;
[a-zA-Z_][a-zA-Z0-9_]* return parser::token::ID;
[0-9]+ return parser::token::NUM;
[ \t\n]+ // Whitespaces skipped.
#.* // Commens skipped.
. { std::cerr << "Line " << lineno() << ": Unexpected character: '" << YYText() << "'." << std::endl; exit(1); }