File: mkopcode_spec.awk

package info (click to toggle)
xcache 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,724 kB
  • sloc: ansic: 8,175; php: 4,557; awk: 285; sh: 135; makefile: 75
file content (46 lines) | stat: -rwxr-xr-x 745 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/awk -f
# vim:ts=4:sw=4
# process eaccelerator/opcodes.c
BEGIN {
	FS=" "
	max = 0;
	started = 0
}

/OPDEF/ {
	if (started) {
		name = "";
		if (match($0, /"([^"]+)"/, m)) { 
			name = m[1]; 
		} 
		sub(/"[^"]*"/, "");
		if (!match($0, /EXT_([^ |]+).*OP[1S]_([^ |]+).*OP2_([^ |]+).*RES_([^ |)]+).*/, array)) {
			print "error" $0
			exit
		}
		id = "";
		if (match($0, /\/\* *([0-9]+) *\*\//, comments)) {
			id = comments[1];
		}
		printf "\tOPSPEC(%10s, %10s, %10s, %10s) /* %s %-30s */\n", array[1], array[2], array[3], array[4], id, name;
		next
	}
}
/^}/ {
	print $0
	exit;
}
/^[ ]*,[ ]*$/ {
	next
}
{
	if (started) {
		print $0
		next
	}
}

/^static/ {
	started = 1;
	print "static const xc_opcode_spec_t xc_opcode_spec[] = {"
}