Declaration of the Interpreter_Interpret() function used in the Interpreter Pattern. More...
#include "helpers/dynamicstring.h"
Go to the source code of this file.
Macros | |
#define | __INTERPRETER_INTERPRETER_H__ |
Enumerations | |
enum | { PERIOD = 100 , QUESTION = 101 , EOL = -1 } |
Enum to define constants for tokens. More... | |
Functions | |
bool | Interpreter_Interpret (const int *tokenList, DynamicString *output) |
This function is a simple interpreter. | |
Declaration of the Interpreter_Interpret() function used in the Interpreter Pattern.
Definition in file Interpreter_Interpreter.h.
#define __INTERPRETER_INTERPRETER_H__ |
Definition at line 8 of file Interpreter_Interpreter.h.
anonymous enum |
Enum to define constants for tokens.
Enumerator | |
---|---|
PERIOD | Period. |
QUESTION | Question mark. |
EOL | Marker for end of a token list. |
Definition at line 15 of file Interpreter_Interpreter.h.
bool Interpreter_Interpret | ( | const int * | tokenList, |
DynamicString * | output | ||
) |
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:
tokenList | List of integer tokens to be interpreted. The list is assumed to be terminated by -1 (EOL). |
output | A DynamicString object returning the sentence created through interpreting the tokens. Call DynamicString_Clear() when done with the string. |
Definition at line 117 of file Interpreter_Interpreter.c.
References _InterpretToken(), DynamicString_Append(), EOL, and titlecase().
Referenced by Interpreter_Exercise().