#pragma once 
#include "extval.h"


/*
This routine is common to both the Mac and IBM versions, along with parse.c pback.c and putil.c
RAM Nov 91: Test change to eliminate LEPO & compound error.
RAM Jul 90: Made changes for new Pause control.
RAM Mar 90: Made changes for soi, sue, hoi, hue.
RAM Mar 90: Allowed for separation of ICA from I again.
RAM Mar 89: Restored ICA to I and changed Pause() considerably. Renamed
numbered lexemes.
RAM Feb 89: Allowed for separation of ICA from I and RANITAI compounds
RAM Feb 89: Inserted InsZe2() to avoid a required comma in text;
RAM Nov 88: History removed to separate file to which these items will be periodically added.  Allowed for dacine and cousins, as well as nifi and cousins. Also will have to do something about pause.
RAM Jul 87. Boolean was changed from character to integer to avoid problems with signed characters? As a result the call to setmem below had to be changed to clear twice as many bytes */

short freefix(short start,short tlex)

/*This routine separates out freemods for separate parsing by altering the lexemes by multiplication by a multiple of 1000. On entry start is the word number being examined, and tlex a lexeme that must be paired with a second lexeme*/

{	short i,base,nlex,val,j,k;
	val = 0;
	base = addend; /*Addend is global, so is initially 0 */
	for (i = start; i<nwords; ++i) {
		nlex = lexemes[i+1]%1000; /*Next lexeme*/
		switch(lexemes[i]%1000) { /*Switch on current lexeme*/
		case NO4: /*If next is a register marker, NO4 negates it*/
			if (nlex != DIE) lexemes[i] += base;
			else lexemes[i] += addend+1000; /*Increment the lexeme*/
			break;
			
// This segment added June 97 to deal with words like nemouu, which have to be treated as UI

		case NI:
			j = i+1;
			if (lexemes[j]%1000 == NI)  {
				++j;
				while ((k = lexemes [j]%1000) == NI  || k == MA || k == MO) ++j;
				}
			if (k == UI) lexemes[i] += addend +1000;
			else lexemes[i] += base;
			break;
			

/*This group contains single word freemods*/

		case DIE: /*Register marker.*/ 
		case JO:  /*Metaphorizer*/
		case UI:  /*Attitudinal*/
			addend += 1000; /*Increment the addend*/
			++nconts; /*Increment the number of separate parses*/
			lexemes[i] += addend; /*and the lexeme*/
			break;
/*		case GU:
		case GUU1:
			if (tlex == HUE) lexemes[i] += base;
			else lexemes[i++] +=base;
			break;*/
		case KIU: /*Close parenthesis. Return to base level*/
			lexemes[i] += base;
			break;
		case KIE: /*Open parenthesis*/
			addend += 1000;
			++nconts;
			lexemes[i++] += addend;
			i=freefix(i,KIE); /*Parentheses can next freemods. New base*/
			++i; /*Skip over the terminating KIU*/
			break;
		case HUE: /*Addressor of a dialogue item*/
		case SOI:
			addend += 1000;
			++nconts;
			lexemes[i++] += addend;
			i= freefix(i,HUE);
			break;
		case HOI:
			addend += 1000;
			++nconts;
			lexemes[i++] += addend;
			i= freefix(i,HOI);
			break;
		default:
			lexemes[i] += base; /*Maintain at same level*/
			break;
			}
		ppiword = i+1; //Jan95
		val = lexemes[i]%1000;
		if (tlex==HUE &&val==PAUSE&&!PredSign()) return i; //Jan95
		if (tlex==KIE && val==KIU) return i;/*End parenthesis*/
		if (tlex==HUE &&( (val==GU || val==GUU1) ||  val == GI) ||i == nwords-1)) return i; //Dec94 GI Jul 99
		if (tlex==HOI &&( (val==PAUSE || val==GUU1) || i == nwords-1)) return i; //Dec94
		}
	return 0;
	}
		


