matthewtodd-doily 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/features/chef_nodes.feature +9 -1
- data/features/chef_openid_registrations.feature +9 -1
- data/features/chef_roles.feature +11 -3
- data/features/steps/chef.rb +6 -3
- data/features/support/helpers.rb +11 -1
- data/lib/doily/parser.rb +188 -170
- data/lib/doily/parser.y +7 -4
- data/test/{doily_function_test.rb → doily_test.rb} +32 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'cucumber/rake/task'
|
|
5
5
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = 'doily'
|
8
|
-
s.version = '0.1.
|
8
|
+
s.version = '0.1.2'
|
9
9
|
s.summary = 'A Javascript (function) interpreter for Ruby.'
|
10
10
|
s.files = FileList['Rakefile', '*.rdoc', 'features/**/*', 'lib/**/*', 'test/**/*'].to_a
|
11
11
|
s.rdoc_options = %W[--main README.rdoc --title #{s.name}-#{s.version} --inline-source --line-numbers --all]
|
data/features/chef_nodes.feature
CHANGED
@@ -11,10 +11,18 @@ Feature: Chef Nodes
|
|
11
11
|
| 'node' | 'thulucandra' | { 'fqdn' => 'thulucandra.example.com' } | nil |
|
12
12
|
| 'openid_registration' | 'glarb_example_com' | 'do not matter' | 'does not matter' |
|
13
13
|
|
14
|
+
Scenario: Parsing the Node Design Document
|
15
|
+
When I parse the design document for 'Node'
|
16
|
+
Then I should see
|
17
|
+
| key |
|
18
|
+
| 'language' |
|
19
|
+
| 'version' |
|
20
|
+
| 'views' |
|
21
|
+
|
14
22
|
Scenario: Coverage
|
15
23
|
When I list all the views for 'Node'
|
16
24
|
Then I should see
|
17
|
-
|
|
25
|
+
| key |
|
18
26
|
| 'all' |
|
19
27
|
| 'all_id' |
|
20
28
|
| 'by_run_list' |
|
@@ -10,10 +10,18 @@ Feature: Chef OpenID Registrations
|
|
10
10
|
| 'openid_registration' | 'validated_org' | true |
|
11
11
|
| 'role' | 'foo' | 'does not matter' |
|
12
12
|
|
13
|
+
Scenario: Parsing the OpenIDRegistration Design Document
|
14
|
+
When I parse the design document for 'OpenIDRegistration'
|
15
|
+
Then I should see
|
16
|
+
| key |
|
17
|
+
| 'language' |
|
18
|
+
| 'version' |
|
19
|
+
| 'views' |
|
20
|
+
|
13
21
|
Scenario: Coverage
|
14
22
|
When I list all the views for 'OpenIDRegistration'
|
15
23
|
Then I should see
|
16
|
-
|
|
24
|
+
| key |
|
17
25
|
| 'all' |
|
18
26
|
| 'all_id' |
|
19
27
|
| 'unvalidated' |
|
data/features/chef_roles.feature
CHANGED
@@ -10,12 +10,20 @@ Feature: Chef Roles
|
|
10
10
|
| 'role' | 'database server' |
|
11
11
|
| 'openid_registration' | 'glarb_example_com' |
|
12
12
|
|
13
|
+
Scenario: Parsing the Role Design Document
|
14
|
+
When I parse the design document for 'Role'
|
15
|
+
Then I should see
|
16
|
+
| key |
|
17
|
+
| 'language' |
|
18
|
+
| 'version' |
|
19
|
+
| 'views' |
|
20
|
+
|
13
21
|
Scenario: Coverage
|
14
22
|
When I list all the views for 'Role'
|
15
23
|
Then I should see
|
16
|
-
|
|
17
|
-
| 'all'
|
18
|
-
| 'all_id'
|
24
|
+
| key |
|
25
|
+
| 'all' |
|
26
|
+
| 'all_id' |
|
19
27
|
|
20
28
|
Scenario: Getting all Roles
|
21
29
|
When I get the 'all' view for 'Role'
|
data/features/steps/chef.rb
CHANGED
@@ -3,9 +3,12 @@ Given /^these documents$/ do |table|
|
|
3
3
|
@documents = table.hashes
|
4
4
|
end
|
5
5
|
|
6
|
+
When /^I parse the design document for '(.+)'$/ do |klass|
|
7
|
+
@results = sorted_keys(Doily(chef_design_document(klass).to_json))
|
8
|
+
end
|
9
|
+
|
6
10
|
When /^I list all the views for '(.+)'$/ do |klass|
|
7
|
-
@results =
|
8
|
-
chef_view_functions(klass).keys.sort.each { |key| @results.push('name' => key)}
|
11
|
+
@results = sorted_keys(chef_view_functions(klass))
|
9
12
|
end
|
10
13
|
|
11
14
|
When /^I get the '(.+)' view for '(.+)'$/ do |name, klass|
|
@@ -17,4 +20,4 @@ end
|
|
17
20
|
Then /^I should see$/ do |table|
|
18
21
|
evaluate_table_values(table)
|
19
22
|
@results.should == table.hashes
|
20
|
-
end
|
23
|
+
end
|
data/features/support/helpers.rb
CHANGED
@@ -14,8 +14,12 @@ class CouchDBView
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def chef_design_document(klass)
|
18
|
+
Chef.const_get(klass)::DESIGN_DOCUMENT
|
19
|
+
end
|
20
|
+
|
17
21
|
def chef_view_functions(klass)
|
18
|
-
|
22
|
+
chef_design_document(klass).fetch('views')
|
19
23
|
end
|
20
24
|
|
21
25
|
def chef_view(klass, name)
|
@@ -25,3 +29,9 @@ end
|
|
25
29
|
def evaluate_table_values(table)
|
26
30
|
table.raw[0].each { |column| table.map_column!(column) { |value| eval(value) }}
|
27
31
|
end
|
32
|
+
|
33
|
+
def sorted_keys(hash)
|
34
|
+
results = []
|
35
|
+
hash.keys.sort.each { |key| results.push('key' => key)}
|
36
|
+
results
|
37
|
+
end
|
data/lib/doily/parser.rb
CHANGED
@@ -13,7 +13,7 @@ module Doily
|
|
13
13
|
|
14
14
|
class Parser < Racc::Parser
|
15
15
|
|
16
|
-
module_eval <<'..end lib/doily/parser.y modeval..
|
16
|
+
module_eval <<'..end lib/doily/parser.y modeval..idcb4ebcabfd', 'lib/doily/parser.y', 116
|
17
17
|
|
18
18
|
def self.parse(string)
|
19
19
|
new.parse(string)
|
@@ -47,11 +47,13 @@ module_eval <<'..end lib/doily/parser.y modeval..id2fd58564af', 'lib/doily/parse
|
|
47
47
|
@tokens.push [m, m]
|
48
48
|
when m = scanner.scan(/[a-zA-Z_]+/)
|
49
49
|
@tokens.push [:IDENTIFIER, m]
|
50
|
-
when m = scanner.scan(/"([^"])*"/)
|
50
|
+
when m = scanner.scan(/"(?:\\.|[^"])*"/)
|
51
51
|
@tokens.push [:STRING_LITERAL, m]
|
52
|
-
when m = scanner.scan(/'([^'])*'/)
|
52
|
+
when m = scanner.scan(/'(?:\\.|[^'])*'/)
|
53
53
|
@tokens.push [:STRING_LITERAL, m]
|
54
|
-
when m = scanner.scan(
|
54
|
+
when m = scanner.scan(/(?:-)?\d+\.\d+/)
|
55
|
+
@tokens.push [:FLOATING_POINT_LITERAL, m]
|
56
|
+
when m = scanner.scan(/(?:-)?\d+/)
|
55
57
|
@tokens.push [:INTEGER_LITERAL, m]
|
56
58
|
else
|
57
59
|
raise ParseError.new(scanner)
|
@@ -65,146 +67,153 @@ module_eval <<'..end lib/doily/parser.y modeval..id2fd58564af', 'lib/doily/parse
|
|
65
67
|
def next_token
|
66
68
|
@tokens.shift
|
67
69
|
end
|
68
|
-
..end lib/doily/parser.y modeval..
|
70
|
+
..end lib/doily/parser.y modeval..idcb4ebcabfd
|
69
71
|
|
70
72
|
##### racc 1.4.5 generates ###
|
71
73
|
|
72
74
|
racc_reduce_table = [
|
73
75
|
0, 0, :racc_error,
|
74
|
-
1,
|
75
|
-
3,
|
76
|
-
5,
|
77
|
-
0,
|
78
|
-
1,
|
79
|
-
3,
|
80
|
-
2,
|
81
|
-
3,
|
82
|
-
1,
|
83
|
-
2,
|
84
|
-
1,
|
85
|
-
1,
|
86
|
-
2,
|
87
|
-
5,
|
88
|
-
7,
|
89
|
-
9,
|
90
|
-
1, 34, :_reduce_none,
|
91
|
-
1, 34, :_reduce_none,
|
92
|
-
1, 34, :_reduce_none,
|
93
|
-
1, 34, :_reduce_none,
|
94
|
-
1, 34, :_reduce_none,
|
76
|
+
1, 26, :_reduce_none,
|
77
|
+
3, 26, :_reduce_2,
|
78
|
+
5, 27, :_reduce_3,
|
79
|
+
0, 29, :_reduce_4,
|
80
|
+
1, 29, :_reduce_5,
|
81
|
+
3, 29, :_reduce_6,
|
82
|
+
2, 30, :_reduce_7,
|
83
|
+
3, 30, :_reduce_8,
|
84
|
+
1, 31, :_reduce_9,
|
85
|
+
2, 31, :_reduce_10,
|
86
|
+
1, 32, :_reduce_none,
|
87
|
+
1, 32, :_reduce_none,
|
88
|
+
2, 32, :_reduce_none,
|
89
|
+
5, 33, :_reduce_14,
|
90
|
+
7, 33, :_reduce_15,
|
91
|
+
9, 34, :_reduce_16,
|
95
92
|
1, 35, :_reduce_none,
|
96
|
-
1, 35, :_reduce_23,
|
97
|
-
1, 35, :_reduce_24,
|
98
93
|
1, 35, :_reduce_none,
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
1,
|
94
|
+
1, 35, :_reduce_none,
|
95
|
+
1, 35, :_reduce_none,
|
96
|
+
1, 35, :_reduce_none,
|
97
|
+
1, 36, :_reduce_none,
|
98
|
+
1, 36, :_reduce_23,
|
99
|
+
1, 36, :_reduce_24,
|
100
|
+
1, 36, :_reduce_25,
|
101
|
+
1, 36, :_reduce_none,
|
102
|
+
3, 36, :_reduce_27,
|
103
|
+
3, 36, :_reduce_28,
|
104
|
+
3, 36, :_reduce_29,
|
105
|
+
4, 36, :_reduce_30,
|
106
|
+
4, 36, :_reduce_31,
|
105
107
|
1, 41, :_reduce_32,
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
3,
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
3,
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
108
|
+
1, 42, :_reduce_33,
|
109
|
+
0, 28, :_reduce_34,
|
110
|
+
1, 28, :_reduce_35,
|
111
|
+
3, 28, :_reduce_36,
|
112
|
+
3, 45, :_reduce_37,
|
113
|
+
0, 43, :_reduce_38,
|
114
|
+
1, 43, :_reduce_39,
|
115
|
+
3, 43, :_reduce_40,
|
116
|
+
0, 44, :_reduce_41,
|
117
|
+
1, 44, :_reduce_42,
|
118
|
+
3, 44, :_reduce_43,
|
119
|
+
3, 38, :_reduce_44,
|
120
|
+
2, 37, :_reduce_45,
|
121
|
+
3, 39, :_reduce_46,
|
122
|
+
2, 40, :_reduce_47 ]
|
123
|
+
|
124
|
+
racc_reduce_n = 48
|
125
|
+
|
126
|
+
racc_shift_n = 88
|
124
127
|
|
125
128
|
racc_action_table = [
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
23,
|
133
|
-
|
134
|
-
21,
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
129
|
+
42, 1, 46, 47, 23, 24, 9, 28, 20, 79,
|
130
|
+
21, 63, 2, 64, 60, 42, 25, 46, 47, 23,
|
131
|
+
24, 9, 28, 20, 33, 21, 43, 65, 34, 71,
|
132
|
+
35, 25, 47, 23, 24, 9, 28, 20, 33, 21,
|
133
|
+
66, 67, 34, 59, 35, 25, 47, 23, 24, 9,
|
134
|
+
28, 20, 33, 21, 69, 57, 34, 53, 35, 25,
|
135
|
+
47, 23, 24, 9, 28, 20, 33, 21, 58, 9,
|
136
|
+
34, 12, 35, 25, 47, 23, 24, 9, 28, 20,
|
137
|
+
70, 21, 29, 9, 18, 17, 60, 25, 47, 23,
|
138
|
+
24, 9, 28, 20, 33, 21, 16, 15, 34, 14,
|
139
|
+
35, 25, 47, 23, 24, 9, 28, 20, 13, 21,
|
140
|
+
23, 24, 9, 28, 20, 25, 21, 23, 24, 9,
|
141
|
+
28, 20, 25, 21, 23, 24, 9, 28, 20, 25,
|
142
|
+
21, 23, 24, 9, 28, 20, 25, 21, 23, 24,
|
143
|
+
9, 28, 20, 25, 21, 23, 24, 9, 28, 20,
|
144
|
+
25, 21, 62, 86, 29, 33, 78, 25, 12, 34,
|
145
|
+
60, 35, 61, 60, 83, 82, 10, 60, 29, 60,
|
146
|
+
9, 5, 29 ]
|
142
147
|
|
143
148
|
racc_action_check = [
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
149
|
+
52, 0, 52, 52, 52, 52, 52, 52, 52, 76,
|
150
|
+
52, 42, 0, 46, 76, 29, 52, 29, 29, 29,
|
151
|
+
29, 29, 29, 29, 56, 29, 29, 47, 56, 56,
|
152
|
+
56, 29, 79, 79, 79, 79, 79, 79, 74, 79,
|
153
|
+
50, 51, 74, 37, 74, 79, 64, 64, 64, 64,
|
154
|
+
64, 64, 22, 64, 54, 35, 22, 32, 22, 64,
|
155
|
+
83, 83, 83, 83, 83, 83, 36, 83, 36, 21,
|
156
|
+
36, 18, 36, 83, 33, 33, 33, 33, 33, 33,
|
157
|
+
55, 33, 17, 13, 12, 11, 55, 33, 63, 63,
|
158
|
+
63, 63, 63, 63, 73, 63, 10, 8, 73, 7,
|
159
|
+
73, 63, 70, 70, 70, 70, 70, 70, 6, 70,
|
160
|
+
25, 25, 25, 25, 25, 70, 25, 58, 58, 58,
|
161
|
+
58, 58, 25, 58, 34, 34, 34, 34, 34, 58,
|
162
|
+
34, 62, 62, 62, 62, 62, 34, 62, 15, 15,
|
163
|
+
15, 15, 15, 62, 15, 60, 60, 60, 60, 60,
|
164
|
+
15, 60, 41, 85, 78, 41, 75, 60, 5, 41,
|
165
|
+
85, 41, 40, 75, 81, 80, 3, 40, 82, 81,
|
166
|
+
2, 1, 86 ]
|
160
167
|
|
161
168
|
racc_action_pointer = [
|
162
|
-
-1,
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
nil, nil,
|
170
|
-
|
169
|
+
-1, 156, 161, 166, nil, 150, 91, 85, 75, nil,
|
170
|
+
96, 69, 67, 74, nil, 131, nil, 69, 63, nil,
|
171
|
+
nil, 60, 37, nil, nil, 103, nil, nil, nil, 12,
|
172
|
+
nil, nil, 43, 68, 117, 47, 51, 23, nil, nil,
|
173
|
+
144, 140, -4, nil, nil, nil, -2, 19, nil, nil,
|
174
|
+
16, 27, -3, nil, 38, 63, 9, nil, 110, nil,
|
175
|
+
138, nil, 124, 82, 40, nil, nil, nil, nil, nil,
|
176
|
+
96, nil, nil, 79, 23, 140, -9, nil, 141, 26,
|
177
|
+
161, 146, 155, 54, nil, 137, 159, nil ]
|
171
178
|
|
172
179
|
racc_action_default = [
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
176
|
-
|
177
|
-
-
|
178
|
-
-
|
179
|
-
-
|
180
|
-
|
181
|
-
-
|
180
|
+
-48, -48, -34, -48, -1, -4, -35, -48, -48, -33,
|
181
|
+
-48, -48, -5, -34, -2, -48, 88, -48, -4, -36,
|
182
|
+
-24, -34, -37, -25, -32, -38, -22, -26, -23, -48,
|
183
|
+
-3, -6, -48, -41, -48, -48, -39, -48, -11, -12,
|
184
|
+
-48, -17, -48, -7, -18, -19, -48, -48, -20, -21,
|
185
|
+
-22, -48, -9, -27, -48, -42, -48, -29, -38, -28,
|
186
|
+
-48, -13, -48, -48, -48, -45, -47, -8, -10, -31,
|
187
|
+
-41, -30, -40, -44, -46, -48, -48, -43, -48, -48,
|
188
|
+
-14, -48, -48, -48, -15, -48, -48, -16 ]
|
182
189
|
|
183
190
|
racc_goto_table = [
|
184
|
-
|
185
|
-
|
186
|
-
nil,
|
187
|
-
nil, nil, nil,
|
188
|
-
nil, nil, nil, nil,
|
189
|
-
|
191
|
+
30, 55, 54, 26, 37, 7, 51, 8, 11, 22,
|
192
|
+
4, 3, nil, 26, nil, nil, 19, nil, 8, 36,
|
193
|
+
nil, 31, 26, nil, 32, nil, 8, nil, 56, 68,
|
194
|
+
nil, 75, 76, nil, nil, nil, nil, 72, 55, 77,
|
195
|
+
nil, nil, nil, nil, nil, nil, 26, 81, 26, nil,
|
196
|
+
26, 85, 36, nil, 73, nil, 74, nil, nil, nil,
|
197
|
+
nil, 80, nil, nil, nil, 84, nil, nil, nil, 87 ]
|
190
198
|
|
191
199
|
racc_goto_check = [
|
192
|
-
5,
|
193
|
-
|
194
|
-
nil,
|
195
|
-
nil, nil, nil,
|
196
|
-
nil, nil, nil, nil,
|
197
|
-
16,
|
200
|
+
5, 10, 19, 16, 18, 3, 6, 17, 4, 11,
|
201
|
+
2, 1, nil, 16, nil, nil, 3, nil, 17, 11,
|
202
|
+
nil, 4, 16, nil, 3, nil, 17, nil, 11, 6,
|
203
|
+
nil, 10, 10, nil, nil, nil, nil, 18, 10, 19,
|
204
|
+
nil, nil, nil, nil, nil, nil, 16, 10, 16, nil,
|
205
|
+
16, 10, 11, nil, 11, nil, 11, nil, nil, nil,
|
206
|
+
nil, 5, nil, nil, nil, 5, nil, nil, nil, 5 ]
|
198
207
|
|
199
208
|
racc_goto_pointer = [
|
200
|
-
nil,
|
201
|
-
-
|
209
|
+
nil, 11, 10, 3, 3, -17, -23, nil, nil, nil,
|
210
|
+
-32, -6, nil, nil, nil, nil, -12, 5, -21, -31,
|
202
211
|
nil ]
|
203
212
|
|
204
213
|
racc_goto_default = [
|
205
|
-
nil, nil, nil, nil, nil, nil, nil,
|
206
|
-
|
207
|
-
|
214
|
+
nil, nil, nil, nil, nil, nil, nil, 52, 38, 39,
|
215
|
+
40, 41, 44, 45, 48, 49, 50, 27, nil, nil,
|
216
|
+
6 ]
|
208
217
|
|
209
218
|
racc_token_table = {
|
210
219
|
false => 0,
|
@@ -217,24 +226,25 @@ racc_token_table = {
|
|
217
226
|
:BOOLEAN_LITERAL => 7,
|
218
227
|
:IDENTIFIER => 8,
|
219
228
|
:STRING_LITERAL => 9,
|
220
|
-
:
|
221
|
-
:
|
222
|
-
|
223
|
-
"
|
224
|
-
"
|
225
|
-
"
|
226
|
-
"
|
227
|
-
"
|
228
|
-
"
|
229
|
-
"
|
230
|
-
"
|
231
|
-
"
|
232
|
-
"
|
233
|
-
"
|
229
|
+
:FLOATING_POINT_LITERAL => 10,
|
230
|
+
:INTEGER_LITERAL => 11,
|
231
|
+
:BINARY_OPERATOR => 12,
|
232
|
+
"{" => 13,
|
233
|
+
"}" => 14,
|
234
|
+
"(" => 15,
|
235
|
+
")" => 16,
|
236
|
+
"," => 17,
|
237
|
+
";" => 18,
|
238
|
+
"[" => 19,
|
239
|
+
"]" => 20,
|
240
|
+
"." => 21,
|
241
|
+
":" => 22,
|
242
|
+
"=" => 23,
|
243
|
+
"++" => 24 }
|
234
244
|
|
235
245
|
racc_use_result_var = true
|
236
246
|
|
237
|
-
racc_nt_base =
|
247
|
+
racc_nt_base = 25
|
238
248
|
|
239
249
|
Racc_arg = [
|
240
250
|
racc_action_table,
|
@@ -263,6 +273,7 @@ Racc_token_to_s_table = [
|
|
263
273
|
'BOOLEAN_LITERAL',
|
264
274
|
'IDENTIFIER',
|
265
275
|
'STRING_LITERAL',
|
276
|
+
'FLOATING_POINT_LITERAL',
|
266
277
|
'INTEGER_LITERAL',
|
267
278
|
'BINARY_OPERATOR',
|
268
279
|
'"{"',
|
@@ -411,162 +422,169 @@ module_eval <<'.,.,', 'lib/doily/parser.y', 42
|
|
411
422
|
|
412
423
|
module_eval <<'.,.,', 'lib/doily/parser.y', 55
|
413
424
|
def _reduce_23( val, _values, result )
|
414
|
-
result = Literal.new(val[0].
|
425
|
+
result = Literal.new(val[0].to_f)
|
415
426
|
result
|
416
427
|
end
|
417
428
|
.,.,
|
418
429
|
|
419
430
|
module_eval <<'.,.,', 'lib/doily/parser.y', 56
|
420
431
|
def _reduce_24( val, _values, result )
|
421
|
-
result = Literal.new(
|
432
|
+
result = Literal.new(val[0].to_i)
|
422
433
|
result
|
423
434
|
end
|
424
435
|
.,.,
|
425
436
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
def _reduce_26( val, _values, result )
|
430
|
-
result = Object.new(val[1])
|
437
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 57
|
438
|
+
def _reduce_25( val, _values, result )
|
439
|
+
result = Literal.new(eval(val[0]))
|
431
440
|
result
|
432
441
|
end
|
433
442
|
.,.,
|
434
443
|
|
444
|
+
# reduce 26 omitted
|
445
|
+
|
435
446
|
module_eval <<'.,.,', 'lib/doily/parser.y', 59
|
436
447
|
def _reduce_27( val, _values, result )
|
437
|
-
result =
|
448
|
+
result = Object.new(val[1])
|
438
449
|
result
|
439
450
|
end
|
440
451
|
.,.,
|
441
452
|
|
442
453
|
module_eval <<'.,.,', 'lib/doily/parser.y', 60
|
443
454
|
def _reduce_28( val, _values, result )
|
444
|
-
result =
|
455
|
+
result = Array.new(val[1])
|
445
456
|
result
|
446
457
|
end
|
447
458
|
.,.,
|
448
459
|
|
449
460
|
module_eval <<'.,.,', 'lib/doily/parser.y', 61
|
450
461
|
def _reduce_29( val, _values, result )
|
451
|
-
result = Access.new(val[0], val[2])
|
462
|
+
result = Access.new(val[0], Literal.new(val[2]))
|
452
463
|
result
|
453
464
|
end
|
454
465
|
.,.,
|
455
466
|
|
456
467
|
module_eval <<'.,.,', 'lib/doily/parser.y', 62
|
457
468
|
def _reduce_30( val, _values, result )
|
458
|
-
result =
|
469
|
+
result = Access.new(val[0], val[2])
|
459
470
|
result
|
460
471
|
end
|
461
472
|
.,.,
|
462
473
|
|
463
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
474
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 63
|
464
475
|
def _reduce_31( val, _values, result )
|
465
|
-
result =
|
476
|
+
result = Call.new(val[0], val[2])
|
466
477
|
result
|
467
478
|
end
|
468
479
|
.,.,
|
469
480
|
|
470
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
481
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 67
|
471
482
|
def _reduce_32( val, _values, result )
|
472
|
-
result =
|
483
|
+
result = Reference.new(val[0])
|
473
484
|
result
|
474
485
|
end
|
475
486
|
.,.,
|
476
487
|
|
477
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
488
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 71
|
478
489
|
def _reduce_33( val, _values, result )
|
479
|
-
result =
|
490
|
+
result = Literal.new(eval(val[0]))
|
480
491
|
result
|
481
492
|
end
|
482
493
|
.,.,
|
483
494
|
|
484
495
|
module_eval <<'.,.,', 'lib/doily/parser.y', 75
|
485
496
|
def _reduce_34( val, _values, result )
|
486
|
-
result =
|
497
|
+
result = {}
|
487
498
|
result
|
488
499
|
end
|
489
500
|
.,.,
|
490
501
|
|
491
502
|
module_eval <<'.,.,', 'lib/doily/parser.y', 76
|
492
503
|
def _reduce_35( val, _values, result )
|
493
|
-
result = val[0]
|
504
|
+
result = val[0]
|
494
505
|
result
|
495
506
|
end
|
496
507
|
.,.,
|
497
508
|
|
498
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
509
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 77
|
499
510
|
def _reduce_36( val, _values, result )
|
500
|
-
result =
|
511
|
+
result = val[0].merge(val[2])
|
501
512
|
result
|
502
513
|
end
|
503
514
|
.,.,
|
504
515
|
|
505
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
516
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 81
|
506
517
|
def _reduce_37( val, _values, result )
|
507
|
-
result = []
|
518
|
+
result = { val[0] => val[2] }
|
508
519
|
result
|
509
520
|
end
|
510
521
|
.,.,
|
511
522
|
|
512
523
|
module_eval <<'.,.,', 'lib/doily/parser.y', 85
|
513
524
|
def _reduce_38( val, _values, result )
|
514
|
-
result = [
|
525
|
+
result = []
|
515
526
|
result
|
516
527
|
end
|
517
528
|
.,.,
|
518
529
|
|
519
530
|
module_eval <<'.,.,', 'lib/doily/parser.y', 86
|
520
531
|
def _reduce_39( val, _values, result )
|
521
|
-
result = [val[0]]
|
532
|
+
result = [val[0]]
|
522
533
|
result
|
523
534
|
end
|
524
535
|
.,.,
|
525
536
|
|
526
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
537
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 87
|
527
538
|
def _reduce_40( val, _values, result )
|
528
|
-
result = []
|
539
|
+
result = [val[0]] + val[2]
|
529
540
|
result
|
530
541
|
end
|
531
542
|
.,.,
|
532
543
|
|
533
544
|
module_eval <<'.,.,', 'lib/doily/parser.y', 91
|
534
545
|
def _reduce_41( val, _values, result )
|
535
|
-
result = [
|
546
|
+
result = []
|
536
547
|
result
|
537
548
|
end
|
538
549
|
.,.,
|
539
550
|
|
540
551
|
module_eval <<'.,.,', 'lib/doily/parser.y', 92
|
541
552
|
def _reduce_42( val, _values, result )
|
542
|
-
result = [val[0]]
|
553
|
+
result = [val[0]]
|
543
554
|
result
|
544
555
|
end
|
545
556
|
.,.,
|
546
557
|
|
547
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
558
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 93
|
548
559
|
def _reduce_43( val, _values, result )
|
549
|
-
result =
|
560
|
+
result = [val[0]] + val[2]
|
550
561
|
result
|
551
562
|
end
|
552
563
|
.,.,
|
553
564
|
|
554
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
565
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 97
|
555
566
|
def _reduce_44( val, _values, result )
|
556
|
-
result =
|
567
|
+
result = Assignment.new(val[0], val[2])
|
557
568
|
result
|
558
569
|
end
|
559
570
|
.,.,
|
560
571
|
|
561
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
572
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 101
|
562
573
|
def _reduce_45( val, _values, result )
|
563
|
-
result =
|
574
|
+
result = Declaration.new(val[1])
|
564
575
|
result
|
565
576
|
end
|
566
577
|
.,.,
|
567
578
|
|
568
|
-
module_eval <<'.,.,', 'lib/doily/parser.y',
|
579
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 105
|
569
580
|
def _reduce_46( val, _values, result )
|
581
|
+
result = Call.new(Access.new(val[0], Literal.new(val[1])), [val[2]])
|
582
|
+
result
|
583
|
+
end
|
584
|
+
.,.,
|
585
|
+
|
586
|
+
module_eval <<'.,.,', 'lib/doily/parser.y', 109
|
587
|
+
def _reduce_47( val, _values, result )
|
570
588
|
result = Assignment.new(val[0], Call.new(Access.new(val[0], Literal.new('+')), [Literal.new(1)]))
|
571
589
|
result
|
572
590
|
end
|
data/lib/doily/parser.y
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Doily::Parser
|
2
2
|
|
3
|
-
token FUNCTION IF ELSE FOR VAR BOOLEAN_LITERAL IDENTIFIER STRING_LITERAL INTEGER_LITERAL BINARY_OPERATOR
|
3
|
+
token FUNCTION IF ELSE FOR VAR BOOLEAN_LITERAL IDENTIFIER STRING_LITERAL FLOATING_POINT_LITERAL INTEGER_LITERAL BINARY_OPERATOR
|
4
4
|
|
5
5
|
rule
|
6
6
|
target
|
@@ -53,6 +53,7 @@ rule
|
|
53
53
|
|
54
54
|
reference
|
55
55
|
: variable
|
56
|
+
| FLOATING_POINT_LITERAL { result = Literal.new(val[0].to_f) }
|
56
57
|
| INTEGER_LITERAL { result = Literal.new(val[0].to_i) }
|
57
58
|
| BOOLEAN_LITERAL { result = Literal.new(eval(val[0])) }
|
58
59
|
| string_literal
|
@@ -145,11 +146,13 @@ require 'strscan'
|
|
145
146
|
@tokens.push [m, m]
|
146
147
|
when m = scanner.scan(/[a-zA-Z_]+/)
|
147
148
|
@tokens.push [:IDENTIFIER, m]
|
148
|
-
when m = scanner.scan(/"([^"])*"/)
|
149
|
+
when m = scanner.scan(/"(?:\\.|[^"])*"/)
|
149
150
|
@tokens.push [:STRING_LITERAL, m]
|
150
|
-
when m = scanner.scan(/'([^'])*'/)
|
151
|
+
when m = scanner.scan(/'(?:\\.|[^'])*'/)
|
151
152
|
@tokens.push [:STRING_LITERAL, m]
|
152
|
-
when m = scanner.scan(
|
153
|
+
when m = scanner.scan(/(?:-)?\d+\.\d+/)
|
154
|
+
@tokens.push [:FLOATING_POINT_LITERAL, m]
|
155
|
+
when m = scanner.scan(/(?:-)?\d+/)
|
153
156
|
@tokens.push [:INTEGER_LITERAL, m]
|
154
157
|
else
|
155
158
|
raise ParseError.new(scanner)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
|
-
class
|
3
|
+
class DoilyTest < Test::Unit::TestCase
|
4
4
|
should 'handle nothing' do
|
5
5
|
Doily('function() {}').call.should == nil
|
6
6
|
end
|
@@ -101,6 +101,37 @@ class DoilyFunctionTest < Test::Unit::TestCase
|
|
101
101
|
Doily('function() { false; }').call.should == false
|
102
102
|
end
|
103
103
|
|
104
|
+
should 'handle floating-point literals' do
|
105
|
+
Doily('function() { 1.2; }').call.should == 1.2
|
106
|
+
end
|
107
|
+
|
108
|
+
should 'handle negative integer literals' do
|
109
|
+
Doily('function() { -1; }').call.should == -1
|
110
|
+
end
|
111
|
+
|
112
|
+
should 'handle negative floating-point literals' do
|
113
|
+
Doily('function() { -1.2; }').call.should == -1.2
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'escape sequences' do
|
117
|
+
context 'ruby' do
|
118
|
+
should 'require escaping backslashes in a single-quoted string' do
|
119
|
+
string = '\\"'
|
120
|
+
string.length.should == 2
|
121
|
+
string[0..0].should == '\\'
|
122
|
+
string[1..1].should == '"'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
should 'handle escape sequences in single-quoted strings' do
|
127
|
+
Doily('function() { \'\\\'\'; }').call.should == '\''
|
128
|
+
end
|
129
|
+
|
130
|
+
should 'handle escape sequences in double-quoted strings' do
|
131
|
+
Doily('function() { "\\""; }').call.should == '"'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
104
135
|
should 'handle single-quoted strings' do
|
105
136
|
Doily("function() { 'foo'; }").call.should == 'foo'
|
106
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matthewtodd-doily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Todd
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -81,8 +81,8 @@ files:
|
|
81
81
|
- lib/doily/types/reference.rb
|
82
82
|
- lib/doily/types.rb
|
83
83
|
- lib/doily.rb
|
84
|
-
- test/doily_function_test.rb
|
85
84
|
- test/doily_hash_test.rb
|
85
|
+
- test/doily_test.rb
|
86
86
|
- test/test_helper.rb
|
87
87
|
has_rdoc: false
|
88
88
|
homepage:
|
@@ -91,7 +91,7 @@ rdoc_options:
|
|
91
91
|
- --main
|
92
92
|
- README.rdoc
|
93
93
|
- --title
|
94
|
-
- doily-0.1.
|
94
|
+
- doily-0.1.2
|
95
95
|
- --inline-source
|
96
96
|
- --line-numbers
|
97
97
|
- --all
|