-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrclang.l
73 lines (55 loc) · 2.42 KB
/
rclang.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
DIGIT [0-9]
NONDIGIT [A-Za-z_]
NONZERO_DIGIT [1-9]
OCTAL_DIGIT [0-7]
DECIMAL_CONSTANT {NONZERO_DIGIT}({DIGIT})*
OCTAL_CONSTANT 0({OCTAL_DIGIT})*
IDENTIFIER {NONDIGIT}({NONDIGIT}|{DIGIT})*
/* Newline and backslash are not allowed either */
STRING_LITERAL \"[^\\"]*\"
WHITESPACE [ \t\n]
%{
#include <stdio.h>
#include "y.tab.h"
%}
%%
register { return REGISTER; }
typedef { return TYPEDEF; }
auto { return AUTO; }
static { return STATIC; }
extern { return EXTERN; }
volatile { return VOLATILE; }
const { return CONST; }
void { return VOID; }
char { return CHAR; }
short { return SHORT; }
int { return INT; }
long { return LONG; }
float { return FLOAT; }
double { return DOUBLE; }
signed { return SIGNED; }
unsigned { return UNSIGNED; }
goto { return GOTO; }
continue { return CONTINUE; }
return { return RETURN; }
break { return BREAK; }
{IDENTIFIER} { return IDENTIFIER; }
{DECIMAL_CONSTANT} { return CONSTANT; }
{OCTAL_CONSTANT} { return CONSTANT; }
{STRING_LITERAL} { return STRING_LITERAL; }
"(" { return '('; }
")" { return ')'; }
"{" { return '{'; }
"}" { return '}'; }
";" { return ';'; }
"*" { return '*'; }
"," { return ','; }
"=" { return '='; }
"." { return '.'; }
"[" { return '['; }
"]" { return ']'; }
"++" { return OP_INC; }
"--" { return OP_DEC; }
"->" { return OP_PTR_PROJ; }
{WHITESPACE} {}
%%