void LexBreakCPD (char *wd, Boolean *brkmap)	

/* Mark boundaries of component little words in compounded little words. Wd is the compound, brkmap a map of the boundaries. The word is broken according to the rules given in L1 */

{
	short ichar, tlen, first, last;
	
	tlen = strlen (wd);
	memset (brkmap,(short)0,(size_t)tlen*2);
	brkmap[0] = brkmap[tlen] = TRUE;    /* useful boundary conditions */
	for (ichar = 1; ichar < tlen; ++ichar)	/* break on consonants */
	    if (IsCons (wd[ichar])) brkmap[ichar] = TRUE;
	for (ichar = 0; ichar < tlen; ++ichar)
	    if (IsVowel (wd[ichar])) {
		  first = ichar;
		  while (IsVowel (wd[++ichar])) {};
		  last = ichar;	      /* actually points to next C */
		  if (last - first >= 4)   /* mark pairs from right */
			while ((ichar -= 2) > first) brkmap[ichar] = TRUE;
		 else if (last - first == 3) {
			if (first == 0) brkmap[1] = TRUE;
			else if (MatchList (&wd[first], "ai:", "ei:", NULL))
			      brkmap [first + 2] = TRUE; /* consonant name */
			else brkmap [first + 1] = TRUE;
			}
		  else if ((last - first == 1) && !(first &&IsCons(wd[first-1]))) {
		  	if (MatchList (&wd[last], "zi:", "fi:", NULL)){
				brkmap [last] = FALSE;
				brkmap [last + 2] = TRUE; /* vowel name */
				}
			}
		  ichar = last;			  /* pick up at next C */
		  }
	for (ichar = 0; ichar < tlen; ++ichar)
	    if (brkmap[ichar]  &&  !brkmap [ichar + 2]
	       && ((MatchList (&wd[ichar], "noV:", NULL)
	       &&  wd [ichar + 2] != 'i')
	       ||  MatchList (&wd[ichar], "nuu:", NULL)))
		  brkmap [ichar + 2] = TRUE;
	}

void LexOfCPD (char *parts[],short lexeme[],short length)

   /*Given a bounded string of 2 or more lexemes representing the
   partition of a current CPD into its constituent LW-lexemes, 
   this function examines lexemes from the beginning.  If 
   several are to be considered as one, it recompounds them 
   before adding. It then recursively continues the examination
   from the last lexeme added.*/

