// IfsCmdScan.decl -- Command Scanner Package, IFS version
// Copyright Xerox Corporation 1980

// Last modified February 28, 1980  3:35 PM by Taft

// Derived from: CmdScan.decl -- declarations for Command Scanner Package
//	Last modified July 13, 1977  5:42 PM

get "streams.d"


//---------------------------------------------------------------------------
structure PD:  //Phrase Descriptor
//---------------------------------------------------------------------------
[
iFirst word		//index of first character of phrase
iLast word		//index of phrase terminator
WordBreak word		//word break predicate
PhraseTerminator word	//phrase terminator predicate
Echo word		//echo predicate
catchFrame word		//EnableCatch frame (0 => none)
catchReturn:		//EnableCatch return PC (extended)
   [
   xJmp word		// JMP @.+1 or XJMP n
   xPC word		// real PC
   ]
]
manifest lenPD = size PD/16

//---------------------------------------------------------------------------
structure CS:  //Command State
//---------------------------------------------------------------------------
[
@ST			//defined stream operations
buf word		//-> command buffer
maxChars word		//maximum number of chars in command buffer
iChIn word		//index of next char to put in buffer
iChOut word		//index of next char to take from buffer
putbackChar word	//input character to re-use if nonzero
keyS word		//keyboard (input) stream
dspS word		//display (output) stream
Erase word		//character erasing procedure
zone word		//storage zone
maxPhrases word		//maximum number of phrase descriptors
iPhIn word		//index of phrase being input
iPhOut word		//index of phrase being consumed
iPhTarget word		//index of target phrase for BackupPhrase
errorCode word		//reason for backup (0 => normal reparse)
flags word =
   [
   phraseRead bit	//current output phrase has been read
   reparse bit		//input is being reparsed
   reuse bit		//current phrase is being re-used
   destroy bit		//destroy stream after backup completed
   blank bit 4
   editControl byte	//edit control for current input phrase
   ]
pd↑0,0 @PD		//phrase descriptors (first one is dummy)
]
manifest lenCS = size CS/16  //+ maxPhrases*lenPD

manifest
[
//editControl values
editNew = 1	//next EditPhrase should treat this as new phrase
editAppend = 2	//next EditPhrase should append to this phrase
editReplace = 3	//next EditPhrase should replace this phrase
]

//---------------------------------------------------------------------------
structure Buf↑0,1 byte
//---------------------------------------------------------------------------

manifest
[
//erase context codes
eraseChar = 0
eraseWord = 1
eraseTerminator = 2

//error codes for main CmdScan package
ecEndOfPhrase = 2800
ecCmdDelete = 2801
ecTooManyPhrases = 2802
ecCmdTooLong = 2803

//error codes for CmdScanAux utility procedures
ecEmptyNumber = 2850
ecNonNumericChar = 2851
ecNumberOverflow = 2852
ecCantOpenFile = 2853
ecBadConfirmingChar = 2854
ecKeyNotFound = 2855
ecKeyAmbiguous = 2856

//error codes directing specific backup actions
ecCmdDestroy = 2875
ecBackupAppend = 2876
ecBackupReplace = 2877
]