-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample4.l
executable file
·39 lines (35 loc) · 1.14 KB
/
example4.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
/******************************************************************************
* @author Nootan Ghimire <[email protected]>
* @project Web Browser in C++ using Bison/Flex
*
* @team Nootan Ghimire - Nishan Bajracharya - Shashi Khanal
*
* @desc This is a lexer file which defines tokens.
*
******************************************************************************
*/
/* The first section: Includes
* Here we include required things
*/
%{
#define YYSTYPE std::string
#include <iostream>
#include <cstring>
#include <string>
/* ^^ For Win-doge users. :P */
using namespace std;
#define YY_DECL extern "C" int yylex()
#include "example4.tab.h"
%}
/* While compiling yacc. do bison -d example4.y so it generates example4.tab.h */
/* Here's where we define things. i.e., rules*/
%%
[<] return LANGLE;
"/>" return CLOSERANGLE;
[>] return RANGLE;
"</" return LANGLE_SLASH;
[]|[a-zA-Z0-9]* yylval=strdup(yytext); return ANYTHING;
\n /* ignore end of line */;
[ \t]+ /* ignore whitespace */;
"<!--".*"-->" /* ignore html comment */
%%