{	short i,j,tlex,state;
	state = 1; /* Initial condition */
	
/* Certain lexemes [lao, liu + sue] require gobbling of 
subsequent lexemes. If these occur in the string, discard 
subsequent*/

	for (i=0; i<length; ++i) {
		if (!strcmp(parts[i],"lao") || !strcmp(parts[i],"lie")
			|| !strcmp(parts[i],"sue")) {
			for (j=i+1; j<length; ++j) ic -= strlen(parts[j]);
			length = i+1;
			break;
			}
		}
	i = 0; /* Current lexeme pointer */
	lexeme[length] = BAD; /*Enable easy detection of end*/
	while (i<length) {
		switch (state) {
		case 0:
			switch(tlex) {
			case RA: tlex = NI; break;
			case HU: tlex = DA; break;
			case ZO: tlex = PO; break;
			case NOI: tlex = NI; break;
			case KOU: tlex = PA2; break;
				}
			if ((j-i)==1) {
				LAddLex(parts[i],tlex);
				switch(tlex) {
				case LAO: LexLao(); break;
				case SUE: LexSue(); break;
				case LIE: LexLie(); break;
					}
				++i;
				}
			else if (!(j-i)) LAddLex(parts[i],BAD);
			else {
				LAddLex(JoinLex(parts,j,i),tlex);
				i = j;
				}
			state = 1;
			break;
		case 1:
			j = i;
			switch (lexeme[i]) {
			case A4: tlex = A4; state = 12; break;
			case BAD: LAddLex(parts[i],BAD); return;
			case BI: tlex = BI; state = 23; break; //Oct 95
			case CA: tlex = CA; state = 10; break;
			case DA: tlex = DA; state = 7; break;
			case GE: tlex = GE; state = 24; break; // Apr 99
			case I: tlex = I; state = 2; break;
			case IE: tlex = IE; state = 9; break;
			case KA3: tlex = KA3; state = 10; break;
			case KI: tlex = KI; state = 10; break;
			case KOU: tlex = KOU; state = 21; break;
			case LE: tlex = LE; state = 20; break;
			case LIU: tlex = LIU; state =11; break;
			case MA: tlex = NI; state = 5; break;
			case NO4: tlex = NO4; state = 15; break;
			case NOI: tlex = NOI; state = 17; break;
			case NU: tlex = NU; state = 14; break;
			case PA2: tlex = PA2; state = 18; break;
			case NI:
			case RA: tlex = NI; state = 5; break;
			case TAI: tlex = TAI; state = 6; break;
			case MO: tlex = DA; j = i+1; state = 0; break; // Jun 97
			case ZO: tlex = PO; j=i+1; state = 0; break;
			default: 
				state = 0; 
				tlex = lexeme[i]; 
				j = i+1;
				break; /* Lex as individual*/
			}
			break;
		case 2: /* Lexeme I */
			++j;
			switch (lexeme[j]) {
			case NO4:
			case NU: state = 2; break;
			case CI: ++j; tlex = ICI; state = 0; break;
			case MA:
			case FI: tlex = TAI; state = 6; break;
			case GE: ++j; tlex = IGE; state = 0; break;
			case PA2: state = 18; break; 
			case KOU: tlex = ICA; state = 21; break; //Dec 94
//			case ZE1:
			case CA: state = 4; break;
/*			case TAI:
			case NI:
			case ZE1:
			case ZI:
			case ZO:
			case A4:
			case I: state = 6; break;*/
			default: j = i+1; state = 0; break;
			}
			break;
		case 3: //New case 29 Nov 93
			++j;
			switch (lexeme[j]) {
			case NI: state = 5; break;
			default:  tlex = PREDA; state = 0; break;
			}
			break;
		case 4:
			++j;
			switch (lexeme[j]) {
			case NOI: state = 4; break;
			case CI: ++j; tlex = ICI; state = 0; break;
			case GE: ++j; tlex = IGE; state = 0; break;
			default: tlex = ICA, state = 0; break;
				}
			break;
		case 5:
			++j;
			switch (lexeme[j]) {
			case MO: tlex = NI; // Jun 97
			case MA:
			case NI: state = 5; break;
			case TAI: state = 5; break;
			case RA: state = 3; break; // Altered 29 Nov 93
			case JO: ++j; tlex = JO; state = 0; break;
			case PA2:tlex = PA2; state = 18; break;
			case UI: //Jun 97
			case FI: ++j; tlex = UI; state = 0; break;
			case ZO:
			case PO: ++j; tlex = LEPO; state = 0; break;
			case CA: ++j; state = 0; break;
			default: state = 0; break;
				}
			break;
		case 6:
			++j;
			switch (lexeme[j]) {
			case TAI:
			case NI:
//			case ZE1: Jun 97
			case ZI:
			case ZO:
			case A4:
			case I: state = 6; break;
			default:
				if (lexeme[j-1]==MA || lexeme[j-1]==FI) {}
				else if ((j-i) != 1 && lexeme[j-1]) tlex=TAI; 
				state=0; break;
				}
			break;
		case 7:
			++j;
			switch (lexeme[j]) {
			case CI: state = 8; break;
			default: state = 0; break;
				}
			break;
		case 8:
			++j;
			switch (lexeme[j]) {
			case NI: ++j; state = 0; break;
			default: j = i+1; state = 0; break;
				}
			break;
		case 9:
			++j;
			switch (lexeme[j]) {
			case NI: tlex = NI; state = 9; break;
			case RA: ++j; tlex = NI; state = 0; break;
			default: state = 0; break;
				}
			break;
		case 10:
			++j;
			state = 0;
			switch (lexeme[j]) {
			case PA2:
			case NOI:  state = 10; break;
			default: break;
				}
			break;
		case 11:
			++j;
			switch (lexeme[j]) {
			case ZI: ++j; state = 0; break;
			default: state = 0; break;
			}
			break;
		case 12: /* Lexeme A */
			++j;
			switch (lexeme[j]) {
			case NO4:
			case NU: state = 12; break;
			case MA:
			case FI: tlex = TAI; state = 6; break;
			case CI: ++j; tlex = ACI; state = 0; break;
			case GE: ++j; tlex = AGE; state = 0; break;
			case KOU: state = 13; break;
			case PA2: state = 18; break;
			case NOI: state = 12; break;
			default: 
				if (lexeme[j-1]!=NOI && lexeme[j-1] != A4) j = i+1; //Sep 95
				state = 0; break;
			}
			break;
		case 13:
			++j;
			state = 0;
			switch (lexeme[j]) {
			case GE: tlex = AGE; ++j; break;
			case CI: tlex = ACI; ++j; break;
			default: break;
				}
			break;
		case 14:
			++j;
			switch (lexeme[j]) {
			case NU: state = 14; break;	/*Any number of NUs can be compounded */
			case NO4: state = 15; break;
			case KOU: state = 16; break;
			case A4: tlex = A4; state = 12; break; //Sep 95
			case CA: tlex = CA; state = 10; break; //Sep 95
			case KA3: tlex = KA3; state = 10; break; //Sep 95
			case NI: ++j; state = 0; break;
			default: state = 0; break;  //Dec94
				}
			break;
		case 15:
			++j;
			switch (lexeme[j]) {
			case KOU: state = 16; break;
			case A4: tlex = A4; state = 0; ++j; break;
			case CA: tlex = CA; state = 0; ++j; break;
			case JI: tlex = JI; state = 0; ++j; break;  //Nov 96
			case JIO: tlex = JIO; state = 0; ++j; break;  //Nov 96
			case JE: tlex = JE; state = 0; ++j; break;  //Nov 96
			case JUE: tlex = JUE; state = 0; ++j; break;  //Nov 96
			case KI: tlex = KI; state = 0; ++j; break;
			case UI: tlex = UI; state = 0; ++j; break; //Sep 95
			default: j = i+1; state = 0; break;
				}
			break;
		case 16:
			++j;
			switch (lexeme[j]) {
			case KI: ++j; tlex = KA3; state = 0; break;
			case HU: ++j; tlex = UI; state = 0; break;
//			case PA2: ++j; tlex = PA2; state = 18; break; //Dec 94
			default: tlex = PA2; state = 0; break;
				}
			break;
		case 17:
			++j;
			switch (lexeme[j]) {
			case BI: tlex = BI; state = 23; break; //Oct 95
			case NOI:
			case NU: state = 17; break;
			case PA2: tlex = PA2; state = 18; break;
			default: j = i+1; state = 0; break;
				}
			break;
		case 18:
			++j;
			switch (lexeme[j]) {
			case CA: state = 19; break;
			case PA2: state = 18; break;
			case KOU: state = 21; break;
//			case HU: ++j; tlex = UI; state = 0; break;    22 Nov 97
			case ZI: ++j; state = 0; break;
			case CI: if (tlex==A4) tlex = ACI;
					 else if (tlex==I) tlex = ICI;
					 ++j; state = 0; break;
			case GE: if (tlex==A4) tlex = AGE;
					 else if (tlex==I) tlex = IGE;
					 ++j;
			default: state = 0; break;
				}
			break;
		case 19:
			++j;
			switch (lexeme[j]) {
			case NOI: state = 19; break;
			case PA2: state = 18; break;
			default: j=i+1; state = 0; break;
				}
			break;
		case 20:
			++j;
			switch (lexeme[j]) {
			case DA: 
			case TAI: state = 22; break;
			case PA2: state = 18; break;
			case ZO:
			case PO: tlex = LEPO; state = 0; ++j; break;
			default: state = 0; break;
				}
			break;
		case 21:
			++j;
			switch (lexeme[j]) {
			case CA: state = 19; break;
			case PA2: state = 18; break;
			case KOU: state = 21; break;
			case KI: ++j; tlex = KA3; state = 0; break;
//			case HU: ++j; tlex = UI; state = 0; break;  5Dec97 to separate KOU from HU
			case ZI: ++j;
			case CI: if (tlex==A4) tlex = ACI;
					 else if (tlex==I) tlex = ICI;
					 state = 0; break;
			case GE: if (tlex==A4) tlex = AGE;
					 else if (tlex==I) tlex = IGE;
			default: state = 0; break;
				}
			break;
		case 22:
			++j;
			switch (lexeme[j]) {
			case PA2: state = 18; break;  //Added 29 Nov 93
			case I:
			case A4:
			case NI:
			case TAI: state = 22; break;    // Changed 30 Nov 93. Needed for acronyms unless comma used.
			default: state = 0; break;
				}
			break;
		case 23:
			++j;
			switch (lexeme[j]) {
			case BI: state = 23; break;
			default: state = 0; break;
				}
			break;
			
		case 24:
			++j;
			switch (lexeme[j]) {
			case LE:
			case NI: tlex = GE2; state = 0; break;
			default: state = 0; break;
				}
			break;
			}
		}
	
	} /*end LEXOFCPD*/


