Design Pattern Examples
Overview of object-oriented design patterns
Interpreter_Class.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __INTERPRETER_CLASS_H__
8#define __INTERPRETER_CLASS_H__
9
10#include <string>
11#include <vector>
12
14{
18 using IntList = std::vector<int>;
19
20
39 {
40 public:
41 const int PERIOD = 100;
42 const int QUESTION = 101;
43
44 private:
49 static const char* _commonwords[];
50
51
60 std::string _InterpretToken(int token);
61
62 public:
63
71 std::string Interpret(IntList tokens);
72 };
73
74} // end namespace
75
76#endif // __INTERPRETER_CLASS_H__
77
Representation of a simple interpreter.
std::string Interpret(IntList tokens)
Given an array of integer tokens, convert the tokens into a single std::string of space-delimited wor...
std::string _InterpretToken(int token)
Helper method to convert the token into its corresponding word or punctuation mark.
static const char * _commonwords[]
The 40 most common words in English (in order but that doesn't really matter here)....
The namespace containing all Design Pattern Examples implemented in C++.
std::vector< int > IntList
Alias to make it easier to work with a vector of vectors of int.