-
Notifications
You must be signed in to change notification settings - Fork 1
/
lang.l
87 lines (77 loc) · 2.4 KB
/
lang.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
81
82
83
84
85
86
87
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ast.h"
#include "lang.tab.h"
extern int yylineno;
%}
%option yylineno
%%
"skibidi" { return SKIBIDI; }
"bussin" { return BUSSIN; }
"flex" { return FLEX; }
"rizz" { return RIZZ; }
"main" { return MAIN; }
"bruh" { return BREAK; }
"sigma" { return CASE; }
"yap" { return CHAR; }
"grimace" { return CONST; }
"grind" { return CONTINUE; }
"based" { return DEFAULT; }
"mewing" { return DO; }
"gigachad" { return DOUBLE; }
"gyatt" { return ENUM; }
"whopper" { return EXTERN; }
"chad" { return FLOAT; }
"cringe" { return GOTO; }
"edging" { return IF; }
"amogus" { return ELSE; }
"giga" { return LONG; }
"edgy" { return REGISTER; }
"soy" { return SHORT; }
"nut" { return SIGNED; }
"maxxing" { return SIZEOF; }
"salty" { return STATIC; }
"gang" { return STRUCT; }
"ohio" { return SWITCH; }
"chungus" { return UNION; }
"nonut" { return UNSIGNED; }
"schizo" { return VOLATILE; }
"goon" { return WHILE; }
"yapping" { return YAPPING; }
"baka" { return BAKA; }
"==" { return EQ; }
"!=" { return NE; }
"<=" { return LE; }
">=" { return GE; }
"&&" { return AND; }
"||" { return OR; }
"<" { return LT; }
">" { return GT; }
"=" { return EQUALS; }
"+" { return PLUS; }
"-" { return MINUS; }
"*" { return TIMES; }
"/" { return DIVIDE; }
"%" { return MOD; }
"(" { return LPAREN; }
")" { return RPAREN; }
"{" { return LBRACE; }
"}" { return RBRACE; }
";" { return SEMICOLON; }
"," { return COMMA; }
":" { return COLON; }
[0-9]+ { yylval.ival = atoi(yytext); return NUMBER; }
[a-zA-Z_][a-zA-Z0-9_]* { yylval.sval = strdup(yytext); return IDENTIFIER; }
\"([^\\\"]|\\.)*\" {
yylval.sval = strdup(yytext + 1);
yylval.sval[strlen(yylval.sval) - 1] = '\0';
return STRING_LITERAL;
}
[ \t\n]+ ; /* Ignore whitespace */
. { /* Ignore unrecognized characters */ }
%%
int yywrap(void) {
return 1;
}