The Interpreter
The Interpreter

The Interpreter

The most common way that a user sends commands to TAME is via text input, usually at some kind of prompt. Stuff like:

	pick up lamp
	look at dog
	scream

This text input is sent through a part of TAME called an interpreter. It's the interpreter's job to parse this input and find significant words and phrases in order to divine a meaningful action.

While the module is a giant accumulation of every element in the world, it also contains what the interpreter is supposed to deem significant, mostly by the author assigning names to actions and objects.

3.1. How TAME Parses Input

No matter the method by which input text is sent to TAME, TAME's interpreter takes the input text and cuts it up into chunks of words called tokens. TAME uses the whitespace between words as the delimiter for these tokens.

For example, the phrase "look at wooden table" would be broken into the tokens "look", "at", "wooden", and "table" before parsing.

TAME always parses input in this manner:

  • Attempt to parse an Action. Then, depending on the kind of action:
  • If the action type is GENERAL,
    • Stop.
  • If the action type is OPEN,
    • Scan the rest of the input. Pass it along with the action.
    • Stop.
  • If the action type is MODAL,
    • Attempt to parse a Mode.
    • Stop.
  • If the action type is TRANSITIVE,
    • Attempt to parse an Object.
    • Stop.
  • If the action type is DITRANSITIVE,
    • Attempt to parse an Object.
    • Attempt to parse a Conjunction.
    • If nothing to parse,
      • Stop.
    • Attempt to parse a second Object.
    • Stop.

TAME's interpreter is a greedy interpreter, and this affects how words and phrases are matched to actions and objects.

3.2. What is a "Greedy" interpreter?

TAME's interpreter is greedy, which means it searches for matches using all of the tokens available. In contrast, a lazy interpreter would stop looking at tokens (and then move on to the next thing to match) the moment that it found a relevant match.

For example, if the input was:

look at wooden table

And "look" and "look at" are actions, and "wooden table" is an object, in a lazy interpreter:

  • Check if "look" is an action.
  • Since it is, stop.
  • Continue parse with "at wooden table".

But in a greedy interpreter:

  • Check if "look" is an action.
  • Since it is, mark "look" as a match.
  • Check if "look at" is an action.
  • Since it is, mark "look at" as a match.
  • Check if "look at wooden" is an action.
  • It is not - continue scan.
  • Check if "look at wooden table" is an action.
  • It is not - continue scan.
  • Reached end of input tokens. Best match for action was "look at".
  • Continue parse with "wooden table"

This greedy scan still happens for each subsequent match, including action modes, conjunctions and accessible objects.

3.3. How an Action gets Processed

Once the interpreter figures out all of the parts of the input, it is bundled into a full action and TAME figures out what blocks to execute. The blocks executed differ depending on context state or action types or target modes or objects with the action.

This documentation has several diagrams that outline this process.

3.4. When the Interpreter Fails Parsing

Sometimes the user will input something that will fail to parse completely or result in an action that is unhandled. This, too is handled in module logic in other blocks. Depending on what parts of the input are either incomplete or unresolvable, different blocks will be called.

If a block does not exist that handles these cases, TAME will add an ERROR cue to the response for the missing block.

This documentation has several diagrams that outline this process.

The Interpreter

The Interpreter

×

Modal Header