-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathctokens.l
80 lines (73 loc) · 1.06 KB
/
ctokens.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// C/C++ tokenizer (plain, no Unicode but see below)
%{
#include <stdio.h>
%}
/* may enable %option unicode before the %include to match unicode identifiers for C++11 */
// %option unicode
// import C/C++ token definitions
%include "cdefs.l"
%option flex
%option nodefault
%option fast
%option main
%%
{WHITESPACE}
{ILCOMMENT}
{MLCOMMENT}
{DIRECTIVE} printf("DIRECTIVE %s\n", yytext);
{NAME} printf("NAME %s\n", yytext);
{UFLT} printf("FLOAT %s\n", yytext);
{UINT} printf("INT %s\n", yytext);
{CHAR} printf("CHAR %s\n", yytext);
{STRING} printf("STRING %s\n", yytext);
"{"|"<%" |
"}"|"%>" |
"["|"<:" |
"]"|":>" |
"(" |
")" |
"+=" |
"++" |
"+" |
"-=" |
"--" |
"->*" |
"->" |
"-" |
"==" |
"=" |
"<=" |
"<<=" |
"<<" |
"<" |
">=" |
">>=" |
">>" |
">" |
"!=" |
"!" |
"," |
";" |
"..." |
".*" |
"." |
"^=" |
"^" |
"~" |
"*=" |
"*" |
"/=" |
"/" |
"%=" |
"%" |
"&=" |
"&&" |
"&" |
"|=" |
"||" |
"|" |
"::" |
":" |
"?" printf("PUNCT %s\n", yytext);
. printf("*** ERROR '%s' at line %d\n", yytext, yylineno);
%%