Skip to content

Commit 602d4a1

Browse files
committed
add info to interpreter man
1 parent 39dfd96 commit 602d4a1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

--wait

Whitespace-only changes.

Interpreter/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@ class Program
99
{
1010
static void Main(string[] args)
1111
{
12+
/*
13+
* more info: https://sourcemaking.com/design_patterns/interpreter
14+
* https://www.codeproject.com/Articles/186183/Interpreter-Design-Pattern
15+
Intent
16+
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
17+
Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design.
18+
19+
Problem
20+
A class of problems occurs repeatedly in a well-defined and well-understood domain.
21+
If the domain were characterized with a "language",
22+
then problems could be easily solved with an interpretation "engine".
23+
*/
24+
1225
string tokenString = "+ - 10 2 3";
13-
List<string> tokenList = new List<string>(tokenString.Split(' '));
26+
var tokenList = new List<string>(tokenString.Split(' '));
1427

1528
IExpression expression = new TokenReader().ReadToken(tokenList);
1629
Console.WriteLine(expression.Interpret()); // (10 - 2) + 3 = 11

0 commit comments

Comments
 (0)