ustate-client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.markdown +111 -0
- data/lib/ustate/client/query.rb +17 -0
- data/lib/ustate/client.rb +108 -0
- data/lib/ustate/dash/config.rb +0 -0
- data/lib/ustate/dash/controller/css.rb +5 -0
- data/lib/ustate/dash/controller/index.rb +5 -0
- data/lib/ustate/dash/helper/renderer.rb +209 -0
- data/lib/ustate/dash/state.rb +75 -0
- data/lib/ustate/dash/views/css.scss +39 -0
- data/lib/ustate/dash/views/index.erubis +3 -0
- data/lib/ustate/dash/views/layout.erubis +16 -0
- data/lib/ustate/dash.rb +111 -0
- data/lib/ustate/message.rb +16 -0
- data/lib/ustate/query.rb +7 -0
- data/lib/ustate/query_string.rb +1066 -0
- data/lib/ustate/query_string.treetop +116 -0
- data/lib/ustate/server/backends/base.rb +103 -0
- data/lib/ustate/server/backends/tcp.rb +33 -0
- data/lib/ustate/server/backends.rb +4 -0
- data/lib/ustate/server/connection.rb +82 -0
- data/lib/ustate/server/graphite.rb +11 -0
- data/lib/ustate/server/index.rb +134 -0
- data/lib/ustate/server.rb +66 -0
- data/lib/ustate/state.rb +18 -0
- data/lib/ustate/version.rb +3 -0
- data/lib/ustate.rb +9 -0
- metadata +71 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
class UState::State
|
2
|
+
# Average a set of states together. Chooses the meane metric, the mode
|
3
|
+
# state, and the mean time. If init is provided, its values override (where present) the
|
4
|
+
# computed ones.
|
5
|
+
def average(states, init = State.new)
|
6
|
+
# Metric
|
7
|
+
init.metric ||= begin
|
8
|
+
states.inject(0) { |a, state|
|
9
|
+
a + (state.metric || 0)
|
10
|
+
} / states.size
|
11
|
+
rescue
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# State
|
16
|
+
init.state ||= states.inject(Hash.new(0)) do |counts, s|
|
17
|
+
counts[s.state] += 1
|
18
|
+
counts
|
19
|
+
end.sort_by { |state, count| count }.first.first rescue nil
|
20
|
+
|
21
|
+
init.time ||= begin
|
22
|
+
states.inject(0) do |a, state|
|
23
|
+
a + state.time.to_f
|
24
|
+
end / states.size
|
25
|
+
rescue
|
26
|
+
end
|
27
|
+
|
28
|
+
init
|
29
|
+
end
|
30
|
+
|
31
|
+
# Finds the maximum of a set of states. Metric is the maximum. State is the highest,
|
32
|
+
# as defined by Dash.config.state_order. Time is the mean.
|
33
|
+
def max(states, init = {})
|
34
|
+
init.metric ||= states.inject(0) { |a, state|
|
35
|
+
a + (state.metric || 0)
|
36
|
+
}
|
37
|
+
|
38
|
+
init.state] ||= states.inject(nil) do |max, state|
|
39
|
+
state.state if Dash.config[:state_order][state.state] > Dash.config[:state_order][max]
|
40
|
+
end
|
41
|
+
|
42
|
+
init.time ||= begin
|
43
|
+
states.inject(0) { |a, state|
|
44
|
+
a + state.time.to_f
|
45
|
+
} / states.size
|
46
|
+
rescue
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
init
|
51
|
+
end
|
52
|
+
|
53
|
+
# Partition a list of states by a field
|
54
|
+
# Returns a hash of field_value => state
|
55
|
+
def partition(states, field)
|
56
|
+
states.inject(Hash.new { [] }) do |p, state|
|
57
|
+
p[state.send(field)] << state
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Sorts states by a field. nil values first.
|
62
|
+
def sort(states, field)
|
63
|
+
states.sort do |a, b|
|
64
|
+
a = a.send field
|
65
|
+
b = b.send field
|
66
|
+
if a.nil?
|
67
|
+
-1
|
68
|
+
elsif b.nil?
|
69
|
+
1
|
70
|
+
else
|
71
|
+
a <=> b
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
html,table {
|
2
|
+
font-family: Helvetica Nueue, Helvetica, sans;
|
3
|
+
font-size: 8pt;
|
4
|
+
}
|
5
|
+
h1 {
|
6
|
+
margin-bottom: 0.2em;
|
7
|
+
}
|
8
|
+
h2 {
|
9
|
+
margin-top: 0;
|
10
|
+
margin-bottom: 0.1em;
|
11
|
+
}
|
12
|
+
|
13
|
+
.box {
|
14
|
+
float: left;
|
15
|
+
margin: 4px;
|
16
|
+
}
|
17
|
+
|
18
|
+
.ok {
|
19
|
+
background: #B8F1BC;
|
20
|
+
}
|
21
|
+
.warning {
|
22
|
+
background: #F7D18E;
|
23
|
+
}
|
24
|
+
.critical {
|
25
|
+
background: #FF3C43;
|
26
|
+
}
|
27
|
+
|
28
|
+
.chart {
|
29
|
+
width: 140px;
|
30
|
+
border: 1px solid #ccc;
|
31
|
+
}
|
32
|
+
.chart td {
|
33
|
+
min-width: 40px;
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
36
|
+
.chart th {
|
37
|
+
width: 1px;
|
38
|
+
text-align: left;
|
39
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Dashboard</title>
|
4
|
+
<meta http-equiv="refresh" content="1" />
|
5
|
+
<link rel="stylesheet" type="text/css" href="/css" />
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body>
|
9
|
+
<div>
|
10
|
+
<h1>Dashboard</h1>
|
11
|
+
<span style="position: absolute; top: 4px; right: 4px;">(as of <%= time Time.now.to_i %>)</span>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= yield %>
|
15
|
+
</body>
|
16
|
+
</html>
|
data/lib/ustate/dash.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module UState
|
4
|
+
class Dash < Sinatra::Base
|
5
|
+
# A little dashboard sinatra application.
|
6
|
+
|
7
|
+
require 'yaml'
|
8
|
+
require 'find'
|
9
|
+
require 'ustate/client'
|
10
|
+
require 'erubis'
|
11
|
+
require 'sass'
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config ||= {
|
15
|
+
client: {},
|
16
|
+
age_scale: 60 * 30,
|
17
|
+
state_order: {
|
18
|
+
'critical' => 3,
|
19
|
+
'warning' => 2,
|
20
|
+
'ok' => 1
|
21
|
+
},
|
22
|
+
strftime: '%H:%M:%S',
|
23
|
+
controllers: [File.join(File.dirname(__FILE__), 'dash', 'controller')],
|
24
|
+
helpers: [File.join(File.dirname(__FILE__), 'dash', 'helper')],
|
25
|
+
views: 'views'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.client
|
30
|
+
@client ||= UState::Client.new(config[:client])
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.load
|
34
|
+
load_config
|
35
|
+
config[:controllers].each { |d| load_controllers d }
|
36
|
+
config[:helpers].each { |d| load_helpers d }
|
37
|
+
set :views, File.expand_path(config[:views])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Executes the configuration file.
|
41
|
+
def self.load_config
|
42
|
+
instance_eval File.read('config.rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
# Load controllers.
|
46
|
+
# Controllers can be regular old one-file-per-class, but if you prefer a little
|
47
|
+
# more modularity, this method will allow you to define all controller methods
|
48
|
+
# in their own files. For example, get "/posts/*/edit" can live in
|
49
|
+
# controller/posts/_/edit.rb. The sorting system provided here requires
|
50
|
+
# files in the correct order to handle wildcards appropriately.
|
51
|
+
def self.load_controllers(dir)
|
52
|
+
rbs = []
|
53
|
+
Find.find(
|
54
|
+
File.expand_path(dir)
|
55
|
+
) do |path|
|
56
|
+
rbs << path if path =~ /\.rb$/
|
57
|
+
end
|
58
|
+
|
59
|
+
# Sort paths with _ last, becase those are wildcards.
|
60
|
+
rbs.sort! do |a, b|
|
61
|
+
as = a.split File::SEPARATOR
|
62
|
+
bs = b.split File::SEPARATOR
|
63
|
+
|
64
|
+
# Compare common subpaths
|
65
|
+
l = [as.size, bs.size].min
|
66
|
+
catch :x do
|
67
|
+
(0...l).each do |i|
|
68
|
+
a, b = as[i], bs[i]
|
69
|
+
if a[/^_/] and not b[/^_/]
|
70
|
+
throw :x, 1
|
71
|
+
elsif b[/^_/] and not a[/^_/]
|
72
|
+
throw :x, -1
|
73
|
+
elsif ord = (a <=> b) and ord != 0
|
74
|
+
throw :x, ord
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# All subpaths are identical; sort longest first
|
79
|
+
if as.size > bs.size
|
80
|
+
throw :x, -1
|
81
|
+
elsif as.size < bs.size
|
82
|
+
throw :x, -1
|
83
|
+
else
|
84
|
+
throw :x, 0
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
rbs.each do |r|
|
90
|
+
require r
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Load helpers
|
95
|
+
def self.load_helpers(dir)
|
96
|
+
Find.find(
|
97
|
+
File.expand_path(dir)
|
98
|
+
) do |path|
|
99
|
+
require path if path =~ /\.rb$/
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def client
|
104
|
+
self.class.client
|
105
|
+
end
|
106
|
+
|
107
|
+
def query(*a)
|
108
|
+
self.class.client.query(*a).states || []
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module UState
|
2
|
+
class Message
|
3
|
+
include Beefcake::Message
|
4
|
+
|
5
|
+
optional :ok, :bool, 2
|
6
|
+
optional :error, :string, 3
|
7
|
+
repeated :states, State, 4
|
8
|
+
optional :query, Query, 5
|
9
|
+
|
10
|
+
def encode_with_length
|
11
|
+
buffer = ''
|
12
|
+
encoded = encode buffer
|
13
|
+
"#{[encoded.length].pack('N')}#{encoded}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/ustate/query.rb
ADDED
@@ -0,0 +1,1066 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
module UState
|
5
|
+
module QueryString
|
6
|
+
include Treetop::Runtime
|
7
|
+
|
8
|
+
def root
|
9
|
+
@root ||= :or
|
10
|
+
end
|
11
|
+
|
12
|
+
module Or0
|
13
|
+
def space1
|
14
|
+
elements[0]
|
15
|
+
end
|
16
|
+
|
17
|
+
def space2
|
18
|
+
elements[2]
|
19
|
+
end
|
20
|
+
|
21
|
+
def and
|
22
|
+
elements[3]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Or1
|
27
|
+
def first
|
28
|
+
elements[0]
|
29
|
+
end
|
30
|
+
|
31
|
+
def rest
|
32
|
+
elements[1]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Or2
|
37
|
+
def sql
|
38
|
+
rest.elements.map { |x| x.and }.
|
39
|
+
inject(first.sql) do |a, sub|
|
40
|
+
a | sub.sql
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def _nt_or
|
46
|
+
start_index = index
|
47
|
+
if node_cache[:or].has_key?(index)
|
48
|
+
cached = node_cache[:or][index]
|
49
|
+
if cached
|
50
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
51
|
+
@index = cached.interval.end
|
52
|
+
end
|
53
|
+
return cached
|
54
|
+
end
|
55
|
+
|
56
|
+
i0, s0 = index, []
|
57
|
+
r1 = _nt_and
|
58
|
+
s0 << r1
|
59
|
+
if r1
|
60
|
+
s2, i2 = [], index
|
61
|
+
loop do
|
62
|
+
i3, s3 = index, []
|
63
|
+
r4 = _nt_space
|
64
|
+
s3 << r4
|
65
|
+
if r4
|
66
|
+
if has_terminal?('or', false, index)
|
67
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
68
|
+
@index += 2
|
69
|
+
else
|
70
|
+
terminal_parse_failure('or')
|
71
|
+
r5 = nil
|
72
|
+
end
|
73
|
+
s3 << r5
|
74
|
+
if r5
|
75
|
+
r6 = _nt_space
|
76
|
+
s3 << r6
|
77
|
+
if r6
|
78
|
+
r7 = _nt_and
|
79
|
+
s3 << r7
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
if s3.last
|
84
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
85
|
+
r3.extend(Or0)
|
86
|
+
else
|
87
|
+
@index = i3
|
88
|
+
r3 = nil
|
89
|
+
end
|
90
|
+
if r3
|
91
|
+
s2 << r3
|
92
|
+
else
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
97
|
+
s0 << r2
|
98
|
+
end
|
99
|
+
if s0.last
|
100
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
101
|
+
r0.extend(Or1)
|
102
|
+
r0.extend(Or2)
|
103
|
+
else
|
104
|
+
@index = i0
|
105
|
+
r0 = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
node_cache[:or][start_index] = r0
|
109
|
+
|
110
|
+
r0
|
111
|
+
end
|
112
|
+
|
113
|
+
module And0
|
114
|
+
def space1
|
115
|
+
elements[0]
|
116
|
+
end
|
117
|
+
|
118
|
+
def space2
|
119
|
+
elements[2]
|
120
|
+
end
|
121
|
+
|
122
|
+
def primary
|
123
|
+
elements[3]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
module And1
|
128
|
+
def first
|
129
|
+
elements[0]
|
130
|
+
end
|
131
|
+
|
132
|
+
def rest
|
133
|
+
elements[1]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
module And2
|
138
|
+
def sql
|
139
|
+
rest.elements.map { |x| x.primary }.
|
140
|
+
inject(first.sql) do |a, sub|
|
141
|
+
a & sub.sql
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def _nt_and
|
147
|
+
start_index = index
|
148
|
+
if node_cache[:and].has_key?(index)
|
149
|
+
cached = node_cache[:and][index]
|
150
|
+
if cached
|
151
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
152
|
+
@index = cached.interval.end
|
153
|
+
end
|
154
|
+
return cached
|
155
|
+
end
|
156
|
+
|
157
|
+
i0, s0 = index, []
|
158
|
+
r1 = _nt_primary
|
159
|
+
s0 << r1
|
160
|
+
if r1
|
161
|
+
s2, i2 = [], index
|
162
|
+
loop do
|
163
|
+
i3, s3 = index, []
|
164
|
+
r4 = _nt_space
|
165
|
+
s3 << r4
|
166
|
+
if r4
|
167
|
+
if has_terminal?('and', false, index)
|
168
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
169
|
+
@index += 3
|
170
|
+
else
|
171
|
+
terminal_parse_failure('and')
|
172
|
+
r5 = nil
|
173
|
+
end
|
174
|
+
s3 << r5
|
175
|
+
if r5
|
176
|
+
r6 = _nt_space
|
177
|
+
s3 << r6
|
178
|
+
if r6
|
179
|
+
r7 = _nt_primary
|
180
|
+
s3 << r7
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
if s3.last
|
185
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
186
|
+
r3.extend(And0)
|
187
|
+
else
|
188
|
+
@index = i3
|
189
|
+
r3 = nil
|
190
|
+
end
|
191
|
+
if r3
|
192
|
+
s2 << r3
|
193
|
+
else
|
194
|
+
break
|
195
|
+
end
|
196
|
+
end
|
197
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
198
|
+
s0 << r2
|
199
|
+
end
|
200
|
+
if s0.last
|
201
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
202
|
+
r0.extend(And1)
|
203
|
+
r0.extend(And2)
|
204
|
+
else
|
205
|
+
@index = i0
|
206
|
+
r0 = nil
|
207
|
+
end
|
208
|
+
|
209
|
+
node_cache[:and][start_index] = r0
|
210
|
+
|
211
|
+
r0
|
212
|
+
end
|
213
|
+
|
214
|
+
module Primary0
|
215
|
+
def x
|
216
|
+
elements[2]
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
module Primary1
|
222
|
+
def sql
|
223
|
+
x.sql
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def _nt_primary
|
228
|
+
start_index = index
|
229
|
+
if node_cache[:primary].has_key?(index)
|
230
|
+
cached = node_cache[:primary][index]
|
231
|
+
if cached
|
232
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
233
|
+
@index = cached.interval.end
|
234
|
+
end
|
235
|
+
return cached
|
236
|
+
end
|
237
|
+
|
238
|
+
i0 = index
|
239
|
+
i1, s1 = index, []
|
240
|
+
if has_terminal?('(', false, index)
|
241
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
242
|
+
@index += 1
|
243
|
+
else
|
244
|
+
terminal_parse_failure('(')
|
245
|
+
r2 = nil
|
246
|
+
end
|
247
|
+
s1 << r2
|
248
|
+
if r2
|
249
|
+
r4 = _nt_space
|
250
|
+
if r4
|
251
|
+
r3 = r4
|
252
|
+
else
|
253
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
254
|
+
end
|
255
|
+
s1 << r3
|
256
|
+
if r3
|
257
|
+
r5 = _nt_or
|
258
|
+
s1 << r5
|
259
|
+
if r5
|
260
|
+
r7 = _nt_space
|
261
|
+
if r7
|
262
|
+
r6 = r7
|
263
|
+
else
|
264
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
265
|
+
end
|
266
|
+
s1 << r6
|
267
|
+
if r6
|
268
|
+
if has_terminal?(')', false, index)
|
269
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
270
|
+
@index += 1
|
271
|
+
else
|
272
|
+
terminal_parse_failure(')')
|
273
|
+
r8 = nil
|
274
|
+
end
|
275
|
+
s1 << r8
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
if s1.last
|
281
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
282
|
+
r1.extend(Primary0)
|
283
|
+
r1.extend(Primary1)
|
284
|
+
else
|
285
|
+
@index = i1
|
286
|
+
r1 = nil
|
287
|
+
end
|
288
|
+
if r1
|
289
|
+
r0 = r1
|
290
|
+
else
|
291
|
+
r9 = _nt_predicate
|
292
|
+
if r9
|
293
|
+
r0 = r9
|
294
|
+
else
|
295
|
+
@index = i0
|
296
|
+
r0 = nil
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
node_cache[:primary][start_index] = r0
|
301
|
+
|
302
|
+
r0
|
303
|
+
end
|
304
|
+
|
305
|
+
def _nt_predicate
|
306
|
+
start_index = index
|
307
|
+
if node_cache[:predicate].has_key?(index)
|
308
|
+
cached = node_cache[:predicate][index]
|
309
|
+
if cached
|
310
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
311
|
+
@index = cached.interval.end
|
312
|
+
end
|
313
|
+
return cached
|
314
|
+
end
|
315
|
+
|
316
|
+
i0 = index
|
317
|
+
r1 = _nt_equals
|
318
|
+
if r1
|
319
|
+
r0 = r1
|
320
|
+
else
|
321
|
+
r2 = _nt_not_equals
|
322
|
+
if r2
|
323
|
+
r0 = r2
|
324
|
+
else
|
325
|
+
r3 = _nt_approximately
|
326
|
+
if r3
|
327
|
+
r0 = r3
|
328
|
+
else
|
329
|
+
@index = i0
|
330
|
+
r0 = nil
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
node_cache[:predicate][start_index] = r0
|
336
|
+
|
337
|
+
r0
|
338
|
+
end
|
339
|
+
|
340
|
+
module Approximately0
|
341
|
+
def field
|
342
|
+
elements[0]
|
343
|
+
end
|
344
|
+
|
345
|
+
def string
|
346
|
+
elements[4]
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
module Approximately1
|
351
|
+
def sql
|
352
|
+
Sequel::SQL::StringExpression.like field.sql, string.sql
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
def _nt_approximately
|
357
|
+
start_index = index
|
358
|
+
if node_cache[:approximately].has_key?(index)
|
359
|
+
cached = node_cache[:approximately][index]
|
360
|
+
if cached
|
361
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
362
|
+
@index = cached.interval.end
|
363
|
+
end
|
364
|
+
return cached
|
365
|
+
end
|
366
|
+
|
367
|
+
i0, s0 = index, []
|
368
|
+
r1 = _nt_field
|
369
|
+
s0 << r1
|
370
|
+
if r1
|
371
|
+
r3 = _nt_space
|
372
|
+
if r3
|
373
|
+
r2 = r3
|
374
|
+
else
|
375
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
376
|
+
end
|
377
|
+
s0 << r2
|
378
|
+
if r2
|
379
|
+
if has_terminal?('=~', false, index)
|
380
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
381
|
+
@index += 2
|
382
|
+
else
|
383
|
+
terminal_parse_failure('=~')
|
384
|
+
r4 = nil
|
385
|
+
end
|
386
|
+
s0 << r4
|
387
|
+
if r4
|
388
|
+
r6 = _nt_space
|
389
|
+
if r6
|
390
|
+
r5 = r6
|
391
|
+
else
|
392
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
393
|
+
end
|
394
|
+
s0 << r5
|
395
|
+
if r5
|
396
|
+
r7 = _nt_string
|
397
|
+
s0 << r7
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
402
|
+
if s0.last
|
403
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
404
|
+
r0.extend(Approximately0)
|
405
|
+
r0.extend(Approximately1)
|
406
|
+
else
|
407
|
+
@index = i0
|
408
|
+
r0 = nil
|
409
|
+
end
|
410
|
+
|
411
|
+
node_cache[:approximately][start_index] = r0
|
412
|
+
|
413
|
+
r0
|
414
|
+
end
|
415
|
+
|
416
|
+
module NotEquals0
|
417
|
+
def field
|
418
|
+
elements[0]
|
419
|
+
end
|
420
|
+
|
421
|
+
def value
|
422
|
+
elements[4]
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
module NotEquals1
|
427
|
+
def sql
|
428
|
+
Sequel::SQL::BooleanExpression.from_value_pairs({field.sql => value.sql}, :AND, true)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def _nt_not_equals
|
433
|
+
start_index = index
|
434
|
+
if node_cache[:not_equals].has_key?(index)
|
435
|
+
cached = node_cache[:not_equals][index]
|
436
|
+
if cached
|
437
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
438
|
+
@index = cached.interval.end
|
439
|
+
end
|
440
|
+
return cached
|
441
|
+
end
|
442
|
+
|
443
|
+
i0, s0 = index, []
|
444
|
+
r1 = _nt_field
|
445
|
+
s0 << r1
|
446
|
+
if r1
|
447
|
+
r3 = _nt_space
|
448
|
+
if r3
|
449
|
+
r2 = r3
|
450
|
+
else
|
451
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
452
|
+
end
|
453
|
+
s0 << r2
|
454
|
+
if r2
|
455
|
+
if has_terminal?('!=', false, index)
|
456
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
457
|
+
@index += 2
|
458
|
+
else
|
459
|
+
terminal_parse_failure('!=')
|
460
|
+
r4 = nil
|
461
|
+
end
|
462
|
+
s0 << r4
|
463
|
+
if r4
|
464
|
+
r6 = _nt_space
|
465
|
+
if r6
|
466
|
+
r5 = r6
|
467
|
+
else
|
468
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
469
|
+
end
|
470
|
+
s0 << r5
|
471
|
+
if r5
|
472
|
+
r7 = _nt_value
|
473
|
+
s0 << r7
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
if s0.last
|
479
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
480
|
+
r0.extend(NotEquals0)
|
481
|
+
r0.extend(NotEquals1)
|
482
|
+
else
|
483
|
+
@index = i0
|
484
|
+
r0 = nil
|
485
|
+
end
|
486
|
+
|
487
|
+
node_cache[:not_equals][start_index] = r0
|
488
|
+
|
489
|
+
r0
|
490
|
+
end
|
491
|
+
|
492
|
+
module Equals0
|
493
|
+
def field
|
494
|
+
elements[0]
|
495
|
+
end
|
496
|
+
|
497
|
+
def value
|
498
|
+
elements[4]
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
module Equals1
|
503
|
+
def sql
|
504
|
+
Sequel::SQL::BooleanExpression.from_value_pairs field.sql => value.sql
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
def _nt_equals
|
509
|
+
start_index = index
|
510
|
+
if node_cache[:equals].has_key?(index)
|
511
|
+
cached = node_cache[:equals][index]
|
512
|
+
if cached
|
513
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
514
|
+
@index = cached.interval.end
|
515
|
+
end
|
516
|
+
return cached
|
517
|
+
end
|
518
|
+
|
519
|
+
i0, s0 = index, []
|
520
|
+
r1 = _nt_field
|
521
|
+
s0 << r1
|
522
|
+
if r1
|
523
|
+
r3 = _nt_space
|
524
|
+
if r3
|
525
|
+
r2 = r3
|
526
|
+
else
|
527
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
528
|
+
end
|
529
|
+
s0 << r2
|
530
|
+
if r2
|
531
|
+
i4 = index
|
532
|
+
if has_terminal?('=', false, index)
|
533
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
534
|
+
@index += 1
|
535
|
+
else
|
536
|
+
terminal_parse_failure('=')
|
537
|
+
r5 = nil
|
538
|
+
end
|
539
|
+
if r5
|
540
|
+
r4 = r5
|
541
|
+
else
|
542
|
+
if has_terminal?('==', false, index)
|
543
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
544
|
+
@index += 2
|
545
|
+
else
|
546
|
+
terminal_parse_failure('==')
|
547
|
+
r6 = nil
|
548
|
+
end
|
549
|
+
if r6
|
550
|
+
r4 = r6
|
551
|
+
else
|
552
|
+
@index = i4
|
553
|
+
r4 = nil
|
554
|
+
end
|
555
|
+
end
|
556
|
+
s0 << r4
|
557
|
+
if r4
|
558
|
+
r8 = _nt_space
|
559
|
+
if r8
|
560
|
+
r7 = r8
|
561
|
+
else
|
562
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
563
|
+
end
|
564
|
+
s0 << r7
|
565
|
+
if r7
|
566
|
+
r9 = _nt_value
|
567
|
+
s0 << r9
|
568
|
+
end
|
569
|
+
end
|
570
|
+
end
|
571
|
+
end
|
572
|
+
if s0.last
|
573
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
574
|
+
r0.extend(Equals0)
|
575
|
+
r0.extend(Equals1)
|
576
|
+
else
|
577
|
+
@index = i0
|
578
|
+
r0 = nil
|
579
|
+
end
|
580
|
+
|
581
|
+
node_cache[:equals][start_index] = r0
|
582
|
+
|
583
|
+
r0
|
584
|
+
end
|
585
|
+
|
586
|
+
def _nt_value
|
587
|
+
start_index = index
|
588
|
+
if node_cache[:value].has_key?(index)
|
589
|
+
cached = node_cache[:value][index]
|
590
|
+
if cached
|
591
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
592
|
+
@index = cached.interval.end
|
593
|
+
end
|
594
|
+
return cached
|
595
|
+
end
|
596
|
+
|
597
|
+
i0 = index
|
598
|
+
r1 = _nt_double_quoted_string
|
599
|
+
if r1
|
600
|
+
r0 = r1
|
601
|
+
else
|
602
|
+
r2 = _nt_float
|
603
|
+
if r2
|
604
|
+
r0 = r2
|
605
|
+
else
|
606
|
+
r3 = _nt_integer
|
607
|
+
if r3
|
608
|
+
r0 = r3
|
609
|
+
else
|
610
|
+
@index = i0
|
611
|
+
r0 = nil
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
node_cache[:value][start_index] = r0
|
617
|
+
|
618
|
+
r0
|
619
|
+
end
|
620
|
+
|
621
|
+
module Integer0
|
622
|
+
end
|
623
|
+
|
624
|
+
module Integer1
|
625
|
+
def ruby_value
|
626
|
+
Integer(text_value)
|
627
|
+
end
|
628
|
+
alias sql ruby_value
|
629
|
+
end
|
630
|
+
|
631
|
+
def _nt_integer
|
632
|
+
start_index = index
|
633
|
+
if node_cache[:integer].has_key?(index)
|
634
|
+
cached = node_cache[:integer][index]
|
635
|
+
if cached
|
636
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
637
|
+
@index = cached.interval.end
|
638
|
+
end
|
639
|
+
return cached
|
640
|
+
end
|
641
|
+
|
642
|
+
i0, s0 = index, []
|
643
|
+
if has_terminal?('-', false, index)
|
644
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
645
|
+
@index += 1
|
646
|
+
else
|
647
|
+
terminal_parse_failure('-')
|
648
|
+
r2 = nil
|
649
|
+
end
|
650
|
+
if r2
|
651
|
+
r1 = r2
|
652
|
+
else
|
653
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
654
|
+
end
|
655
|
+
s0 << r1
|
656
|
+
if r1
|
657
|
+
s3, i3 = [], index
|
658
|
+
loop do
|
659
|
+
if has_terminal?('\G[0-9]', true, index)
|
660
|
+
r4 = true
|
661
|
+
@index += 1
|
662
|
+
else
|
663
|
+
r4 = nil
|
664
|
+
end
|
665
|
+
if r4
|
666
|
+
s3 << r4
|
667
|
+
else
|
668
|
+
break
|
669
|
+
end
|
670
|
+
end
|
671
|
+
if s3.empty?
|
672
|
+
@index = i3
|
673
|
+
r3 = nil
|
674
|
+
else
|
675
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
676
|
+
end
|
677
|
+
s0 << r3
|
678
|
+
end
|
679
|
+
if s0.last
|
680
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
681
|
+
r0.extend(Integer0)
|
682
|
+
r0.extend(Integer1)
|
683
|
+
else
|
684
|
+
@index = i0
|
685
|
+
r0 = nil
|
686
|
+
end
|
687
|
+
|
688
|
+
node_cache[:integer][start_index] = r0
|
689
|
+
|
690
|
+
r0
|
691
|
+
end
|
692
|
+
|
693
|
+
module Float0
|
694
|
+
end
|
695
|
+
|
696
|
+
module Float1
|
697
|
+
def ruby_value
|
698
|
+
Float(text_value)
|
699
|
+
end
|
700
|
+
|
701
|
+
alias sql ruby_value
|
702
|
+
end
|
703
|
+
|
704
|
+
def _nt_float
|
705
|
+
start_index = index
|
706
|
+
if node_cache[:float].has_key?(index)
|
707
|
+
cached = node_cache[:float][index]
|
708
|
+
if cached
|
709
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
710
|
+
@index = cached.interval.end
|
711
|
+
end
|
712
|
+
return cached
|
713
|
+
end
|
714
|
+
|
715
|
+
i0, s0 = index, []
|
716
|
+
if has_terminal?('-', false, index)
|
717
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
718
|
+
@index += 1
|
719
|
+
else
|
720
|
+
terminal_parse_failure('-')
|
721
|
+
r2 = nil
|
722
|
+
end
|
723
|
+
if r2
|
724
|
+
r1 = r2
|
725
|
+
else
|
726
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
727
|
+
end
|
728
|
+
s0 << r1
|
729
|
+
if r1
|
730
|
+
s3, i3 = [], index
|
731
|
+
loop do
|
732
|
+
if has_terminal?('\G[0-9]', true, index)
|
733
|
+
r4 = true
|
734
|
+
@index += 1
|
735
|
+
else
|
736
|
+
r4 = nil
|
737
|
+
end
|
738
|
+
if r4
|
739
|
+
s3 << r4
|
740
|
+
else
|
741
|
+
break
|
742
|
+
end
|
743
|
+
end
|
744
|
+
if s3.empty?
|
745
|
+
@index = i3
|
746
|
+
r3 = nil
|
747
|
+
else
|
748
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
749
|
+
end
|
750
|
+
s0 << r3
|
751
|
+
if r3
|
752
|
+
if has_terminal?('.', false, index)
|
753
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
754
|
+
@index += 1
|
755
|
+
else
|
756
|
+
terminal_parse_failure('.')
|
757
|
+
r5 = nil
|
758
|
+
end
|
759
|
+
s0 << r5
|
760
|
+
if r5
|
761
|
+
s6, i6 = [], index
|
762
|
+
loop do
|
763
|
+
if has_terminal?('\G[0-9]', true, index)
|
764
|
+
r7 = true
|
765
|
+
@index += 1
|
766
|
+
else
|
767
|
+
r7 = nil
|
768
|
+
end
|
769
|
+
if r7
|
770
|
+
s6 << r7
|
771
|
+
else
|
772
|
+
break
|
773
|
+
end
|
774
|
+
end
|
775
|
+
if s6.empty?
|
776
|
+
@index = i6
|
777
|
+
r6 = nil
|
778
|
+
else
|
779
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
780
|
+
end
|
781
|
+
s0 << r6
|
782
|
+
end
|
783
|
+
end
|
784
|
+
end
|
785
|
+
if s0.last
|
786
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
787
|
+
r0.extend(Float0)
|
788
|
+
r0.extend(Float1)
|
789
|
+
else
|
790
|
+
@index = i0
|
791
|
+
r0 = nil
|
792
|
+
end
|
793
|
+
|
794
|
+
node_cache[:float][start_index] = r0
|
795
|
+
|
796
|
+
r0
|
797
|
+
end
|
798
|
+
|
799
|
+
module Field0
|
800
|
+
def sql
|
801
|
+
text_value.to_sym
|
802
|
+
end
|
803
|
+
end
|
804
|
+
|
805
|
+
def _nt_field
|
806
|
+
start_index = index
|
807
|
+
if node_cache[:field].has_key?(index)
|
808
|
+
cached = node_cache[:field][index]
|
809
|
+
if cached
|
810
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
811
|
+
@index = cached.interval.end
|
812
|
+
end
|
813
|
+
return cached
|
814
|
+
end
|
815
|
+
|
816
|
+
i0 = index
|
817
|
+
if has_terminal?("state", false, index)
|
818
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 5))
|
819
|
+
@index += 5
|
820
|
+
else
|
821
|
+
terminal_parse_failure("state")
|
822
|
+
r1 = nil
|
823
|
+
end
|
824
|
+
if r1
|
825
|
+
r0 = r1
|
826
|
+
r0.extend(Field0)
|
827
|
+
else
|
828
|
+
if has_terminal?("host", false, index)
|
829
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
830
|
+
@index += 4
|
831
|
+
else
|
832
|
+
terminal_parse_failure("host")
|
833
|
+
r2 = nil
|
834
|
+
end
|
835
|
+
if r2
|
836
|
+
r0 = r2
|
837
|
+
r0.extend(Field0)
|
838
|
+
else
|
839
|
+
if has_terminal?("service", false, index)
|
840
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 7))
|
841
|
+
@index += 7
|
842
|
+
else
|
843
|
+
terminal_parse_failure("service")
|
844
|
+
r3 = nil
|
845
|
+
end
|
846
|
+
if r3
|
847
|
+
r0 = r3
|
848
|
+
r0.extend(Field0)
|
849
|
+
else
|
850
|
+
if has_terminal?("description", false, index)
|
851
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 11))
|
852
|
+
@index += 11
|
853
|
+
else
|
854
|
+
terminal_parse_failure("description")
|
855
|
+
r4 = nil
|
856
|
+
end
|
857
|
+
if r4
|
858
|
+
r0 = r4
|
859
|
+
r0.extend(Field0)
|
860
|
+
else
|
861
|
+
if has_terminal?("metric_f", false, index)
|
862
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 8))
|
863
|
+
@index += 8
|
864
|
+
else
|
865
|
+
terminal_parse_failure("metric_f")
|
866
|
+
r5 = nil
|
867
|
+
end
|
868
|
+
if r5
|
869
|
+
r0 = r5
|
870
|
+
r0.extend(Field0)
|
871
|
+
else
|
872
|
+
@index = i0
|
873
|
+
r0 = nil
|
874
|
+
end
|
875
|
+
end
|
876
|
+
end
|
877
|
+
end
|
878
|
+
end
|
879
|
+
|
880
|
+
node_cache[:field][start_index] = r0
|
881
|
+
|
882
|
+
r0
|
883
|
+
end
|
884
|
+
|
885
|
+
def _nt_string
|
886
|
+
start_index = index
|
887
|
+
if node_cache[:string].has_key?(index)
|
888
|
+
cached = node_cache[:string][index]
|
889
|
+
if cached
|
890
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
891
|
+
@index = cached.interval.end
|
892
|
+
end
|
893
|
+
return cached
|
894
|
+
end
|
895
|
+
|
896
|
+
r0 = _nt_double_quoted_string
|
897
|
+
|
898
|
+
node_cache[:string][start_index] = r0
|
899
|
+
|
900
|
+
r0
|
901
|
+
end
|
902
|
+
|
903
|
+
module DoubleQuotedString0
|
904
|
+
end
|
905
|
+
|
906
|
+
module DoubleQuotedString1
|
907
|
+
end
|
908
|
+
|
909
|
+
module DoubleQuotedString2
|
910
|
+
def ruby_value
|
911
|
+
text_value[1..-2].gsub('\"', '"')
|
912
|
+
end
|
913
|
+
alias sql ruby_value
|
914
|
+
end
|
915
|
+
|
916
|
+
def _nt_double_quoted_string
|
917
|
+
start_index = index
|
918
|
+
if node_cache[:double_quoted_string].has_key?(index)
|
919
|
+
cached = node_cache[:double_quoted_string][index]
|
920
|
+
if cached
|
921
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
922
|
+
@index = cached.interval.end
|
923
|
+
end
|
924
|
+
return cached
|
925
|
+
end
|
926
|
+
|
927
|
+
i0, s0 = index, []
|
928
|
+
if has_terminal?('"', false, index)
|
929
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
930
|
+
@index += 1
|
931
|
+
else
|
932
|
+
terminal_parse_failure('"')
|
933
|
+
r1 = nil
|
934
|
+
end
|
935
|
+
s0 << r1
|
936
|
+
if r1
|
937
|
+
s2, i2 = [], index
|
938
|
+
loop do
|
939
|
+
i3 = index
|
940
|
+
i4, s4 = index, []
|
941
|
+
i5 = index
|
942
|
+
if has_terminal?('"', false, index)
|
943
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
944
|
+
@index += 1
|
945
|
+
else
|
946
|
+
terminal_parse_failure('"')
|
947
|
+
r6 = nil
|
948
|
+
end
|
949
|
+
if r6
|
950
|
+
r5 = nil
|
951
|
+
else
|
952
|
+
@index = i5
|
953
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
954
|
+
end
|
955
|
+
s4 << r5
|
956
|
+
if r5
|
957
|
+
if index < input_length
|
958
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
959
|
+
@index += 1
|
960
|
+
else
|
961
|
+
terminal_parse_failure("any character")
|
962
|
+
r7 = nil
|
963
|
+
end
|
964
|
+
s4 << r7
|
965
|
+
end
|
966
|
+
if s4.last
|
967
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
968
|
+
r4.extend(DoubleQuotedString0)
|
969
|
+
else
|
970
|
+
@index = i4
|
971
|
+
r4 = nil
|
972
|
+
end
|
973
|
+
if r4
|
974
|
+
r3 = r4
|
975
|
+
else
|
976
|
+
if has_terminal?('\"', false, index)
|
977
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
978
|
+
@index += 2
|
979
|
+
else
|
980
|
+
terminal_parse_failure('\"')
|
981
|
+
r8 = nil
|
982
|
+
end
|
983
|
+
if r8
|
984
|
+
r3 = r8
|
985
|
+
else
|
986
|
+
@index = i3
|
987
|
+
r3 = nil
|
988
|
+
end
|
989
|
+
end
|
990
|
+
if r3
|
991
|
+
s2 << r3
|
992
|
+
else
|
993
|
+
break
|
994
|
+
end
|
995
|
+
end
|
996
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
997
|
+
s0 << r2
|
998
|
+
if r2
|
999
|
+
if has_terminal?('"', false, index)
|
1000
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1001
|
+
@index += 1
|
1002
|
+
else
|
1003
|
+
terminal_parse_failure('"')
|
1004
|
+
r9 = nil
|
1005
|
+
end
|
1006
|
+
s0 << r9
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
if s0.last
|
1010
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1011
|
+
r0.extend(DoubleQuotedString1)
|
1012
|
+
r0.extend(DoubleQuotedString2)
|
1013
|
+
else
|
1014
|
+
@index = i0
|
1015
|
+
r0 = nil
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
node_cache[:double_quoted_string][start_index] = r0
|
1019
|
+
|
1020
|
+
r0
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
def _nt_space
|
1024
|
+
start_index = index
|
1025
|
+
if node_cache[:space].has_key?(index)
|
1026
|
+
cached = node_cache[:space][index]
|
1027
|
+
if cached
|
1028
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1029
|
+
@index = cached.interval.end
|
1030
|
+
end
|
1031
|
+
return cached
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
s0, i0 = [], index
|
1035
|
+
loop do
|
1036
|
+
if has_terminal?('\G[\\s]', true, index)
|
1037
|
+
r1 = true
|
1038
|
+
@index += 1
|
1039
|
+
else
|
1040
|
+
r1 = nil
|
1041
|
+
end
|
1042
|
+
if r1
|
1043
|
+
s0 << r1
|
1044
|
+
else
|
1045
|
+
break
|
1046
|
+
end
|
1047
|
+
end
|
1048
|
+
if s0.empty?
|
1049
|
+
@index = i0
|
1050
|
+
r0 = nil
|
1051
|
+
else
|
1052
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
node_cache[:space][start_index] = r0
|
1056
|
+
|
1057
|
+
r0
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
class QueryStringParser < Treetop::Runtime::CompiledParser
|
1063
|
+
include QueryString
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
end
|