TAME Execution Flow
Initialize:
- FOR each ELEMENT in MODULE,
- If RESOLVE ELEMENT.init(),
- Loop FOR.
- If RESOLVE world.start(),
- Return.
Interpret:
- ACTION = Read action.
- If bad action,
- Else If ACTION type is GENERAL,
- If ACTION is STRICT,
- Enqueue COMMAND(ACTION).
- Else If ACTION type is OPEN,
- If no more tokens,
- OPENSTRING = Accumulate tokens.
- Enqueue COMMAND(ACTION, OPENSTRING).
- Else If ACTION type is MODAL,
- If no more tokens,
- MODE = Read mode.
- If bad mode,
- If ACTION is STRICT,
- Enqueue COMMAND(ACTION, MODE).
- Else If ACTION type is TRANSITIVE,
- If no more tokens,
- OBJECT1 = Read object.
- If best match refers to more than one object,
- Else If unknown object,
- If ACTION is STRICT,
- Enqueue COMMAND(ACTION, OBJECT1).
- Else If ACTION type is DITRANSITIVE,
- If no more tokens,
- OBJECT1 = Read object.
- If best match refers to more than one object,
- Else If unknown object,
- If no more tokens,
- Enqueue COMMAND(ACTION, OBJECT1) (treat as transitive action).
- Else,
- Read conjugate.
- If bad conjugate,
- If no more tokens,
- OBJECT2 = Read object.
- If best match refers to more than one object,
- Else If unknown object,
- Enqueue COMMAND(ACTION, OBJECT1, OBJECT2).
- CALL [Successful Parse].
- Return.
COMMAND Loop:
- WHILE Command Queue is not empty,
- Return.
Process COMMAND:
- ACTION = COMMAND.ACTION.
- If ACTION Type is GENERAL,
- Else If ACTION Type is OPEN,
- Else If ACTION Type is MODAL,
- Else If ACTION Type is TRANSITIVE,
- Else If ACTION Type is DITRANSITIVE,
- Else,
General ACTION:
- If current room is set,
- If current player is set,
- If RESOLVE world.onAction(ACTION),
- Return.
Open ACTION:
- Set local ACTION.TARGET to COMMAND.STRING.
- If current room is set,
- If current player is set,
- If RESOLVE world.onAction(ACTION),
- Return.
Ditransitive ACTION:
- OBJECT1 = COMMAND.OBJECT1.
- OBJECT2 = COMMAND.OBJECT2.
- If ACTION is STRICT,
- If ACTION is REVERSED,
- Else,
- Else,
UNKNOWN Command:
- If current player is set,
- If RESOLVE world.onUnknownCommand(),
- Add ERROR cue: UNKNOWN.
- Return.