char *JoinLex(char *parts[],short end,short start)

/* Join count adjacent lexemes in parts into a single lexeme*/

{	static char temp[25], *ptr; /*holds joined lexemes*/
	short i;
	ptr = temp;
	*ptr=0;
	for (i=start; i<end; ++i) {
		strcat(ptr,parts[i]);
		}
	return ptr;
	}




void PreParse(void)	 

/* This function finishes the preparse in these steps:- */

{

/* Gobble LIU-quotes into LIU. LIE-quotes are gobbled by PARSE.C before lexing so they can be anything.*/

	JoinLIU();	   

/* Gobble SOI (attitudinalizer) with the following word*/
		   
//	JoinSOI(); Jun 97

/* Identify and mark freemods for separate parsing*/

	freefix(0,0);

/* Remove all but lexemic pauses */

	Pause();	  
	
/* Replace GUU1 with GUU2 before JI/JIO*/
	InsGuu2();

/* Replace ZE1 with ZE2 before argsign */

	InsZe2();

/* Replace PA2 with PA1 before pred-sign */

	InsM7();

/* Replace KA3 with KA2|KA1 before pred-sign|link */

	InsM3M2();
	InsM7(); /*again to permit PA before kekpreds*/

/* Replace NO4 with NO3|NO2|NO1 before argsign|markpred|PA */

	InsM8M4();	 

/* Replace A4 with A1|A2|A3 before pred|linkargs|argmod respectively.*/

  InsM10M1M6M5M9M11();	
	}


