#! /bin/sh

# convert listing section:
#pron	0x04E09	1 M
#says	san1 san4
#pron	0x04E09	2 C
#says	saam1 saam3
#pron	0x04E09	3 J
#says	mitsu mitabi
#pron	0x04E09	4 S
#says	san
#pron	0x04E09	5 K
#says	sam
#pron	0x04E09	6 V
#says	tam
#def	0x04E09	9 D
#is	"three"
# into C data table entry:
#	{0x04E09, "san1 san4", "saam1 saam3", "mitsu mitabi", "san", "sam", "tam", "three"},


(
cat <<\/EOS

current=

flush () {
	echo "	{$current, \"$M\", \"$C\", \"$J\", \"$S\", \"$K\", \"$V\", \"$D\"},"
}

checkrec () {
	if [ "$1" != "$current" ]
	then	if [ "$current" != "" ]
		then	flush
		fi
		# initialise record data
		M=
		C=
		J=
		S=
		K=
		V=
		D=
		current=$1
	fi
}

pron () {
	checkrec $1
	tag=$3
}

says () {
	eval $tag=\"$*\"
}

def () {
	checkrec $1
	tag=D
}

is () {
	D="$*"
}

/EOS

cat $1

echo flush

) | sh
