90 if token >= 0
and token < len(Interpreter_Class._commonwords):
91 tokenAsString = Interpreter_Class._commonwords[token]
94 if token == Interpreter_Class.PERIOD:
97 elif token == Interpreter_Class.QUESTION:
101 tokenAsString =
"<UNKNOWN TOKEN {0}>".format(token)
103 return tokenAsString;
116 numTokens = len(tokens)
118 for tokenIndex
in range(0, numTokens):
123 tokenAsString = tokenAsString.title()
124 output.write(tokenAsString)
127 if tokenIndex + 2 < numTokens:
131 return output.getvalue()
Representation of a simple interpreter.
str Interpret(self, list[int] tokens)
Given an array of integer tokens, convert the tokens into a single string of space-delimited words,...
str _InterpretToken(self, int token)
Helper method to convert the token into its corresponding word or punctuation mark.