void JoinLIU(void)

/* Join LIU, LIE or LAO with following word. If LIE, SUE or LAO, string already gobbled */

{	PPStart();
	while (PPFindList (LIU, LIE, LAO, SUE,0) > 0) PPJoinNext ("Quote");
	}

void JoinSOI(void)	

/* Join SOI with following word as above */
{				
	PPStart();
	while (PPFindList (SOI, 0) > 0) PPJoinNext ("free");
	}

void Pause(void) 			

/*  A recent change puts pause removal outside of Parse.  If a parse fails because of an unexpected comma, that comma is removed from the lexeme string, and the sentence is reparsed as long as commas cause parse failures.  However, inserted right hand ends must be deleted after a failure before looking for commas, and commas before A must be removed to avoid misparses.*/

{
	short  next, flag;
	
	PPStart(); 
	while ((flag = PPFindList (PAUSE, 0)) > 0) {
		next = PPLexeme (1);
		if (next==A4) PPDelete();
		else PPNext();
		}
	}


void InsM7(void) 				

/* RAM Jan 88. This now replaces PA2 with PA1 when followed by a pred-sign */

{	short curlex, place1,tcont;
	PPStart();
	while ((curlex = PPFindList (PA2, GA2, 0)) > 0) {
		tcont = curlex/1000;
		place1 = PPWhere();
		PPNext();
		if (PredSign()) {
			lexemes[ppmark[place1]] = PA1+tcont*1000;
			leaves[ppmark[place1]]->lexeme = PA1;
			}
		}
	}

