aboutsummaryrefslogtreecommitdiff
path: root/src/primitives.gperf
blob: 09d9b6898f97f32f271d523fc710810e10addb0c (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,  1, true,  false }
i16,  { TYPE_NUM,  2, true,  false }
i32,  { TYPE_NUM,  4, true,  false }
i64,  { TYPE_NUM,  8, true,  false }
i128, { TYPE_NUM, 16, true,  false }
int,  { TYPE_NUM,  8, true,  false }
u8,   { TYPE_NUM,  1, false, false }
u16,  { TYPE_NUM,  2, false, false }
u32,  { TYPE_NUM,  4, false, false }
u64,  { TYPE_NUM,  8, false, false }
u128, { TYPE_NUM, 16, false, false }
uint, { TYPE_NUM,  8, false, false }
rune, { TYPE_NUM , 4, true,  false }
f32,  { TYPE_NUM,  4, true,  true  }
f64,  { TYPE_NUM,  8, true,  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;
}