pub fn interpreter_interpret(token_list: &[usize]) -> String
Expand description

This function is a simple interpreter.

The interpreter takes an array of integer tokens and converts each token into a word or punctuation mark. The interpreter then arranges the words into a space-separated list in a single string. In other words, the tokens are converted into a sentence, with the first word capitalized and no space between the last two “words” under the assumption the last word is actually a punctuation mark.

Interpreter Rules:

  1. Each token must be in the range of 0 through 39 (maximum number of words known by the interpreter) or must be 100 (‘.’) or 101 (‘?’).
  2. The word corresponding to the first token is always capitalized.
  3. A single space appears between each word.
  4. No space appears between the last two tokens.

Parameters

  • tokenList

    List of integer tokens to be interpreted. The list is assumed to be terminated by -1 (EOL).

Returns

Returns a new String containing the result of the interpretation.