void InsM3M2(void)				

/* RAM Jan 88. This routine now replaces KA3 with KA2 or KA1 when followed by a pred-sign or linkargs-sign respectively */

{
	short curlex, place1,tcont;
	Boolean m5,m4;
	
	PPStart();
	while ((curlex = PPFindList (NO4, KA3, 0)) > 0) {
		tcont = curlex/1000;
		place1 = PPWhere();
		PPSkipList (NO4, KA3, 0);
		m4 = (PPLexeme(0)%1000 != PA1);
		if ((m5 = PredSign())
		    || PPLexeme (0) == JE  ||  PPLexeme (0) == JUE) {
			PPGoto (place1);
			repeat {
				curlex = PPLexeme (0)%1000;
				if (curlex == KA3 && m4) { 
					lexemes[ppiword] = (m5 ? KA2+tcont*1000: KA1+tcont*1000);
					leaves[ppiword]->lexeme = (m5 ? KA2 : KA1);
					}
				else if (curlex != NO4 && curlex != KA3) break;
				PPNext();
				}
			}
		}
	}

void InsZe2(void) 

/* This routine replaces ZE1 with ZE2 before argsign */
// Jul95 Replace ZE1 with A2 and A3 before argmods and linkargs.

{	short place1,tcont,curlex;
	PPStart();
	while ((curlex=PPFindList (ZE2, 0)) > 0) {
		tcont = curlex/1000;
		place1 = PPWhere();
		PPNext();
		if (PredSign()) {
			lexemes[ppmark[place1]] = CA+tcont*1000; //Jun 97
			leaves[ppmark[place1]]->lexeme = CA; //Jun 97
			}
		else switch (PPLexeme (0)) {
		case JE:			    /* linkargs-signs and mod-signs */
		case JUE:
		case PA2:
		case NO1:
			lexemes[ppmark[place1]] = A2+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = A2; 
			break;
		case JI:			    /* argmod-signs */
		case JIO:
			lexemes[ppmark[place1]] = A3+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = A3; 
			break;
		default:
			lexemes[ppmark[place1]] = A4+tcont*1000; //Sept 97 replace ZE2 with A4.
			leaves[ppmark[place1]]->lexeme = A4; 
			break;
			}
		}
	}
	
void InsGuu2(void)

/* This routine replaces GUU1 with GUU2 before ji/jio */

{	
	short place1,tcont,curlex;
	PPStart();
	while ((curlex=PPFindList (GUU1, 0)) > 0) {
		tcont = curlex/1000;
		place1 = PPWhere();
		PPNext();
		switch (PPLexeme (0)) {
		case JI:
		case JIO:
			lexemes[ppmark[place1]] = GUU2+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = GUU2; 
			break;
		default:
			break;
			}
		}
	}


void InsM8M4(void)		     

/* Replace NO4 with NO3|NO2|NO1 before argsign|markpred|PA */

