Writing a DSL with commands split by space
We want to have a DSL where we can write statements separated with space. Like this:
1
2
3
4
5
6
|
|
outputs
1
2
3
4
5
6
7
8
9
10
|
|
Since separating by space means method invocation in Ruby, we need to hack into method_missing.
I am just posting the codes and will not give it further explanation. Look into the details yourself.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
|
Similar tricks are used in my other Ruby project alda-rb. The codes can be found on GitHub.