#include "jcabc2ps.h"
#include "parse.h"
#include "prsAnn.h"

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
int prsDeco (void)
{	char *F ="prsDeco";
	int dt, n=0;

	for (;;) {
		dt = 0;
		switch (*P) {
		case '~': dt = DECO_IS_ROLL ? D_ROLL : D_GRACE; break;
		case '.': dt = D_STACC; break;
		case 'J': dt = D_SLIDE; break;
		case 'M': dt = D_EMBAR; break;
		case 'H': dt = D_HOLD; break;
		case 'R': dt = D_ROLL; break;
		case 'T': dt = D_TRILL; break;
		case 'u': dt = D_UPBOW; break;
		case 'v': dt = D_DOWNBOW; break;
//		case '^':		# This doesn't work; it converts all sharps to hats! [jc]
		case 'K': dt = D_HAT; break;
		case 'k': dt = D_ATT; break;
		case '!':
		case '+':
			V5 "%s: Deco !%4s ...\n",F,P V;
			if (prsAnn()) {	// prsAnn will call addDeco if it finds a decoration
							// and will return true if it finds any sort of annotation at all
                continue;
//			V5 "%s: Deco %d type %d=%s.\n",F,decos,dt,annname[dt].value V;
            } else {		// not a valid annotation, the list of decorations must be done
                break;
            }
		}
		if (dt) {
//			V5 "%s: DECO %d is type %d.\n",F,decos,dt V;
			P++;
            addDeco (dt);
			n++;
		} else {
			break;
		}
	}
//	V3 "%s: %d decos found, %d total.\n",F,n,decos V;
	return n;
}
