aboutsummaryrefslogtreecommitdiff
path: root/src/primitives.gperf
blob: 230413f9a40d25f4e7c1efa70bd235ab1d48dcd4 (plain) (blame)
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
%compare-strncmp
%includes
%language=ANSI-C
%readonly-tables
%struct-type

%{
#include <stdbool.h>

#include "analyzer.h"
#include "types.h"

#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
%}

struct typeslot { char *name; struct type inner; };
%%
i8,   { TYPE_NUM, {.size =  1, .issigned=true,  .isfloat=false} }
i16,  { TYPE_NUM, {.size =  2, .issigned=true,  .isfloat=false} }
i32,  { TYPE_NUM, {.size =  4, .issigned=true,  .isfloat=false} }
i64,  { TYPE_NUM, {.size =  8, .issigned=true,  .isfloat=false} }
i128, { TYPE_NUM, {.size = 16, .issigned=true,  .isfloat=false} }
int,  { TYPE_NUM, {.size =  8, .issigned=true,  .isfloat=false} }
u8,   { TYPE_NUM, {.size =  1, .issigned=false, .isfloat=false} }
u16,  { TYPE_NUM, {.size =  2, .issigned=false, .isfloat=false} }
u32,  { TYPE_NUM, {.size =  4, .issigned=false, .isfloat=false} }
u64,  { TYPE_NUM, {.size =  8, .issigned=false, .isfloat=false} }
u128, { TYPE_NUM, {.size = 16, .issigned=false, .isfloat=false} }
uint, { TYPE_NUM, {.size =  8, .issigned=false, .isfloat=false} }
rune, { TYPE_NUM ,{.size =  4, .issigned=true,  .isfloat=false} }
f32,  { TYPE_NUM, {.size =  4, .issigned=true,  .isfloat=true } }
f64,  { TYPE_NUM, {.size =  8, .issigned=true,  .isfloat=true } }
%%
const struct type *
typelookup(const uchar *p, size_t len)
{
	const struct typeslot *tp = in_word_set(p, len);
	return tp == NULL ? NULL : &tp->inner;
}