-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlex.l
32 lines (31 loc) · 977 Bytes
/
lex.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
%option noyywrap
%{
#include "Parse.tab.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
%}
%%
#[^\n]* {return HASH;}
"[perf_model/l1_icache]" {return ICACHE;}
"[perf_model/l1_dcache]" {return DCACHE;}
"[perf_model/core]" {printf("core\n");return CORE;}
"[perf_model/dram]" {printf("dram\n");return DRAM;}
"perfect" {return PERFECT;}
"false" {return FALSE;}
"true" {return TRUE;}
"cache_size" {return SIZE;}
"associativity" {return ASSOC;}
"replacement_policy" {return REPLACE;}
"writethrough" {return WRITETHROUGH;}
"block_size" {return BSIZE;}
"frequency" {return FREQUENCY;}
"latency" {return LATENCY;}
[0-9]+ {cfgFlval.value = atoi(cfgFtext);return NUMBER;}
"=" {return EQUAL;}
[a-z]+ {cfgFlval.string=strdup(cfgFtext);return REPPolicy;}
([0-9]+)(\.[0-9]+) {cfgFlval.fvalue = atof(cfgFtext);return DECIMAL;}
"\n" {return NEWLINE;}
[ \t] {}
. {cfgFerror("Unknown Character"); exit(0);}
%%