static    char    sccsid[]="%Z% %M% %I% %E% %U%";
/*************************************************/
/*  Program name                                 */
/*       int       col_mn_tr_elseif              */
/* --------------------------------------------- */
/*  (I/O)                                        */
/*       Out        0   :Normal                  */
/*                 -1   :AbNormal                */
/* --------------------------------------------- */
/*  Function :                                   */
/*     Equote no shori.                          */
/* --------------------------------------------- */
/*************************************************/
#include "colmn.h"

extern condList  CLcList;	/* 情報リスト */
extern tableRoot CLtbl;		/* 解析するタグ及び文字が格納される領域*/
extern CLNCB     CLSTCB;	/* タグの構文解析を行うための領域 */

/*********************************************/
/*                                           */
/*********************************************/
int col_mn_tr_else_if()
{
	static int able[]={C_IF,C_ELSEIF};
	static int deny[]={C_ELSE};

	return col_mn_tr_else_ifNode(deny,1,able,2);
}

/*********************************************/
/*                                           */
/*********************************************/
int col_mn_tr_case()
{
	static char *_fn_="col_mn_tr_case";
/*	static int able[]={C_SWITCH,C_CASE};	*/
	static int able[]={C_SWITCH,C_CASE,C_DEFAULT};
	static int deny[]={C_DEFAULT};
	int  rc ,tree;
	Leaf *leaf;

#if 1	/* 2017.03.18 */
	if (rc=cl_tr_end_node_check(deny,0,able,3)) return rc;
#else
	if (rc=cl_tr_end_node_check(deny,1,able,2)) return rc;
#endif

	tree = cl_nest_tag(2);
	if (tree != -1) {
		leaf = CLSTCB.nestLev2;
		if (leaf->cmd.cid==C_SWITCH && leaf->rightleaf) {
			/* %s: SWITCHとCASEの間に文があります。 */
			ERROROUT1(FORMAT(541),_fn_);
			return ECL_TR_ELSEIF;
		}
		else if (!CLcList.cmd.prmnum) {
			ERROROUT1(FORMAT(92),_fn_);	/* %s: 式が必要です */
			return ECL_TR_ELSEIF;
		}
		rc=cl_change_tree(CLSTCB.nestLev2);
/*
printf("col_mn_tr_else_if:cl_change_tree(CLSTCB.nestLev2) rc=%d\n",rc);
*/
		cl_search_nest(2);
	}
	else {
/*
printf("col_mn_tr_else_if:cl_nest_tag(2) tree=%d\n",tree);
*/
		return ECL_TR_ELSEIF;
	}

	if ((rc = cl_tr_gather(0)) >= 0) rc = cl_make_push_leaf();
}

/*********************************************/
/*                                           */
/*********************************************/
int col_mn_tr_catch()
{
	static int able[]={C_TRY,C_CATCH};
	static int deny[]={C_FINALLY};
	int rc;

	if (!(rc=cl_tr_end_node_check(deny,1,able,2))) {
		if ((rc = cl_tr_gather(0)) >= 0) rc = cl_tr_else_nest_check();
	}
	return rc;
}

/*********************************************/
/*                                           */
/*********************************************/
int col_mn_tr_else_ifNode(deny,nd,able,na)
int deny[],nd;
int able[],na;
{
	int rc;

	if (!(rc=cl_tr_end_node_check(deny,1,able,2))) {
		if (!CLcList.cmd.prmnum) {
			ERROROUT1(FORMAT(92),"col_mn_tr_else_if");	/* %s: 式が必要です */
			rc =ECL_TR_ELSEIF;
		}
		else rc = cl_tr_else_nest_check();
	}
	return rc;
}
