matthewtodd-doily 0.1.0

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/README.rdoc ADDED
@@ -0,0 +1,30 @@
1
+ = Doily
2
+
3
+ A Javascript (function) interpreter for Ruby.
4
+
5
+ == Examples
6
+
7
+ Doily('function(string) { string.length; }').call('foo') # => 3
8
+
9
+ function = Doily('function(doc) { if (doc.type == "node") { emit(doc.name, doc); } }')
10
+ function = function.delegate(couch_db_view) # assuming couch_db_view responds to :emit
11
+ documents.each do |document|
12
+ function.call(document)
13
+ end
14
+
15
+ == Install
16
+
17
+ gem sources --add http://gems.github.com
18
+ gem install matthewtodd-doily
19
+
20
+ Or, if you want to run tests & features:
21
+
22
+ gem sources --add http://gems.github.com
23
+ gem sources --add http://gems.opscode.com
24
+ gem install matthewtodd-doily --development
25
+
26
+ == Alternatives (More or Less)
27
+
28
+ * http://github.com/jbarnette/johnson - Ruby wrapper for SpiderMonkey
29
+ * http://github.com/jcoglan/siren - JSON parser / query language
30
+ * others?
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake/rdoctask'
3
+ require 'rake/testtask'
4
+ require 'cucumber/rake/task'
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = 'doily'
8
+ s.version = '0.1.0'
9
+ s.summary = 'A Javascript (function) interpreter for Ruby.'
10
+ s.files = FileList['Rakefile', '*.rdoc', 'features/**/*', 'lib/**/*', 'test/**/*'].to_a
11
+ s.rdoc_options = %W[--main README.rdoc --title #{s.name}-#{s.version} --inline-source --line-numbers --all]
12
+ s.extra_rdoc_files = FileList['*.rdoc'].to_a
13
+ s.author = 'Matthew Todd'
14
+ s.email = 'matthew.todd@gmail.com'
15
+
16
+ s.add_development_dependency 'chef'
17
+ s.add_development_dependency 'jeremymcanally-matchy'
18
+ s.add_development_dependency 'thoughtbot-shoulda'
19
+ end
20
+
21
+ desc 'Generate documentation'
22
+ Rake::RDocTask.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_dir = 'docs'
24
+ rdoc.options = spec.rdoc_options
25
+ rdoc.rdoc_files = FileList['*.rdoc', 'lib/**/*.rb'].to_a
26
+ end
27
+
28
+ desc 'Generate a gemspec file'
29
+ task :gemspec do
30
+ File.open("#{spec.name}.gemspec", 'w') do |f|
31
+ f.write spec.to_ruby
32
+ end
33
+ end
34
+
35
+ rule '.rb' => ['.y'] do |task|
36
+ sh "racc --output-file #{task.name} #{task.source}"
37
+ end
38
+
39
+ Rake::TestTask.new do |task|
40
+ task.pattern = 'test/*_test.rb'
41
+ end
42
+
43
+ Cucumber::Rake::Task.new
44
+
45
+ task :test => 'lib/doily/parser.rb'
46
+ task :features => 'lib/doily/parser.rb'
47
+ task :default => [:test, :features]
@@ -0,0 +1,55 @@
1
+ Feature: Chef Nodes
2
+ In order to get my chef server talking to a ruby-based fake couchdb
3
+ As a compulsive yak shaver
4
+ I want a ruby-based javascript interpreter that handles the views necessary to retrieve Nodes
5
+
6
+ Background:
7
+ Given these documents
8
+ | chef_type | name | attributes | run_list |
9
+ | 'node' | 'malacandra' | { 'fqdn' => 'malacandra.example.com' } | ['a', 'b', 'c'] |
10
+ | 'node' | 'perelandra' | { 'fqdn' => 'perelandra.example.com' } | ['a', 'b'] |
11
+ | 'node' | 'thulucandra' | { 'fqdn' => 'thulucandra.example.com' } | nil |
12
+ | 'openid_registration' | 'glarb_example_com' | 'do not matter' | 'does not matter' |
13
+
14
+ Scenario: Coverage
15
+ When I list all the views for 'Node'
16
+ Then I should see
17
+ | name |
18
+ | 'all' |
19
+ | 'all_id' |
20
+ | 'by_run_list' |
21
+ | 'status' |
22
+
23
+ Scenario: Getting all Nodes
24
+ When I get the 'all' view for 'Node'
25
+ Then I should see
26
+ | key | value |
27
+ | 'malacandra' | { 'chef_type' => 'node', 'name' => 'malacandra', 'attributes' => { 'fqdn' => 'malacandra.example.com' }, 'run_list' => ['a', 'b', 'c'] } |
28
+ | 'perelandra' | { 'chef_type' => 'node', 'name' => 'perelandra', 'attributes' => { 'fqdn' => 'perelandra.example.com' }, 'run_list' => ['a', 'b'] } |
29
+ | 'thulucandra' | { 'chef_type' => 'node', 'name' => 'thulucandra', 'attributes' => { 'fqdn' => 'thulucandra.example.com' }, 'run_list' => nil } |
30
+
31
+ Scenario: Getting all Node ids
32
+ When I get the 'all_id' view for 'Node'
33
+ Then I should see
34
+ | key | value |
35
+ | 'malacandra' | 'malacandra' |
36
+ | 'perelandra' | 'perelandra' |
37
+ | 'thulucandra' | 'thulucandra' |
38
+
39
+ Scenario: Getting all Node statuses
40
+ When I get the 'status' view for 'Node'
41
+ Then I should see
42
+ | key | value |
43
+ | 'malacandra' | { 'name' => 'malacandra', 'fqdn' => 'malacandra.example.com', 'ipaddress' => 'Undefined', 'ohai_time' => 'Undefined', 'uptime' => 'Undefined', 'platform' => 'Undefined', 'platform_version' => 'Undefined', 'run_list' => ['a', 'b', 'c'] } |
44
+ | 'perelandra' | { 'name' => 'perelandra', 'fqdn' => 'perelandra.example.com', 'ipaddress' => 'Undefined', 'ohai_time' => 'Undefined', 'uptime' => 'Undefined', 'platform' => 'Undefined', 'platform_version' => 'Undefined', 'run_list' => ['a', 'b'] } |
45
+ | 'thulucandra' | { 'name' => 'thulucandra', 'fqdn' => 'thulucandra.example.com', 'ipaddress' => 'Undefined', 'ohai_time' => 'Undefined', 'uptime' => 'Undefined', 'platform' => 'Undefined', 'platform_version' => 'Undefined', 'run_list' => 'Undefined' } |
46
+
47
+ Scenario: Getting Nodes by run list
48
+ When I get the 'by_run_list' view for 'Node'
49
+ Then I should see
50
+ | key | value |
51
+ | 'a' | 'malacandra' |
52
+ | 'b' | 'malacandra' |
53
+ | 'c' | 'malacandra' |
54
+ | 'a' | 'perelandra' |
55
+ | 'b' | 'perelandra' |
@@ -0,0 +1,46 @@
1
+ Feature: Chef OpenID Registrations
2
+ In order to get my chef server talking to a ruby-based fake couchdb
3
+ As a compulsive yak shaver
4
+ I want a ruby-based javascript interpreter that handles the views necessary to retrieve OpenIDRegistrations
5
+
6
+ Background:
7
+ Given these documents
8
+ | chef_type | name | validated |
9
+ | 'openid_registration' | 'unvalidated_org' | false |
10
+ | 'openid_registration' | 'validated_org' | true |
11
+ | 'role' | 'foo' | 'does not matter' |
12
+
13
+ Scenario: Coverage
14
+ When I list all the views for 'OpenIDRegistration'
15
+ Then I should see
16
+ | name |
17
+ | 'all' |
18
+ | 'all_id' |
19
+ | 'unvalidated' |
20
+ | 'validated' |
21
+
22
+ Scenario: Getting all OpenID Registrations
23
+ When I get the 'all' view for 'OpenIDRegistration'
24
+ Then I should see
25
+ | key | value |
26
+ | 'unvalidated_org' | { 'chef_type' => 'openid_registration', 'name' => 'unvalidated_org', 'validated' => false } |
27
+ | 'validated_org' | { 'chef_type' => 'openid_registration', 'name' => 'validated_org', 'validated' => true } |
28
+
29
+ Scenario: Getting all OpenID Registration ids
30
+ When I get the 'all_id' view for 'OpenIDRegistration'
31
+ Then I should see
32
+ | key | value |
33
+ | 'unvalidated_org' | 'unvalidated_org' |
34
+ | 'validated_org' | 'validated_org' |
35
+
36
+ Scenario: Getting validated OpenID Registrations
37
+ When I get the 'validated' view for 'OpenIDRegistration'
38
+ Then I should see
39
+ | key | value |
40
+ | 'validated_org' | { 'chef_type' => 'openid_registration', 'name' => 'validated_org', 'validated' => true } |
41
+
42
+ Scenario: Getting unvalidated OpenID Registrations
43
+ When I get the 'unvalidated' view for 'OpenIDRegistration'
44
+ Then I should see
45
+ | key | value |
46
+ | 'unvalidated_org' | { 'chef_type' => 'openid_registration', 'name' => 'unvalidated_org', 'validated' => false } |
@@ -0,0 +1,32 @@
1
+ Feature: Chef Roles
2
+ In order to get my chef server talking to a ruby-based fake couchdb
3
+ As a compulsive yak shaver
4
+ I want a ruby-based javascript interpreter that handles the views necessary to retrieve Roles
5
+
6
+ Background:
7
+ Given these documents
8
+ | chef_type | name |
9
+ | 'role' | 'application server' |
10
+ | 'role' | 'database server' |
11
+ | 'openid_registration' | 'glarb_example_com' |
12
+
13
+ Scenario: Coverage
14
+ When I list all the views for 'Role'
15
+ Then I should see
16
+ | name |
17
+ | 'all' |
18
+ | 'all_id' |
19
+
20
+ Scenario: Getting all Roles
21
+ When I get the 'all' view for 'Role'
22
+ Then I should see
23
+ | key | value |
24
+ | 'application server' | { 'chef_type' => 'role', 'name' => 'application server' } |
25
+ | 'database server' | { 'chef_type' => 'role', 'name' => 'database server' } |
26
+
27
+ Scenario: Getting all Role ids
28
+ When I get the 'all_id' view for 'Role'
29
+ Then I should see
30
+ | key | value |
31
+ | 'application server' | 'application server' |
32
+ | 'database server' | 'database server' |
@@ -0,0 +1,20 @@
1
+ Given /^these documents$/ do |table|
2
+ evaluate_table_values(table)
3
+ @documents = table.hashes
4
+ end
5
+
6
+ When /^I list all the views for '(.+)'$/ do |klass|
7
+ @results = []
8
+ chef_view_functions(klass).keys.sort.each { |key| @results.push('name' => key)}
9
+ end
10
+
11
+ When /^I get the '(.+)' view for '(.+)'$/ do |name, klass|
12
+ @results = CouchDBView.perform do |couch_db_view|
13
+ @documents.each { |document| Doily(chef_view(klass, name)).delegate(couch_db_view).call(document) }
14
+ end
15
+ end
16
+
17
+ Then /^I should see$/ do |table|
18
+ evaluate_table_values(table)
19
+ @results.should == table.hashes
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ gem 'jeremymcanally-matchy'
3
+ require 'matchy'
4
+ gem 'chef'
5
+ require 'chef'
6
+ require 'chef/role'
7
+
8
+ $:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
9
+ require 'doily'
@@ -0,0 +1,27 @@
1
+ class CouchDBView
2
+ def self.perform(&block)
3
+ new.perform(&block)
4
+ end
5
+
6
+ def perform
7
+ @emitted = []
8
+ yield self
9
+ @emitted
10
+ end
11
+
12
+ def emit(key, value)
13
+ @emitted.push('key' => key, 'value' => value)
14
+ end
15
+ end
16
+
17
+ def chef_view_functions(klass)
18
+ Chef.const_get(klass)::DESIGN_DOCUMENT.fetch('views')
19
+ end
20
+
21
+ def chef_view(klass, name)
22
+ chef_view_functions(klass).fetch(name).fetch('map')
23
+ end
24
+
25
+ def evaluate_table_values(table)
26
+ table.raw[0].each { |column| table.map_column!(column) { |value| eval(value) }}
27
+ end
data/lib/doily.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'doily/errors'
2
+ require 'doily/parser'
3
+ require 'doily/types'
4
+
5
+ def Doily(string)
6
+ Doily::Parser.function(string)
7
+ end
@@ -0,0 +1,13 @@
1
+ module Doily
2
+ class ArgumentError < RuntimeError
3
+ def initialize(names, values)
4
+ super("wrong number of arguments: expected #{names.inspect} but got #{values.inspect}")
5
+ end
6
+ end
7
+
8
+ class ParseError < RuntimeError
9
+ def initialize(scanner)
10
+ super("Unknown token starting at position #{scanner.pos}: #{scanner.rest}")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,534 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by racc 1.4.5
4
+ # from racc grammer file "lib/doily/parser.y".
5
+ #
6
+
7
+ require 'racc/parser'
8
+
9
+
10
+ require 'strscan'
11
+
12
+ module Doily
13
+
14
+ class Parser < Racc::Parser
15
+
16
+ module_eval <<'..end lib/doily/parser.y modeval..id32b1a5e4ef', 'lib/doily/parser.y', 107
17
+
18
+ def self.function(string)
19
+ new.parse(string)
20
+ end
21
+
22
+ def parse(string)
23
+ @tokens = []
24
+ scanner = StringScanner.new(string)
25
+
26
+ until scanner.empty?
27
+ case
28
+ when scanner.scan(/\s+/)
29
+ # ignore space
30
+ when m = scanner.scan(/function/)
31
+ @tokens.push [:FUNCTION, m]
32
+ when m = scanner.scan(/if/)
33
+ @tokens.push [:IF, m]
34
+ when m = scanner.scan(/else/)
35
+ @tokens.push [:ELSE, m]
36
+ when m = scanner.scan(/for/)
37
+ @tokens.push [:FOR, m]
38
+ when m = scanner.scan(/var/)
39
+ @tokens.push [:VAR, m]
40
+ when m = scanner.scan(/true|false/)
41
+ @tokens.push [:BOOLEAN_LITERAL, m]
42
+ when m = scanner.scan(/==|</)
43
+ @tokens.push [:BINARY_OPERATOR, m]
44
+ when m = scanner.scan(/\+\+/)
45
+ @tokens.push [m, m]
46
+ when m = scanner.scan(/[(){}\[\],\.:;=]/)
47
+ @tokens.push [m, m]
48
+ when m = scanner.scan(/[a-zA-Z_]+/)
49
+ @tokens.push [:IDENTIFIER, m]
50
+ when m = scanner.scan(/"([^"])*"/)
51
+ @tokens.push [:STRING_LITERAL, m]
52
+ when m = scanner.scan(/'([^'])*'/)
53
+ @tokens.push [:STRING_LITERAL, m]
54
+ when m = scanner.scan(/\d+/)
55
+ @tokens.push [:INTEGER_LITERAL, m]
56
+ else
57
+ raise ParseError.new(scanner)
58
+ end
59
+ end
60
+
61
+ @tokens.push [false, false]
62
+ do_parse
63
+ end
64
+
65
+ def next_token
66
+ @tokens.shift
67
+ end
68
+ ..end lib/doily/parser.y modeval..id32b1a5e4ef
69
+
70
+ ##### racc 1.4.5 generates ###
71
+
72
+ racc_reduce_table = [
73
+ 0, 0, :racc_error,
74
+ 1, 25, :_reduce_none,
75
+ 5, 26, :_reduce_2,
76
+ 0, 27, :_reduce_3,
77
+ 1, 27, :_reduce_4,
78
+ 3, 27, :_reduce_5,
79
+ 2, 28, :_reduce_6,
80
+ 3, 28, :_reduce_7,
81
+ 1, 29, :_reduce_8,
82
+ 2, 29, :_reduce_9,
83
+ 1, 30, :_reduce_none,
84
+ 1, 30, :_reduce_none,
85
+ 2, 30, :_reduce_none,
86
+ 5, 31, :_reduce_13,
87
+ 7, 31, :_reduce_14,
88
+ 9, 32, :_reduce_15,
89
+ 1, 33, :_reduce_none,
90
+ 1, 33, :_reduce_none,
91
+ 1, 33, :_reduce_none,
92
+ 1, 33, :_reduce_none,
93
+ 1, 33, :_reduce_none,
94
+ 1, 34, :_reduce_none,
95
+ 1, 34, :_reduce_22,
96
+ 1, 34, :_reduce_23,
97
+ 1, 34, :_reduce_none,
98
+ 3, 34, :_reduce_25,
99
+ 3, 34, :_reduce_26,
100
+ 4, 34, :_reduce_27,
101
+ 4, 34, :_reduce_28,
102
+ 1, 39, :_reduce_29,
103
+ 1, 40, :_reduce_30,
104
+ 0, 41, :_reduce_31,
105
+ 1, 41, :_reduce_32,
106
+ 3, 41, :_reduce_33,
107
+ 3, 43, :_reduce_34,
108
+ 0, 42, :_reduce_35,
109
+ 1, 42, :_reduce_36,
110
+ 3, 42, :_reduce_37,
111
+ 3, 36, :_reduce_38,
112
+ 2, 35, :_reduce_39,
113
+ 3, 37, :_reduce_40,
114
+ 2, 38, :_reduce_41 ]
115
+
116
+ racc_reduce_n = 42
117
+
118
+ racc_shift_n = 78
119
+
120
+ racc_action_table = [
121
+ 18, 76, 22, 24, 27, 29, 31, 33, 1, 55,
122
+ 35, 58, 19, 23, 18, 65, 22, 24, 27, 29,
123
+ 31, 33, 59, 60, 35, 62, 19, 24, 27, 29,
124
+ 31, 33, 48, 35, 47, 46, 19, 24, 27, 29,
125
+ 31, 33, 45, 63, 31, 41, 19, 24, 27, 29,
126
+ 31, 33, 7, 31, 11, 10, 19, 24, 27, 29,
127
+ 31, 33, 11, 9, 8, 72, 19, 24, 27, 29,
128
+ 31, 33, 7, 11, 5, 4, 19, 24, 27, 29,
129
+ 31, 33, 37, 38, 11, nil, 19, nil, nil, 39,
130
+ 40, 27, 29, 31, 33, 27, 29, 31, 33, 19,
131
+ 38, nil, nil, 19, nil, nil, 39, 40, 64, 27,
132
+ 29, 31, 33, 27, 29, 31, 33, 19, 38, nil,
133
+ 38, 19, 38, nil, 39, 40, 39, 40, 39, 40,
134
+ 68, 73, 36, nil, nil, 35, 35, 35 ]
135
+
136
+ racc_action_check = [
137
+ 11, 75, 11, 11, 11, 11, 11, 11, 0, 39,
138
+ 75, 42, 11, 11, 30, 57, 30, 30, 30, 30,
139
+ 30, 30, 43, 44, 57, 53, 30, 73, 73, 73,
140
+ 73, 73, 28, 53, 25, 24, 73, 38, 38, 38,
141
+ 38, 38, 22, 54, 19, 18, 38, 68, 68, 68,
142
+ 68, 68, 10, 60, 9, 7, 68, 62, 62, 62,
143
+ 62, 62, 65, 6, 5, 70, 62, 45, 45, 45,
144
+ 45, 45, 4, 72, 2, 1, 45, 41, 41, 41,
145
+ 41, 41, 15, 15, 76, nil, 41, nil, nil, 15,
146
+ 15, 40, 40, 40, 40, 58, 58, 58, 58, 40,
147
+ 56, nil, nil, 58, nil, nil, 56, 56, 56, 37,
148
+ 37, 37, 37, 35, 35, 35, 35, 37, 50, nil,
149
+ 66, 35, 52, nil, 50, 50, 66, 66, 52, 52,
150
+ 61, 71, 14, nil, nil, 61, 71, 14 ]
151
+
152
+ racc_action_pointer = [
153
+ 6, 63, 74, nil, 64, 64, 50, 41, nil, 39,
154
+ 44, -3, nil, nil, 115, 71, nil, nil, 33, 35,
155
+ nil, nil, 30, nil, 27, 11, nil, nil, 16, nil,
156
+ 11, nil, nil, nil, nil, 106, nil, 102, 31, 1,
157
+ 84, 71, -10, 6, 9, 61, nil, nil, nil, nil,
158
+ 106, nil, 110, 11, 30, nil, 88, 2, 88, nil,
159
+ 44, 113, 51, nil, nil, 47, 108, nil, 41, nil,
160
+ 61, 114, 58, 21, nil, -12, 69, nil ]
161
+
162
+ racc_action_default = [
163
+ -42, -42, -42, -1, -3, -42, -42, -4, 78, -42,
164
+ -3, -42, -2, -5, -42, -16, -17, -18, -42, -31,
165
+ -19, -20, -42, -6, -42, -21, -24, -23, -42, -29,
166
+ -8, -30, -10, -22, -11, -42, -12, -42, -35, -42,
167
+ -42, -42, -42, -42, -32, -42, -39, -41, -7, -9,
168
+ -38, -21, -40, -36, -42, -26, -42, -42, -42, -25,
169
+ -31, -42, -35, -28, -27, -42, -34, -33, -42, -37,
170
+ -13, -42, -42, -42, -14, -42, -42, -15 ]
171
+
172
+ racc_goto_table = [
173
+ 12, 43, 42, 53, 54, 28, 57, 51, 6, 51,
174
+ 61, 50, 51, 52, 13, 3, 56, 2, nil, nil,
175
+ nil, nil, nil, nil, 49, nil, nil, 53, 69, nil,
176
+ 51, nil, nil, 71, 66, nil, nil, nil, 75, nil,
177
+ nil, nil, 67, 42, nil, nil, nil, nil, nil, nil,
178
+ nil, nil, nil, nil, nil, nil, 70, nil, nil, nil,
179
+ nil, nil, nil, 74, nil, nil, nil, 77 ]
180
+
181
+ racc_goto_check = [
182
+ 4, 17, 16, 9, 18, 5, 9, 15, 3, 15,
183
+ 9, 10, 15, 10, 3, 2, 10, 1, nil, nil,
184
+ nil, nil, nil, nil, 5, nil, nil, 9, 18, nil,
185
+ 15, nil, nil, 9, 10, nil, nil, nil, 9, nil,
186
+ nil, nil, 17, 16, nil, nil, nil, nil, nil, nil,
187
+ nil, nil, nil, nil, nil, nil, 4, nil, nil, nil,
188
+ nil, nil, nil, 4, nil, nil, nil, 4 ]
189
+
190
+ racc_goto_pointer = [
191
+ nil, 17, 15, 4, -9, -6, nil, nil, nil, -35,
192
+ -24, nil, nil, nil, nil, -28, -17, -18, -34, nil ]
193
+
194
+ racc_goto_default = [
195
+ nil, nil, nil, nil, nil, nil, 30, 32, 34, 14,
196
+ 15, 16, 17, 20, 21, 25, 26, nil, nil, 44 ]
197
+
198
+ racc_token_table = {
199
+ false => 0,
200
+ Object.new => 1,
201
+ :FUNCTION => 2,
202
+ :IF => 3,
203
+ :ELSE => 4,
204
+ :FOR => 5,
205
+ :VAR => 6,
206
+ :BOOLEAN_LITERAL => 7,
207
+ :IDENTIFIER => 8,
208
+ :STRING_LITERAL => 9,
209
+ :INTEGER_LITERAL => 10,
210
+ :BINARY_OPERATOR => 11,
211
+ "(" => 12,
212
+ ")" => 13,
213
+ "," => 14,
214
+ "{" => 15,
215
+ "}" => 16,
216
+ ";" => 17,
217
+ "." => 18,
218
+ "[" => 19,
219
+ "]" => 20,
220
+ ":" => 21,
221
+ "=" => 22,
222
+ "++" => 23 }
223
+
224
+ racc_use_result_var = true
225
+
226
+ racc_nt_base = 24
227
+
228
+ Racc_arg = [
229
+ racc_action_table,
230
+ racc_action_check,
231
+ racc_action_default,
232
+ racc_action_pointer,
233
+ racc_goto_table,
234
+ racc_goto_check,
235
+ racc_goto_default,
236
+ racc_goto_pointer,
237
+ racc_nt_base,
238
+ racc_reduce_table,
239
+ racc_token_table,
240
+ racc_shift_n,
241
+ racc_reduce_n,
242
+ racc_use_result_var ]
243
+
244
+ Racc_token_to_s_table = [
245
+ '$end',
246
+ 'error',
247
+ 'FUNCTION',
248
+ 'IF',
249
+ 'ELSE',
250
+ 'FOR',
251
+ 'VAR',
252
+ 'BOOLEAN_LITERAL',
253
+ 'IDENTIFIER',
254
+ 'STRING_LITERAL',
255
+ 'INTEGER_LITERAL',
256
+ 'BINARY_OPERATOR',
257
+ '"("',
258
+ '")"',
259
+ '","',
260
+ '"{"',
261
+ '"}"',
262
+ '";"',
263
+ '"."',
264
+ '"["',
265
+ '"]"',
266
+ '":"',
267
+ '"="',
268
+ '"++"',
269
+ '$start',
270
+ 'target',
271
+ 'function_definition',
272
+ 'argument_name_list',
273
+ 'block',
274
+ 'statement_list',
275
+ 'statement',
276
+ 'if_statement',
277
+ 'for_loop',
278
+ 'expression',
279
+ 'reference',
280
+ 'declaration',
281
+ 'assignment',
282
+ 'binary_expression',
283
+ 'increment',
284
+ 'variable',
285
+ 'string_literal',
286
+ 'key_value_list',
287
+ 'argument_list',
288
+ 'key_value']
289
+
290
+ Racc_debug_parser = false
291
+
292
+ ##### racc system variables end #####
293
+
294
+ # reduce 0 omitted
295
+
296
+ # reduce 1 omitted
297
+
298
+ module_eval <<'.,.,', 'lib/doily/parser.y', 10
299
+ def _reduce_2( val, _values, result )
300
+ result = Function.new(val[2], val[4])
301
+ result
302
+ end
303
+ .,.,
304
+
305
+ module_eval <<'.,.,', 'lib/doily/parser.y', 14
306
+ def _reduce_3( val, _values, result )
307
+ result = []
308
+ result
309
+ end
310
+ .,.,
311
+
312
+ module_eval <<'.,.,', 'lib/doily/parser.y', 15
313
+ def _reduce_4( val, _values, result )
314
+ result = [val[0]]
315
+ result
316
+ end
317
+ .,.,
318
+
319
+ module_eval <<'.,.,', 'lib/doily/parser.y', 16
320
+ def _reduce_5( val, _values, result )
321
+ result = [val[0]] + val[2]
322
+ result
323
+ end
324
+ .,.,
325
+
326
+ module_eval <<'.,.,', 'lib/doily/parser.y', 20
327
+ def _reduce_6( val, _values, result )
328
+ result = Block.new([])
329
+ result
330
+ end
331
+ .,.,
332
+
333
+ module_eval <<'.,.,', 'lib/doily/parser.y', 21
334
+ def _reduce_7( val, _values, result )
335
+ result = Block.new(val[1])
336
+ result
337
+ end
338
+ .,.,
339
+
340
+ module_eval <<'.,.,', 'lib/doily/parser.y', 25
341
+ def _reduce_8( val, _values, result )
342
+ result = [val[0]]
343
+ result
344
+ end
345
+ .,.,
346
+
347
+ module_eval <<'.,.,', 'lib/doily/parser.y', 26
348
+ def _reduce_9( val, _values, result )
349
+ result = [val[0]] + val[1]
350
+ result
351
+ end
352
+ .,.,
353
+
354
+ # reduce 10 omitted
355
+
356
+ # reduce 11 omitted
357
+
358
+ # reduce 12 omitted
359
+
360
+ module_eval <<'.,.,', 'lib/doily/parser.y', 36
361
+ def _reduce_13( val, _values, result )
362
+ result = Conditional.new(val[2], val[4])
363
+ result
364
+ end
365
+ .,.,
366
+
367
+ module_eval <<'.,.,', 'lib/doily/parser.y', 37
368
+ def _reduce_14( val, _values, result )
369
+ result = Conditional.new(val[2], val[4], val[6])
370
+ result
371
+ end
372
+ .,.,
373
+
374
+ module_eval <<'.,.,', 'lib/doily/parser.y', 41
375
+ def _reduce_15( val, _values, result )
376
+ result = Loop.new(val[2], val[4], val[6], val[8])
377
+ result
378
+ end
379
+ .,.,
380
+
381
+ # reduce 16 omitted
382
+
383
+ # reduce 17 omitted
384
+
385
+ # reduce 18 omitted
386
+
387
+ # reduce 19 omitted
388
+
389
+ # reduce 20 omitted
390
+
391
+ # reduce 21 omitted
392
+
393
+ module_eval <<'.,.,', 'lib/doily/parser.y', 54
394
+ def _reduce_22( val, _values, result )
395
+ result = Literal.new(val[0].to_i)
396
+ result
397
+ end
398
+ .,.,
399
+
400
+ module_eval <<'.,.,', 'lib/doily/parser.y', 55
401
+ def _reduce_23( val, _values, result )
402
+ result = Literal.new(eval(val[0]))
403
+ result
404
+ end
405
+ .,.,
406
+
407
+ # reduce 24 omitted
408
+
409
+ module_eval <<'.,.,', 'lib/doily/parser.y', 57
410
+ def _reduce_25( val, _values, result )
411
+ result = Object.new(val[1])
412
+ result
413
+ end
414
+ .,.,
415
+
416
+ module_eval <<'.,.,', 'lib/doily/parser.y', 58
417
+ def _reduce_26( val, _values, result )
418
+ result = Access.new(val[0], Literal.new(val[2]))
419
+ result
420
+ end
421
+ .,.,
422
+
423
+ module_eval <<'.,.,', 'lib/doily/parser.y', 59
424
+ def _reduce_27( val, _values, result )
425
+ result = Access.new(val[0], val[2])
426
+ result
427
+ end
428
+ .,.,
429
+
430
+ module_eval <<'.,.,', 'lib/doily/parser.y', 60
431
+ def _reduce_28( val, _values, result )
432
+ result = Call.new(val[0], val[2])
433
+ result
434
+ end
435
+ .,.,
436
+
437
+ module_eval <<'.,.,', 'lib/doily/parser.y', 64
438
+ def _reduce_29( val, _values, result )
439
+ result = Reference.new(val[0])
440
+ result
441
+ end
442
+ .,.,
443
+
444
+ module_eval <<'.,.,', 'lib/doily/parser.y', 68
445
+ def _reduce_30( val, _values, result )
446
+ result = Literal.new(eval(val[0]))
447
+ result
448
+ end
449
+ .,.,
450
+
451
+ module_eval <<'.,.,', 'lib/doily/parser.y', 72
452
+ def _reduce_31( val, _values, result )
453
+ result = {}
454
+ result
455
+ end
456
+ .,.,
457
+
458
+ module_eval <<'.,.,', 'lib/doily/parser.y', 73
459
+ def _reduce_32( val, _values, result )
460
+ result = val[0]
461
+ result
462
+ end
463
+ .,.,
464
+
465
+ module_eval <<'.,.,', 'lib/doily/parser.y', 74
466
+ def _reduce_33( val, _values, result )
467
+ result = val[0].merge(val[2])
468
+ result
469
+ end
470
+ .,.,
471
+
472
+ module_eval <<'.,.,', 'lib/doily/parser.y', 78
473
+ def _reduce_34( val, _values, result )
474
+ result = { val[0] => val[2] }
475
+ result
476
+ end
477
+ .,.,
478
+
479
+ module_eval <<'.,.,', 'lib/doily/parser.y', 82
480
+ def _reduce_35( val, _values, result )
481
+ result = []
482
+ result
483
+ end
484
+ .,.,
485
+
486
+ module_eval <<'.,.,', 'lib/doily/parser.y', 83
487
+ def _reduce_36( val, _values, result )
488
+ result = [val[0]]
489
+ result
490
+ end
491
+ .,.,
492
+
493
+ module_eval <<'.,.,', 'lib/doily/parser.y', 84
494
+ def _reduce_37( val, _values, result )
495
+ result = [val[0]] + val[2]
496
+ result
497
+ end
498
+ .,.,
499
+
500
+ module_eval <<'.,.,', 'lib/doily/parser.y', 88
501
+ def _reduce_38( val, _values, result )
502
+ result = Assignment.new(val[0], val[2])
503
+ result
504
+ end
505
+ .,.,
506
+
507
+ module_eval <<'.,.,', 'lib/doily/parser.y', 92
508
+ def _reduce_39( val, _values, result )
509
+ result = Declaration.new(val[1])
510
+ result
511
+ end
512
+ .,.,
513
+
514
+ module_eval <<'.,.,', 'lib/doily/parser.y', 96
515
+ def _reduce_40( val, _values, result )
516
+ result = Call.new(Access.new(val[0], Literal.new(val[1])), [val[2]])
517
+ result
518
+ end
519
+ .,.,
520
+
521
+ module_eval <<'.,.,', 'lib/doily/parser.y', 100
522
+ def _reduce_41( val, _values, result )
523
+ result = Assignment.new(val[0], Call.new(Access.new(val[0], Literal.new('+')), [Literal.new(1)]))
524
+ result
525
+ end
526
+ .,.,
527
+
528
+ def _reduce_none( val, _values, result )
529
+ result
530
+ end
531
+
532
+ end # class Parser
533
+
534
+ end # module Doily