-- Execute.mesa
-- written by Bill Paxton, May 1981
-- last edit by Bill Paxton, 21-May-81 14:45:04

-- This package implements the Execute command in Tioga

DIRECTORY
Rope,
TextNode;

Execute: DEFINITIONS =
BEGIN
OPEN nodeI:TextNode, ropeI.Rope;

RefTextNode: TYPE = nodeI.RefTextNode;
Card: TYPE = LONG CARDINAL;
NodeList: TYPE = LIST[nodeI.Ref];
Rope: TYPE = ropeI.Ref;

-- ***** Execute

Exec: PROC [keyNode: RefTextNode, keyStart, keyLen: Card, dictList: NodeList]
	RETURNS [foundIt: BOOLEAN, exec: Rope];
	
	-- dictList is a list of dictionaries
	-- looks for key in dictionaries, returns foundIt=FALSE if cannot find the key
	
	-- each dictionary in the list is expected to have entries as top level branches
	-- an entry is a branch of the following form:
	-- <key> is the text of the top node
	-- typename of the top node determines what kind of entry it is
	
	-- if dictionary key has typename = "abbrev" or typename = "",
		-- text of first child node replaces key in keyNode
		-- children of first child node are inserted as children of keyNode
		-- siblings of first child node are inserted as siblings of keyNode
		-- looks of first letter of key are added to looks of expansion text
		-- if key is all uppercase, then
			-- first letter of each word in the expansion is forced uppercase
			-- this is useful for expansion as a title, for example.
			-- key is considered to be all uppercase if it has at least one uppercase
				-- and no lowercase letters
		-- otherwise, if first letter of key is uppercase, then
			-- first letter of expansion is forced uppercase
			-- useful for expansion at start of sentence
	-- if it has typename = "command",
		-- text of first child node is returned to be executed
		-- note that this does not automatically delete the key
	-- no other typenames are currently defined

-- ***** Initialization

Start: PROC; -- for initialization only

END.