Representation of a simple interpreter. More...
Public Member Functions | |
string | Interpret (int[] tokens) |
Given an array of integer tokens, convert the tokens into a single string of space-delimited words, following simple rules of formatting. | |
Private Member Functions | |
string | _InterpretToken (int token) |
Helper method to convert the token into its corresponding word or punctuation mark. | |
Static Private Attributes | |
const int | PERIOD = 100 |
const int | QUESTION = 101 |
static string[] | _commonwords |
The 40 most common words in English (in order but that doesn't really matter here). A token is nothing more than an index into this list. | |
Representation of a simple interpreter.
This 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:
Definition at line 31 of file Interpreter_Class.cs.
|
inlineprivate |
Helper method to convert the token into its corresponding word or punctuation mark.
token | The token to interpret. |
A string containing the corresponding word or punctuation. If the token is not recognized, the string returns "<UNKNOWN TOKEN #>", where
Definition at line 93 of file Interpreter_Class.cs.
References Interpreter_Class._commonwords, Interpreter_Class.PERIOD, and Interpreter_Class.QUESTION.
Referenced by Interpreter_Class.Interpret().
|
inline |
Given an array of integer tokens, convert the tokens into a single string of space-delimited words, following simple rules of formatting.
tokens | The list of integers to interpret. |
Definition at line 131 of file Interpreter_Class.cs.
References Interpreter_Class._InterpretToken().
Referenced by Interpreter_Exercise.Run().
|
staticprivate |
The 40 most common words in English (in order but that doesn't really matter here). A token is nothing more than an index into this list.
Definition at line 40 of file Interpreter_Class.cs.
Referenced by Interpreter_Class._InterpretToken().
|
staticprivate |
Definition at line 33 of file Interpreter_Class.cs.
Referenced by Interpreter_Class._InterpretToken().
|
staticprivate |
Definition at line 34 of file Interpreter_Class.cs.
Referenced by Interpreter_Class._InterpretToken().