summaryrefslogtreecommitdiff
path: root/source3/aparser/parser.awk
blob: dde43b91a272845058d61a1fb4ad129f102c8ddf (plain)
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
@include basic.awk
@include struct.awk
@include union.awk
@include func.awk

function produce_preamble() {
	printf("#define TEST_STRUCT %s\n", struct_name);
	printf("#define TEST_FUNC %s\n", func_name);
	printf("#define TEST_NAME \"%s\"\n", func_name);
	printf("\n\n");
}


/^module/ {
	module=$2;
	next;
}

/^test/ {
	test=$2;
	next;
}

/^struct/ {
	start_struct($2);
	next;
}

/^[ \t]*union/ {
	start_union($2, $3);
	next;
}

/^[ \t]*case/ {
	split($0,a,"[ \t;]*");
	parse_case(a[3],a[4],a[5]);
	next;
}

/^\};/ {
	end_struct();
	next;
}

/^[ \t]*\}/ {
	end_union();
	next;
}

/^[ \t]*REF/ {
	split($0,a,"[ \t;]*");
	add_elem(a[3],a[4], 1);
	next;
}

/.*;/ {
	split($0,a,"[ \t;]*");
	add_elem(a[2], a[3], 0);
}