{
	short place1,tcont,curlex;
	
	PPStart();
	while ((curlex=PPFindList (NO4, 0)) > 0)
	{	tcont = curlex/1000;
		place1 = PPWhere();
		PPNext();
		if (ArgSign()) {
			lexemes[ppmark[place1]] = NO3+tcont*1000; //Nov 96? /*Aug88 for test*/
			leaves[ppmark[place1]]->lexeme = NO3; 
			}
		else switch (PPLexeme (0))
		{
		case PO:			  /* markpred-signs */
		case ZO:
		case PA1:

/* RAM Jan 88 This was originally M7 PA, but is now PA1. The preceding NO is changed to NO2 instead of inserting M8 */

			lexemes[ppmark[place1]] = NO2+tcont*1000; //Nov 96? 
			leaves[ppmark[place1]]->lexeme = NO2; 
			break;
/*		case KA3:		KA followed by unmarked PA
					  is a mod-sign 
			if (PPLexeme (1) != PA2)
				break;	 anything else terminates (Deleted) */
		case PA2:

/*PA not before pred = mod-sign RAM Jan 88, change preceding NO to NO1 instead of inserting M4  */   

			lexemes[ppmark[place1]] = NO1+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = NO1; 
			break;
			}
		}
	}


void InsM10M1M6M5M9M11(void)	  
			    
/* Replace A4 with A1|A2|A3 before pred|linkargs|argmod respectively. Other insertions formerly in this routine were found unnecessary and deleted. */

{			    
	short found, place1,tcont,curlex;  
	PPStart();
	while ((curlex=PPFindList (A4, ACI, AGE, 0)) > 0)
	{	tcont = curlex/1000;
		found = PPLexeme (0);
		place1 = PPWhere();
		PPNext();
		if (PredSign())

/*RAM Jan88 Instead of inserting M10,M11, and M9, replace A, AGE, and ACI with A1,AGE1,and ACI1. AGE and ACI were reduced to a single lexeme when this change was found unnecessary.*/

		{	if (found == A4) {
				lexemes[ppmark[place1]] = A1+tcont*1000; //Nov 96?
				leaves[ppmark[place1]]->lexeme = A1;
				}
/*		else if (found == AGE)lexemes[ppmark[place1]] = AGE;
			else lexemes[ppmark[place1]] = ACI+tcont*1000; //Nov 96?*/
			}
		else switch (PPLexeme (0))
		{
		case JE:			    /* linkargs-signs and mod-signs */
		case JUE:
		case PA2: //Sep 95
		case NO1: //Sep 95

/* RAM Jan 88. Instead of inserting M1, replace A by A2 */

			lexemes[ppmark[place1]] = A2+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = A2; 
			break;
		case JI:			    /* argmod-signs */
		case JIO:

/* RAM Jan 88 Instead of inserting M6, replace A by A3 */

			lexemes[ppmark[place1]] = A3+tcont*1000; //Nov 96?
			leaves[ppmark[place1]]->lexeme = A3; 
			break;
			}
		}
	}


Boolean ArgSign(void)		       

{
	switch (PPLexeme (0)%1000)
	{
	case DA:
	case HU:
	case IE:
	case KA3:
	case LE:
	case LEPO:
	case LI:
	case LIE:
	case LIO:
	case LIU:
	case NI:
	case DIO:
	case RA:
	case TAI:
	case DJAN:
		return (TRUE);
		}
	return (FALSE);
	}


Boolean PredSign(void)		       

/* Determines if at the beginning of an predicate */

{
	short curplace;
	Boolean psfound;
	
	switch (PPLexeme(0)%1000) {

/* RAM Jan 88 In this table, replace the former M7,M3,and M8 by PA,KA2,and NO2 */
	case CA:
	case CUI:
	case SUE:
	case GE:
	case PA1:
	case KA2:
	case NO2:
	case ME:
	case NU:
	case PO:
	case ZO:
	case PREDA:
		return (TRUE);
	case NO4:
		curplace = PPWhere();
		while (PPNext() == NO4) {};
		psfound = PredSign();
		PPGoto (curplace);
		return (psfound);
	default:
		return (FALSE);
		}
	}


/* End of PREPARSE.C */
