ruby_jsonpath 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -0
- data/LICENSE +20 -0
- data/README.md +5 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/jsonpath.gemspec +54 -0
- data/lib/jsonpath.rb +22 -0
- data/lib/jsonpath/nodes.rb +216 -0
- data/lib/jsonpath/parser.rb +1854 -0
- data/lib/jsonpath/parser.treetop +106 -0
- data/test/parser_test.rb +180 -0
- data/test/reference_test.rb +136 -0
- data/test/test_helper.rb +37 -0
- metadata +93 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Bruce Williams
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "jsonpath"
|
8
|
+
gem.summary = %Q{JSONPath support for Ruby}
|
9
|
+
gem.email = "bruce@codefluency.com"
|
10
|
+
gem.homepage = "http://github.com/bruce/jsonpath"
|
11
|
+
gem.authors = ["Bruce Williams"]
|
12
|
+
gem.add_dependency 'treetop'
|
13
|
+
# gem is a Gem::Specification... see http:// www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
test.rcov_opts << '--exclude gems'
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION.yml')
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
48
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
+
else
|
50
|
+
version = ""
|
51
|
+
end
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "jsonpath #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
58
|
+
|
59
|
+
file 'lib/jsonpath/parser.rb' => 'lib/jsonpath/parser.treetop' do |t|
|
60
|
+
sh "tt 'lib/jsonpath/parser.treetop'"
|
61
|
+
end
|
62
|
+
|
63
|
+
task :treetop => 'lib/jsonpath/parser.rb'
|
64
|
+
|
65
|
+
|
66
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/jsonpath.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruby_jsonpath}
|
5
|
+
s.version = "1.0.1"
|
6
|
+
s.homepage = 'https://github.com/zhiyuchen/ruby_jsonpath'
|
7
|
+
s.description = "JSONPath support for Ruby"
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.authors = ["Zhiyu Chen"]
|
10
|
+
s.date = %q{2013-01-08}
|
11
|
+
s.email = %q{zhiyu@outlook.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.md"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".document",
|
18
|
+
"LICENSE",
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"jsonpath.gemspec",
|
23
|
+
"lib/jsonpath.rb",
|
24
|
+
"lib/jsonpath/nodes.rb",
|
25
|
+
"lib/jsonpath/parser.rb",
|
26
|
+
"lib/jsonpath/parser.treetop",
|
27
|
+
"test/parser_test.rb",
|
28
|
+
"test/reference_test.rb",
|
29
|
+
"test/test_helper.rb"
|
30
|
+
]
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.2}
|
35
|
+
s.summary = %q{JSONPath support for Ruby}
|
36
|
+
s.test_files = [
|
37
|
+
"test/parser_test.rb",
|
38
|
+
"test/reference_test.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<treetop>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<treetop>, [">= 0"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<treetop>, [">= 0"])
|
53
|
+
end
|
54
|
+
end
|
data/lib/jsonpath.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'treetop'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
require 'jsonpath/parser'
|
6
|
+
require 'jsonpath/nodes'
|
7
|
+
|
8
|
+
module JSONPath
|
9
|
+
|
10
|
+
Parser = ::JSONPathGrammarParser
|
11
|
+
class ParseError < ::SyntaxError; end
|
12
|
+
|
13
|
+
def self.lookup(obj, path)
|
14
|
+
parser = Parser.new
|
15
|
+
if (result = parser.parse(path))
|
16
|
+
result.walk(obj)
|
17
|
+
else
|
18
|
+
raise ParseError, parser.failure_reason
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
module JSONPath
|
2
|
+
|
3
|
+
module Nodes
|
4
|
+
|
5
|
+
class RootNode < Treetop::Runtime::SyntaxNode
|
6
|
+
def walk(object)
|
7
|
+
selectors.elements.inject([object]) do |reduce, selector|
|
8
|
+
selector.descend(*reduce)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class PathNode < Treetop::Runtime::SyntaxNode
|
14
|
+
|
15
|
+
def traversing_descendants?
|
16
|
+
respond_to?(:lower) && lower.text_value == '..'
|
17
|
+
end
|
18
|
+
|
19
|
+
def traverse(obj, &block)
|
20
|
+
if !respond_to?(:lower) || lower.text_value == '.'
|
21
|
+
obj.each(&block)
|
22
|
+
elsif lower.text_value == '..'
|
23
|
+
obj.each do |o|
|
24
|
+
recurse(o, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def recurse(obj, &block)
|
30
|
+
block.call(obj)
|
31
|
+
children = case obj
|
32
|
+
when Hash
|
33
|
+
obj.values
|
34
|
+
when Array
|
35
|
+
obj
|
36
|
+
else
|
37
|
+
return
|
38
|
+
end
|
39
|
+
children.each do |child|
|
40
|
+
recurse(child, &block)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class WildcardNode < PathNode
|
47
|
+
def descend(*objects)
|
48
|
+
results = []
|
49
|
+
traverse(objects) do |obj|
|
50
|
+
values = case obj
|
51
|
+
when Hash
|
52
|
+
obj.values
|
53
|
+
when Array
|
54
|
+
obj
|
55
|
+
else
|
56
|
+
next
|
57
|
+
end
|
58
|
+
results.push(*values)
|
59
|
+
# Note: I really don't like this special case. This happens
|
60
|
+
# because when wildcarding regularly, the results are the *children*,
|
61
|
+
# but when using a .. descendant selector, you want the main parent,
|
62
|
+
# too. According to the JSONPath docs, '$..*' means "All members of
|
63
|
+
# [the] JSON structure." Should this support Array, as well?
|
64
|
+
if obj.is_a?(Hash) && traversing_descendants?
|
65
|
+
results.push(obj) unless results.include?(obj)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
results
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class KeyNode < PathNode
|
73
|
+
|
74
|
+
# supports finding the key from self or child elements
|
75
|
+
def find_keys(node=self, results=[], checked=[])
|
76
|
+
if node.respond_to?(:key)
|
77
|
+
results << node.key.text_value
|
78
|
+
end
|
79
|
+
if node.elements && !node.elements.empty?
|
80
|
+
node.elements.each do |element|
|
81
|
+
find_keys(element, results)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
results
|
85
|
+
end
|
86
|
+
|
87
|
+
def descend(*objects)
|
88
|
+
results = []
|
89
|
+
keys = find_keys
|
90
|
+
traverse(objects) do |obj|
|
91
|
+
if obj.is_a?(Hash)
|
92
|
+
keys.each do |key|
|
93
|
+
if obj.key?(key)
|
94
|
+
results << obj[key]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
results
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class IndexNode < PathNode
|
104
|
+
def descend(*objects)
|
105
|
+
offset = Integer(index.text_value)
|
106
|
+
results = []
|
107
|
+
traverse(objects) do |obj|
|
108
|
+
if obj.is_a?(Array)
|
109
|
+
if obj.size > offset
|
110
|
+
results << obj[offset]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
results
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class SliceNode < PathNode
|
119
|
+
|
120
|
+
def descend(*objects)
|
121
|
+
results = []
|
122
|
+
traverse(objects) do |obj|
|
123
|
+
if obj.is_a?(Array)
|
124
|
+
values = obj[start_offset..stop_offset(obj)]
|
125
|
+
0.step(values.size - 1, step_size) do |n|
|
126
|
+
results << values[n]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
results
|
131
|
+
end
|
132
|
+
|
133
|
+
def start_offset
|
134
|
+
@start_offset ||= Integer(start.text_value)
|
135
|
+
end
|
136
|
+
|
137
|
+
def stop_offset(obj)
|
138
|
+
@stop_offset ||= if respond_to?(:stop)
|
139
|
+
Integer(stop.text_value)
|
140
|
+
else
|
141
|
+
obj.size
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def step_size
|
146
|
+
@step_size ||= if respond_to?(:step)
|
147
|
+
Integer(step.text_value)
|
148
|
+
else
|
149
|
+
1
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
class CodeNode < PathNode
|
156
|
+
|
157
|
+
def code
|
158
|
+
@code ||= begin
|
159
|
+
text = template_code.text_value
|
160
|
+
text.gsub('@', '(obj)').gsub('\\(obj)', '@')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def execute(obj)
|
165
|
+
eval(code, binding)
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
class ExprNode < CodeNode
|
171
|
+
|
172
|
+
def descend(*objects)
|
173
|
+
results = []
|
174
|
+
traverse(objects) do |obj|
|
175
|
+
res = execute(obj)
|
176
|
+
case obj
|
177
|
+
when Hash
|
178
|
+
next unless obj.key?(res)
|
179
|
+
when Array
|
180
|
+
next unless obj.size > res
|
181
|
+
else
|
182
|
+
next
|
183
|
+
end
|
184
|
+
results << obj[res]
|
185
|
+
end
|
186
|
+
results
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
class FilterNode < CodeNode
|
192
|
+
|
193
|
+
class Error < ::ArgumentError; end
|
194
|
+
|
195
|
+
def descend(*objects)
|
196
|
+
results = []
|
197
|
+
traverse(objects) do |set|
|
198
|
+
next unless set.is_a?(Array) || set.is_a?(Hash)
|
199
|
+
values = set.is_a?(Array) ? set : set.values
|
200
|
+
values.each do |obj|
|
201
|
+
begin
|
202
|
+
if execute(obj)
|
203
|
+
results << obj
|
204
|
+
end
|
205
|
+
rescue
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
results
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
@@ -0,0 +1,1854 @@
|
|
1
|
+
module JSONPathGrammar
|
2
|
+
include Treetop::Runtime
|
3
|
+
|
4
|
+
def root
|
5
|
+
@root || :path
|
6
|
+
end
|
7
|
+
|
8
|
+
module Path0
|
9
|
+
def root
|
10
|
+
elements[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def selectors
|
14
|
+
elements[1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def _nt_path
|
19
|
+
start_index = index
|
20
|
+
if node_cache[:path].has_key?(index)
|
21
|
+
cached = node_cache[:path][index]
|
22
|
+
@index = cached.interval.end if cached
|
23
|
+
return cached
|
24
|
+
end
|
25
|
+
|
26
|
+
i0, s0 = index, []
|
27
|
+
r1 = _nt_root
|
28
|
+
s0 << r1
|
29
|
+
if r1
|
30
|
+
s2, i2 = [], index
|
31
|
+
loop do
|
32
|
+
r3 = _nt_child
|
33
|
+
if r3
|
34
|
+
s2 << r3
|
35
|
+
else
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if s2.empty?
|
40
|
+
self.index = i2
|
41
|
+
r2 = nil
|
42
|
+
else
|
43
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
44
|
+
end
|
45
|
+
s0 << r2
|
46
|
+
end
|
47
|
+
if s0.last
|
48
|
+
r0 = instantiate_node(JSONPath::Nodes::RootNode,input, i0...index, s0)
|
49
|
+
r0.extend(Path0)
|
50
|
+
else
|
51
|
+
self.index = i0
|
52
|
+
r0 = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
node_cache[:path][start_index] = r0
|
56
|
+
|
57
|
+
return r0
|
58
|
+
end
|
59
|
+
|
60
|
+
def _nt_root
|
61
|
+
start_index = index
|
62
|
+
if node_cache[:root].has_key?(index)
|
63
|
+
cached = node_cache[:root][index]
|
64
|
+
@index = cached.interval.end if cached
|
65
|
+
return cached
|
66
|
+
end
|
67
|
+
|
68
|
+
if input.index('$', index) == index
|
69
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
70
|
+
@index += 1
|
71
|
+
else
|
72
|
+
terminal_parse_failure('$')
|
73
|
+
r0 = nil
|
74
|
+
end
|
75
|
+
|
76
|
+
node_cache[:root][start_index] = r0
|
77
|
+
|
78
|
+
return r0
|
79
|
+
end
|
80
|
+
|
81
|
+
module Number0
|
82
|
+
end
|
83
|
+
|
84
|
+
def _nt_number
|
85
|
+
start_index = index
|
86
|
+
if node_cache[:number].has_key?(index)
|
87
|
+
cached = node_cache[:number][index]
|
88
|
+
@index = cached.interval.end if cached
|
89
|
+
return cached
|
90
|
+
end
|
91
|
+
|
92
|
+
i0, s0 = index, []
|
93
|
+
if input.index('-', index) == index
|
94
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
95
|
+
@index += 1
|
96
|
+
else
|
97
|
+
terminal_parse_failure('-')
|
98
|
+
r2 = nil
|
99
|
+
end
|
100
|
+
if r2
|
101
|
+
r1 = r2
|
102
|
+
else
|
103
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
104
|
+
end
|
105
|
+
s0 << r1
|
106
|
+
if r1
|
107
|
+
s3, i3 = [], index
|
108
|
+
loop do
|
109
|
+
if input.index(Regexp.new('[0-9]'), index) == index
|
110
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
111
|
+
@index += 1
|
112
|
+
else
|
113
|
+
r4 = nil
|
114
|
+
end
|
115
|
+
if r4
|
116
|
+
s3 << r4
|
117
|
+
else
|
118
|
+
break
|
119
|
+
end
|
120
|
+
end
|
121
|
+
if s3.empty?
|
122
|
+
self.index = i3
|
123
|
+
r3 = nil
|
124
|
+
else
|
125
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
126
|
+
end
|
127
|
+
s0 << r3
|
128
|
+
end
|
129
|
+
if s0.last
|
130
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
131
|
+
r0.extend(Number0)
|
132
|
+
else
|
133
|
+
self.index = i0
|
134
|
+
r0 = nil
|
135
|
+
end
|
136
|
+
|
137
|
+
node_cache[:number][start_index] = r0
|
138
|
+
|
139
|
+
return r0
|
140
|
+
end
|
141
|
+
|
142
|
+
module Wildcard0
|
143
|
+
end
|
144
|
+
|
145
|
+
def _nt_wildcard
|
146
|
+
start_index = index
|
147
|
+
if node_cache[:wildcard].has_key?(index)
|
148
|
+
cached = node_cache[:wildcard][index]
|
149
|
+
@index = cached.interval.end if cached
|
150
|
+
return cached
|
151
|
+
end
|
152
|
+
|
153
|
+
i0 = index
|
154
|
+
if input.index('*', index) == index
|
155
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
156
|
+
@index += 1
|
157
|
+
else
|
158
|
+
terminal_parse_failure('*')
|
159
|
+
r1 = nil
|
160
|
+
end
|
161
|
+
if r1
|
162
|
+
r0 = r1
|
163
|
+
else
|
164
|
+
i2, s2 = index, []
|
165
|
+
if input.index('\'', index) == index
|
166
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
167
|
+
@index += 1
|
168
|
+
else
|
169
|
+
terminal_parse_failure('\'')
|
170
|
+
r3 = nil
|
171
|
+
end
|
172
|
+
s2 << r3
|
173
|
+
if r3
|
174
|
+
if input.index('*', index) == index
|
175
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
176
|
+
@index += 1
|
177
|
+
else
|
178
|
+
terminal_parse_failure('*')
|
179
|
+
r4 = nil
|
180
|
+
end
|
181
|
+
s2 << r4
|
182
|
+
if r4
|
183
|
+
if input.index('\'', index) == index
|
184
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
185
|
+
@index += 1
|
186
|
+
else
|
187
|
+
terminal_parse_failure('\'')
|
188
|
+
r5 = nil
|
189
|
+
end
|
190
|
+
s2 << r5
|
191
|
+
end
|
192
|
+
end
|
193
|
+
if s2.last
|
194
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
195
|
+
r2.extend(Wildcard0)
|
196
|
+
else
|
197
|
+
self.index = i2
|
198
|
+
r2 = nil
|
199
|
+
end
|
200
|
+
if r2
|
201
|
+
r0 = r2
|
202
|
+
else
|
203
|
+
self.index = i0
|
204
|
+
r0 = nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
node_cache[:wildcard][start_index] = r0
|
209
|
+
|
210
|
+
return r0
|
211
|
+
end
|
212
|
+
|
213
|
+
def _nt_lower
|
214
|
+
start_index = index
|
215
|
+
if node_cache[:lower].has_key?(index)
|
216
|
+
cached = node_cache[:lower][index]
|
217
|
+
@index = cached.interval.end if cached
|
218
|
+
return cached
|
219
|
+
end
|
220
|
+
|
221
|
+
i0 = index
|
222
|
+
r1 = _nt_descendant
|
223
|
+
if r1
|
224
|
+
r0 = r1
|
225
|
+
else
|
226
|
+
if input.index('.', index) == index
|
227
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
228
|
+
@index += 1
|
229
|
+
else
|
230
|
+
terminal_parse_failure('.')
|
231
|
+
r2 = nil
|
232
|
+
end
|
233
|
+
if r2
|
234
|
+
r0 = r2
|
235
|
+
else
|
236
|
+
self.index = i0
|
237
|
+
r0 = nil
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
node_cache[:lower][start_index] = r0
|
242
|
+
|
243
|
+
return r0
|
244
|
+
end
|
245
|
+
|
246
|
+
def _nt_descendant
|
247
|
+
start_index = index
|
248
|
+
if node_cache[:descendant].has_key?(index)
|
249
|
+
cached = node_cache[:descendant][index]
|
250
|
+
@index = cached.interval.end if cached
|
251
|
+
return cached
|
252
|
+
end
|
253
|
+
|
254
|
+
if input.index('..', index) == index
|
255
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
256
|
+
@index += 2
|
257
|
+
else
|
258
|
+
terminal_parse_failure('..')
|
259
|
+
r0 = nil
|
260
|
+
end
|
261
|
+
|
262
|
+
node_cache[:descendant][start_index] = r0
|
263
|
+
|
264
|
+
return r0
|
265
|
+
end
|
266
|
+
|
267
|
+
module WordList0
|
268
|
+
def quoted_word
|
269
|
+
elements[0]
|
270
|
+
end
|
271
|
+
|
272
|
+
def word_list
|
273
|
+
elements[3]
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def _nt_word_list
|
278
|
+
start_index = index
|
279
|
+
if node_cache[:word_list].has_key?(index)
|
280
|
+
cached = node_cache[:word_list][index]
|
281
|
+
@index = cached.interval.end if cached
|
282
|
+
return cached
|
283
|
+
end
|
284
|
+
|
285
|
+
i0 = index
|
286
|
+
i1, s1 = index, []
|
287
|
+
r2 = _nt_quoted_word
|
288
|
+
s1 << r2
|
289
|
+
if r2
|
290
|
+
if input.index(',', index) == index
|
291
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
292
|
+
@index += 1
|
293
|
+
else
|
294
|
+
terminal_parse_failure(',')
|
295
|
+
r3 = nil
|
296
|
+
end
|
297
|
+
s1 << r3
|
298
|
+
if r3
|
299
|
+
s4, i4 = [], index
|
300
|
+
loop do
|
301
|
+
if input.index(' ', index) == index
|
302
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
303
|
+
@index += 1
|
304
|
+
else
|
305
|
+
terminal_parse_failure(' ')
|
306
|
+
r5 = nil
|
307
|
+
end
|
308
|
+
if r5
|
309
|
+
s4 << r5
|
310
|
+
else
|
311
|
+
break
|
312
|
+
end
|
313
|
+
end
|
314
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
315
|
+
s1 << r4
|
316
|
+
if r4
|
317
|
+
r6 = _nt_word_list
|
318
|
+
s1 << r6
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
if s1.last
|
323
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
324
|
+
r1.extend(WordList0)
|
325
|
+
else
|
326
|
+
self.index = i1
|
327
|
+
r1 = nil
|
328
|
+
end
|
329
|
+
if r1
|
330
|
+
r0 = r1
|
331
|
+
else
|
332
|
+
r7 = _nt_quoted_word
|
333
|
+
if r7
|
334
|
+
r0 = r7
|
335
|
+
else
|
336
|
+
self.index = i0
|
337
|
+
r0 = nil
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
node_cache[:word_list][start_index] = r0
|
342
|
+
|
343
|
+
return r0
|
344
|
+
end
|
345
|
+
|
346
|
+
module QuotedWord0
|
347
|
+
end
|
348
|
+
|
349
|
+
module QuotedWord1
|
350
|
+
def key
|
351
|
+
elements[1]
|
352
|
+
end
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
def _nt_quoted_word
|
357
|
+
start_index = index
|
358
|
+
if node_cache[:quoted_word].has_key?(index)
|
359
|
+
cached = node_cache[:quoted_word][index]
|
360
|
+
@index = cached.interval.end if cached
|
361
|
+
return cached
|
362
|
+
end
|
363
|
+
|
364
|
+
i0, s0 = index, []
|
365
|
+
if input.index('\'', index) == index
|
366
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
367
|
+
@index += 1
|
368
|
+
else
|
369
|
+
terminal_parse_failure('\'')
|
370
|
+
r1 = nil
|
371
|
+
end
|
372
|
+
s0 << r1
|
373
|
+
if r1
|
374
|
+
s2, i2 = [], index
|
375
|
+
loop do
|
376
|
+
i3, s3 = index, []
|
377
|
+
i4 = index
|
378
|
+
if input.index('\'', index) == index
|
379
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
380
|
+
@index += 1
|
381
|
+
else
|
382
|
+
terminal_parse_failure('\'')
|
383
|
+
r5 = nil
|
384
|
+
end
|
385
|
+
if r5
|
386
|
+
r4 = nil
|
387
|
+
else
|
388
|
+
self.index = i4
|
389
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
390
|
+
end
|
391
|
+
s3 << r4
|
392
|
+
if r4
|
393
|
+
if index < input_length
|
394
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
395
|
+
@index += 1
|
396
|
+
else
|
397
|
+
terminal_parse_failure("any character")
|
398
|
+
r6 = nil
|
399
|
+
end
|
400
|
+
s3 << r6
|
401
|
+
end
|
402
|
+
if s3.last
|
403
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
404
|
+
r3.extend(QuotedWord0)
|
405
|
+
else
|
406
|
+
self.index = i3
|
407
|
+
r3 = nil
|
408
|
+
end
|
409
|
+
if r3
|
410
|
+
s2 << r3
|
411
|
+
else
|
412
|
+
break
|
413
|
+
end
|
414
|
+
end
|
415
|
+
if s2.empty?
|
416
|
+
self.index = i2
|
417
|
+
r2 = nil
|
418
|
+
else
|
419
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
420
|
+
end
|
421
|
+
s0 << r2
|
422
|
+
if r2
|
423
|
+
if input.index('\'', index) == index
|
424
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
425
|
+
@index += 1
|
426
|
+
else
|
427
|
+
terminal_parse_failure('\'')
|
428
|
+
r7 = nil
|
429
|
+
end
|
430
|
+
s0 << r7
|
431
|
+
end
|
432
|
+
end
|
433
|
+
if s0.last
|
434
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
435
|
+
r0.extend(QuotedWord1)
|
436
|
+
else
|
437
|
+
self.index = i0
|
438
|
+
r0 = nil
|
439
|
+
end
|
440
|
+
|
441
|
+
node_cache[:quoted_word][start_index] = r0
|
442
|
+
|
443
|
+
return r0
|
444
|
+
end
|
445
|
+
|
446
|
+
module Child0
|
447
|
+
def lower
|
448
|
+
elements[0]
|
449
|
+
end
|
450
|
+
|
451
|
+
def key
|
452
|
+
elements[1]
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
module Child1
|
457
|
+
def lower
|
458
|
+
elements[0]
|
459
|
+
end
|
460
|
+
|
461
|
+
def wildcard
|
462
|
+
elements[1]
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
module Child2
|
467
|
+
end
|
468
|
+
|
469
|
+
module Child3
|
470
|
+
def lower
|
471
|
+
elements[0]
|
472
|
+
end
|
473
|
+
|
474
|
+
def template_code
|
475
|
+
elements[2]
|
476
|
+
end
|
477
|
+
|
478
|
+
end
|
479
|
+
|
480
|
+
module Child4
|
481
|
+
end
|
482
|
+
|
483
|
+
module Child5
|
484
|
+
def lower
|
485
|
+
elements[0]
|
486
|
+
end
|
487
|
+
|
488
|
+
def key
|
489
|
+
elements[2]
|
490
|
+
end
|
491
|
+
|
492
|
+
end
|
493
|
+
|
494
|
+
module Child6
|
495
|
+
def wildcard
|
496
|
+
elements[1]
|
497
|
+
end
|
498
|
+
|
499
|
+
end
|
500
|
+
|
501
|
+
module Child7
|
502
|
+
def index
|
503
|
+
elements[1]
|
504
|
+
end
|
505
|
+
|
506
|
+
end
|
507
|
+
|
508
|
+
module Child8
|
509
|
+
def lower
|
510
|
+
elements[0]
|
511
|
+
end
|
512
|
+
|
513
|
+
def index
|
514
|
+
elements[2]
|
515
|
+
end
|
516
|
+
|
517
|
+
end
|
518
|
+
|
519
|
+
module Child9
|
520
|
+
def start
|
521
|
+
elements[1]
|
522
|
+
end
|
523
|
+
|
524
|
+
def stop
|
525
|
+
elements[3]
|
526
|
+
end
|
527
|
+
|
528
|
+
end
|
529
|
+
|
530
|
+
module Child10
|
531
|
+
def lower
|
532
|
+
elements[0]
|
533
|
+
end
|
534
|
+
|
535
|
+
def start
|
536
|
+
elements[2]
|
537
|
+
end
|
538
|
+
|
539
|
+
def stop
|
540
|
+
elements[4]
|
541
|
+
end
|
542
|
+
|
543
|
+
end
|
544
|
+
|
545
|
+
module Child11
|
546
|
+
def start
|
547
|
+
elements[1]
|
548
|
+
end
|
549
|
+
|
550
|
+
end
|
551
|
+
|
552
|
+
module Child12
|
553
|
+
def lower
|
554
|
+
elements[0]
|
555
|
+
end
|
556
|
+
|
557
|
+
def start
|
558
|
+
elements[2]
|
559
|
+
end
|
560
|
+
|
561
|
+
end
|
562
|
+
|
563
|
+
module Child13
|
564
|
+
def start
|
565
|
+
elements[1]
|
566
|
+
end
|
567
|
+
|
568
|
+
def stop
|
569
|
+
elements[3]
|
570
|
+
end
|
571
|
+
|
572
|
+
def step
|
573
|
+
elements[5]
|
574
|
+
end
|
575
|
+
|
576
|
+
end
|
577
|
+
|
578
|
+
module Child14
|
579
|
+
def lower
|
580
|
+
elements[0]
|
581
|
+
end
|
582
|
+
|
583
|
+
def start
|
584
|
+
elements[2]
|
585
|
+
end
|
586
|
+
|
587
|
+
def stop
|
588
|
+
elements[4]
|
589
|
+
end
|
590
|
+
|
591
|
+
def step
|
592
|
+
elements[6]
|
593
|
+
end
|
594
|
+
|
595
|
+
end
|
596
|
+
|
597
|
+
module Child15
|
598
|
+
def start
|
599
|
+
elements[1]
|
600
|
+
end
|
601
|
+
|
602
|
+
def step
|
603
|
+
elements[3]
|
604
|
+
end
|
605
|
+
|
606
|
+
end
|
607
|
+
|
608
|
+
module Child16
|
609
|
+
def lower
|
610
|
+
elements[0]
|
611
|
+
end
|
612
|
+
|
613
|
+
def start
|
614
|
+
elements[2]
|
615
|
+
end
|
616
|
+
|
617
|
+
def step
|
618
|
+
elements[4]
|
619
|
+
end
|
620
|
+
|
621
|
+
end
|
622
|
+
|
623
|
+
module Child17
|
624
|
+
end
|
625
|
+
|
626
|
+
module Child18
|
627
|
+
def template_code
|
628
|
+
elements[1]
|
629
|
+
end
|
630
|
+
|
631
|
+
end
|
632
|
+
|
633
|
+
module Child19
|
634
|
+
end
|
635
|
+
|
636
|
+
module Child20
|
637
|
+
def lower
|
638
|
+
elements[0]
|
639
|
+
end
|
640
|
+
|
641
|
+
def template_code
|
642
|
+
elements[2]
|
643
|
+
end
|
644
|
+
|
645
|
+
end
|
646
|
+
|
647
|
+
module Child21
|
648
|
+
end
|
649
|
+
|
650
|
+
module Child22
|
651
|
+
def template_code
|
652
|
+
elements[1]
|
653
|
+
end
|
654
|
+
|
655
|
+
end
|
656
|
+
|
657
|
+
module Child23
|
658
|
+
end
|
659
|
+
|
660
|
+
module Child24
|
661
|
+
def lower
|
662
|
+
elements[0]
|
663
|
+
end
|
664
|
+
|
665
|
+
def template_code
|
666
|
+
elements[2]
|
667
|
+
end
|
668
|
+
|
669
|
+
end
|
670
|
+
|
671
|
+
module Child25
|
672
|
+
def word_list
|
673
|
+
elements[1]
|
674
|
+
end
|
675
|
+
|
676
|
+
end
|
677
|
+
|
678
|
+
module Child26
|
679
|
+
def lower
|
680
|
+
elements[0]
|
681
|
+
end
|
682
|
+
|
683
|
+
def word_list
|
684
|
+
elements[2]
|
685
|
+
end
|
686
|
+
|
687
|
+
end
|
688
|
+
|
689
|
+
def _nt_child
|
690
|
+
start_index = index
|
691
|
+
if node_cache[:child].has_key?(index)
|
692
|
+
cached = node_cache[:child][index]
|
693
|
+
@index = cached.interval.end if cached
|
694
|
+
return cached
|
695
|
+
end
|
696
|
+
|
697
|
+
i0 = index
|
698
|
+
i1, s1 = index, []
|
699
|
+
r2 = _nt_lower
|
700
|
+
s1 << r2
|
701
|
+
if r2
|
702
|
+
r3 = _nt_bareword
|
703
|
+
s1 << r3
|
704
|
+
end
|
705
|
+
if s1.last
|
706
|
+
r1 = instantiate_node(JSONPath::Nodes::KeyNode,input, i1...index, s1)
|
707
|
+
r1.extend(Child0)
|
708
|
+
else
|
709
|
+
self.index = i1
|
710
|
+
r1 = nil
|
711
|
+
end
|
712
|
+
if r1
|
713
|
+
r0 = r1
|
714
|
+
else
|
715
|
+
i4, s4 = index, []
|
716
|
+
r5 = _nt_lower
|
717
|
+
s4 << r5
|
718
|
+
if r5
|
719
|
+
r6 = _nt_wildcard
|
720
|
+
s4 << r6
|
721
|
+
end
|
722
|
+
if s4.last
|
723
|
+
r4 = instantiate_node(JSONPath::Nodes::WildcardNode,input, i4...index, s4)
|
724
|
+
r4.extend(Child1)
|
725
|
+
else
|
726
|
+
self.index = i4
|
727
|
+
r4 = nil
|
728
|
+
end
|
729
|
+
if r4
|
730
|
+
r0 = r4
|
731
|
+
else
|
732
|
+
i7, s7 = index, []
|
733
|
+
r8 = _nt_lower
|
734
|
+
s7 << r8
|
735
|
+
if r8
|
736
|
+
if input.index('\'?(', index) == index
|
737
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
738
|
+
@index += 3
|
739
|
+
else
|
740
|
+
terminal_parse_failure('\'?(')
|
741
|
+
r9 = nil
|
742
|
+
end
|
743
|
+
s7 << r9
|
744
|
+
if r9
|
745
|
+
s10, i10 = [], index
|
746
|
+
loop do
|
747
|
+
i11, s11 = index, []
|
748
|
+
i12 = index
|
749
|
+
if input.index(')\'', index) == index
|
750
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
751
|
+
@index += 2
|
752
|
+
else
|
753
|
+
terminal_parse_failure(')\'')
|
754
|
+
r13 = nil
|
755
|
+
end
|
756
|
+
if r13
|
757
|
+
r12 = nil
|
758
|
+
else
|
759
|
+
self.index = i12
|
760
|
+
r12 = instantiate_node(SyntaxNode,input, index...index)
|
761
|
+
end
|
762
|
+
s11 << r12
|
763
|
+
if r12
|
764
|
+
if index < input_length
|
765
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
766
|
+
@index += 1
|
767
|
+
else
|
768
|
+
terminal_parse_failure("any character")
|
769
|
+
r14 = nil
|
770
|
+
end
|
771
|
+
s11 << r14
|
772
|
+
end
|
773
|
+
if s11.last
|
774
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
775
|
+
r11.extend(Child2)
|
776
|
+
else
|
777
|
+
self.index = i11
|
778
|
+
r11 = nil
|
779
|
+
end
|
780
|
+
if r11
|
781
|
+
s10 << r11
|
782
|
+
else
|
783
|
+
break
|
784
|
+
end
|
785
|
+
end
|
786
|
+
if s10.empty?
|
787
|
+
self.index = i10
|
788
|
+
r10 = nil
|
789
|
+
else
|
790
|
+
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
791
|
+
end
|
792
|
+
s7 << r10
|
793
|
+
if r10
|
794
|
+
if input.index(')\'', index) == index
|
795
|
+
r15 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
796
|
+
@index += 2
|
797
|
+
else
|
798
|
+
terminal_parse_failure(')\'')
|
799
|
+
r15 = nil
|
800
|
+
end
|
801
|
+
s7 << r15
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
if s7.last
|
806
|
+
r7 = instantiate_node(JSONPath::Nodes::FilterNode,input, i7...index, s7)
|
807
|
+
r7.extend(Child3)
|
808
|
+
else
|
809
|
+
self.index = i7
|
810
|
+
r7 = nil
|
811
|
+
end
|
812
|
+
if r7
|
813
|
+
r0 = r7
|
814
|
+
else
|
815
|
+
i16, s16 = index, []
|
816
|
+
r17 = _nt_lower
|
817
|
+
s16 << r17
|
818
|
+
if r17
|
819
|
+
if input.index('\'', index) == index
|
820
|
+
r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
821
|
+
@index += 1
|
822
|
+
else
|
823
|
+
terminal_parse_failure('\'')
|
824
|
+
r18 = nil
|
825
|
+
end
|
826
|
+
s16 << r18
|
827
|
+
if r18
|
828
|
+
s19, i19 = [], index
|
829
|
+
loop do
|
830
|
+
i20, s20 = index, []
|
831
|
+
i21 = index
|
832
|
+
if input.index('\'', index) == index
|
833
|
+
r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
834
|
+
@index += 1
|
835
|
+
else
|
836
|
+
terminal_parse_failure('\'')
|
837
|
+
r22 = nil
|
838
|
+
end
|
839
|
+
if r22
|
840
|
+
r21 = nil
|
841
|
+
else
|
842
|
+
self.index = i21
|
843
|
+
r21 = instantiate_node(SyntaxNode,input, index...index)
|
844
|
+
end
|
845
|
+
s20 << r21
|
846
|
+
if r21
|
847
|
+
if index < input_length
|
848
|
+
r23 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
849
|
+
@index += 1
|
850
|
+
else
|
851
|
+
terminal_parse_failure("any character")
|
852
|
+
r23 = nil
|
853
|
+
end
|
854
|
+
s20 << r23
|
855
|
+
end
|
856
|
+
if s20.last
|
857
|
+
r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
|
858
|
+
r20.extend(Child4)
|
859
|
+
else
|
860
|
+
self.index = i20
|
861
|
+
r20 = nil
|
862
|
+
end
|
863
|
+
if r20
|
864
|
+
s19 << r20
|
865
|
+
else
|
866
|
+
break
|
867
|
+
end
|
868
|
+
end
|
869
|
+
if s19.empty?
|
870
|
+
self.index = i19
|
871
|
+
r19 = nil
|
872
|
+
else
|
873
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
874
|
+
end
|
875
|
+
s16 << r19
|
876
|
+
if r19
|
877
|
+
if input.index('\'', index) == index
|
878
|
+
r24 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
879
|
+
@index += 1
|
880
|
+
else
|
881
|
+
terminal_parse_failure('\'')
|
882
|
+
r24 = nil
|
883
|
+
end
|
884
|
+
s16 << r24
|
885
|
+
end
|
886
|
+
end
|
887
|
+
end
|
888
|
+
if s16.last
|
889
|
+
r16 = instantiate_node(JSONPath::Nodes::KeyNode,input, i16...index, s16)
|
890
|
+
r16.extend(Child5)
|
891
|
+
else
|
892
|
+
self.index = i16
|
893
|
+
r16 = nil
|
894
|
+
end
|
895
|
+
if r16
|
896
|
+
r0 = r16
|
897
|
+
else
|
898
|
+
i25, s25 = index, []
|
899
|
+
if input.index('[', index) == index
|
900
|
+
r26 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
901
|
+
@index += 1
|
902
|
+
else
|
903
|
+
terminal_parse_failure('[')
|
904
|
+
r26 = nil
|
905
|
+
end
|
906
|
+
s25 << r26
|
907
|
+
if r26
|
908
|
+
r27 = _nt_wildcard
|
909
|
+
s25 << r27
|
910
|
+
if r27
|
911
|
+
if input.index(']', index) == index
|
912
|
+
r28 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
913
|
+
@index += 1
|
914
|
+
else
|
915
|
+
terminal_parse_failure(']')
|
916
|
+
r28 = nil
|
917
|
+
end
|
918
|
+
s25 << r28
|
919
|
+
end
|
920
|
+
end
|
921
|
+
if s25.last
|
922
|
+
r25 = instantiate_node(JSONPath::Nodes::WildcardNode,input, i25...index, s25)
|
923
|
+
r25.extend(Child6)
|
924
|
+
else
|
925
|
+
self.index = i25
|
926
|
+
r25 = nil
|
927
|
+
end
|
928
|
+
if r25
|
929
|
+
r0 = r25
|
930
|
+
else
|
931
|
+
i29, s29 = index, []
|
932
|
+
if input.index('[', index) == index
|
933
|
+
r30 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
934
|
+
@index += 1
|
935
|
+
else
|
936
|
+
terminal_parse_failure('[')
|
937
|
+
r30 = nil
|
938
|
+
end
|
939
|
+
s29 << r30
|
940
|
+
if r30
|
941
|
+
r31 = _nt_number
|
942
|
+
s29 << r31
|
943
|
+
if r31
|
944
|
+
if input.index(']', index) == index
|
945
|
+
r32 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
946
|
+
@index += 1
|
947
|
+
else
|
948
|
+
terminal_parse_failure(']')
|
949
|
+
r32 = nil
|
950
|
+
end
|
951
|
+
s29 << r32
|
952
|
+
end
|
953
|
+
end
|
954
|
+
if s29.last
|
955
|
+
r29 = instantiate_node(JSONPath::Nodes::IndexNode,input, i29...index, s29)
|
956
|
+
r29.extend(Child7)
|
957
|
+
else
|
958
|
+
self.index = i29
|
959
|
+
r29 = nil
|
960
|
+
end
|
961
|
+
if r29
|
962
|
+
r0 = r29
|
963
|
+
else
|
964
|
+
i33, s33 = index, []
|
965
|
+
r34 = _nt_lower
|
966
|
+
s33 << r34
|
967
|
+
if r34
|
968
|
+
if input.index('[', index) == index
|
969
|
+
r35 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
970
|
+
@index += 1
|
971
|
+
else
|
972
|
+
terminal_parse_failure('[')
|
973
|
+
r35 = nil
|
974
|
+
end
|
975
|
+
s33 << r35
|
976
|
+
if r35
|
977
|
+
r36 = _nt_number
|
978
|
+
s33 << r36
|
979
|
+
if r36
|
980
|
+
if input.index(']', index) == index
|
981
|
+
r37 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
982
|
+
@index += 1
|
983
|
+
else
|
984
|
+
terminal_parse_failure(']')
|
985
|
+
r37 = nil
|
986
|
+
end
|
987
|
+
s33 << r37
|
988
|
+
end
|
989
|
+
end
|
990
|
+
end
|
991
|
+
if s33.last
|
992
|
+
r33 = instantiate_node(JSONPath::Nodes::IndexNode,input, i33...index, s33)
|
993
|
+
r33.extend(Child8)
|
994
|
+
else
|
995
|
+
self.index = i33
|
996
|
+
r33 = nil
|
997
|
+
end
|
998
|
+
if r33
|
999
|
+
r0 = r33
|
1000
|
+
else
|
1001
|
+
i38, s38 = index, []
|
1002
|
+
if input.index('[', index) == index
|
1003
|
+
r39 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1004
|
+
@index += 1
|
1005
|
+
else
|
1006
|
+
terminal_parse_failure('[')
|
1007
|
+
r39 = nil
|
1008
|
+
end
|
1009
|
+
s38 << r39
|
1010
|
+
if r39
|
1011
|
+
r40 = _nt_number
|
1012
|
+
s38 << r40
|
1013
|
+
if r40
|
1014
|
+
if input.index(':', index) == index
|
1015
|
+
r41 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1016
|
+
@index += 1
|
1017
|
+
else
|
1018
|
+
terminal_parse_failure(':')
|
1019
|
+
r41 = nil
|
1020
|
+
end
|
1021
|
+
s38 << r41
|
1022
|
+
if r41
|
1023
|
+
r42 = _nt_number
|
1024
|
+
s38 << r42
|
1025
|
+
if r42
|
1026
|
+
if input.index(']', index) == index
|
1027
|
+
r43 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1028
|
+
@index += 1
|
1029
|
+
else
|
1030
|
+
terminal_parse_failure(']')
|
1031
|
+
r43 = nil
|
1032
|
+
end
|
1033
|
+
s38 << r43
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
if s38.last
|
1039
|
+
r38 = instantiate_node(JSONPath::Nodes::SliceNode,input, i38...index, s38)
|
1040
|
+
r38.extend(Child9)
|
1041
|
+
else
|
1042
|
+
self.index = i38
|
1043
|
+
r38 = nil
|
1044
|
+
end
|
1045
|
+
if r38
|
1046
|
+
r0 = r38
|
1047
|
+
else
|
1048
|
+
i44, s44 = index, []
|
1049
|
+
r45 = _nt_lower
|
1050
|
+
s44 << r45
|
1051
|
+
if r45
|
1052
|
+
if input.index('[', index) == index
|
1053
|
+
r46 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1054
|
+
@index += 1
|
1055
|
+
else
|
1056
|
+
terminal_parse_failure('[')
|
1057
|
+
r46 = nil
|
1058
|
+
end
|
1059
|
+
s44 << r46
|
1060
|
+
if r46
|
1061
|
+
r47 = _nt_number
|
1062
|
+
s44 << r47
|
1063
|
+
if r47
|
1064
|
+
if input.index(':', index) == index
|
1065
|
+
r48 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1066
|
+
@index += 1
|
1067
|
+
else
|
1068
|
+
terminal_parse_failure(':')
|
1069
|
+
r48 = nil
|
1070
|
+
end
|
1071
|
+
s44 << r48
|
1072
|
+
if r48
|
1073
|
+
r49 = _nt_number
|
1074
|
+
s44 << r49
|
1075
|
+
if r49
|
1076
|
+
if input.index(']', index) == index
|
1077
|
+
r50 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1078
|
+
@index += 1
|
1079
|
+
else
|
1080
|
+
terminal_parse_failure(']')
|
1081
|
+
r50 = nil
|
1082
|
+
end
|
1083
|
+
s44 << r50
|
1084
|
+
end
|
1085
|
+
end
|
1086
|
+
end
|
1087
|
+
end
|
1088
|
+
end
|
1089
|
+
if s44.last
|
1090
|
+
r44 = instantiate_node(JSONPath::Nodes::SliceNode,input, i44...index, s44)
|
1091
|
+
r44.extend(Child10)
|
1092
|
+
else
|
1093
|
+
self.index = i44
|
1094
|
+
r44 = nil
|
1095
|
+
end
|
1096
|
+
if r44
|
1097
|
+
r0 = r44
|
1098
|
+
else
|
1099
|
+
i51, s51 = index, []
|
1100
|
+
if input.index('[', index) == index
|
1101
|
+
r52 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1102
|
+
@index += 1
|
1103
|
+
else
|
1104
|
+
terminal_parse_failure('[')
|
1105
|
+
r52 = nil
|
1106
|
+
end
|
1107
|
+
s51 << r52
|
1108
|
+
if r52
|
1109
|
+
r53 = _nt_number
|
1110
|
+
s51 << r53
|
1111
|
+
if r53
|
1112
|
+
if input.index(':]', index) == index
|
1113
|
+
r54 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1114
|
+
@index += 2
|
1115
|
+
else
|
1116
|
+
terminal_parse_failure(':]')
|
1117
|
+
r54 = nil
|
1118
|
+
end
|
1119
|
+
s51 << r54
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
if s51.last
|
1123
|
+
r51 = instantiate_node(JSONPath::Nodes::SliceNode,input, i51...index, s51)
|
1124
|
+
r51.extend(Child11)
|
1125
|
+
else
|
1126
|
+
self.index = i51
|
1127
|
+
r51 = nil
|
1128
|
+
end
|
1129
|
+
if r51
|
1130
|
+
r0 = r51
|
1131
|
+
else
|
1132
|
+
i55, s55 = index, []
|
1133
|
+
r56 = _nt_lower
|
1134
|
+
s55 << r56
|
1135
|
+
if r56
|
1136
|
+
if input.index('[', index) == index
|
1137
|
+
r57 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1138
|
+
@index += 1
|
1139
|
+
else
|
1140
|
+
terminal_parse_failure('[')
|
1141
|
+
r57 = nil
|
1142
|
+
end
|
1143
|
+
s55 << r57
|
1144
|
+
if r57
|
1145
|
+
r58 = _nt_number
|
1146
|
+
s55 << r58
|
1147
|
+
if r58
|
1148
|
+
if input.index(':]', index) == index
|
1149
|
+
r59 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1150
|
+
@index += 2
|
1151
|
+
else
|
1152
|
+
terminal_parse_failure(':]')
|
1153
|
+
r59 = nil
|
1154
|
+
end
|
1155
|
+
s55 << r59
|
1156
|
+
end
|
1157
|
+
end
|
1158
|
+
end
|
1159
|
+
if s55.last
|
1160
|
+
r55 = instantiate_node(JSONPath::Nodes::SliceNode,input, i55...index, s55)
|
1161
|
+
r55.extend(Child12)
|
1162
|
+
else
|
1163
|
+
self.index = i55
|
1164
|
+
r55 = nil
|
1165
|
+
end
|
1166
|
+
if r55
|
1167
|
+
r0 = r55
|
1168
|
+
else
|
1169
|
+
i60, s60 = index, []
|
1170
|
+
if input.index('[', index) == index
|
1171
|
+
r61 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1172
|
+
@index += 1
|
1173
|
+
else
|
1174
|
+
terminal_parse_failure('[')
|
1175
|
+
r61 = nil
|
1176
|
+
end
|
1177
|
+
s60 << r61
|
1178
|
+
if r61
|
1179
|
+
r62 = _nt_number
|
1180
|
+
s60 << r62
|
1181
|
+
if r62
|
1182
|
+
if input.index(':', index) == index
|
1183
|
+
r63 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1184
|
+
@index += 1
|
1185
|
+
else
|
1186
|
+
terminal_parse_failure(':')
|
1187
|
+
r63 = nil
|
1188
|
+
end
|
1189
|
+
s60 << r63
|
1190
|
+
if r63
|
1191
|
+
r64 = _nt_number
|
1192
|
+
s60 << r64
|
1193
|
+
if r64
|
1194
|
+
if input.index(':', index) == index
|
1195
|
+
r65 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1196
|
+
@index += 1
|
1197
|
+
else
|
1198
|
+
terminal_parse_failure(':')
|
1199
|
+
r65 = nil
|
1200
|
+
end
|
1201
|
+
s60 << r65
|
1202
|
+
if r65
|
1203
|
+
r66 = _nt_number
|
1204
|
+
s60 << r66
|
1205
|
+
if r66
|
1206
|
+
if input.index(']', index) == index
|
1207
|
+
r67 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1208
|
+
@index += 1
|
1209
|
+
else
|
1210
|
+
terminal_parse_failure(']')
|
1211
|
+
r67 = nil
|
1212
|
+
end
|
1213
|
+
s60 << r67
|
1214
|
+
end
|
1215
|
+
end
|
1216
|
+
end
|
1217
|
+
end
|
1218
|
+
end
|
1219
|
+
end
|
1220
|
+
if s60.last
|
1221
|
+
r60 = instantiate_node(JSONPath::Nodes::SliceNode,input, i60...index, s60)
|
1222
|
+
r60.extend(Child13)
|
1223
|
+
else
|
1224
|
+
self.index = i60
|
1225
|
+
r60 = nil
|
1226
|
+
end
|
1227
|
+
if r60
|
1228
|
+
r0 = r60
|
1229
|
+
else
|
1230
|
+
i68, s68 = index, []
|
1231
|
+
r69 = _nt_lower
|
1232
|
+
s68 << r69
|
1233
|
+
if r69
|
1234
|
+
if input.index('[', index) == index
|
1235
|
+
r70 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1236
|
+
@index += 1
|
1237
|
+
else
|
1238
|
+
terminal_parse_failure('[')
|
1239
|
+
r70 = nil
|
1240
|
+
end
|
1241
|
+
s68 << r70
|
1242
|
+
if r70
|
1243
|
+
r71 = _nt_number
|
1244
|
+
s68 << r71
|
1245
|
+
if r71
|
1246
|
+
if input.index(':', index) == index
|
1247
|
+
r72 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1248
|
+
@index += 1
|
1249
|
+
else
|
1250
|
+
terminal_parse_failure(':')
|
1251
|
+
r72 = nil
|
1252
|
+
end
|
1253
|
+
s68 << r72
|
1254
|
+
if r72
|
1255
|
+
r73 = _nt_number
|
1256
|
+
s68 << r73
|
1257
|
+
if r73
|
1258
|
+
if input.index(':', index) == index
|
1259
|
+
r74 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1260
|
+
@index += 1
|
1261
|
+
else
|
1262
|
+
terminal_parse_failure(':')
|
1263
|
+
r74 = nil
|
1264
|
+
end
|
1265
|
+
s68 << r74
|
1266
|
+
if r74
|
1267
|
+
r75 = _nt_number
|
1268
|
+
s68 << r75
|
1269
|
+
if r75
|
1270
|
+
if input.index(']', index) == index
|
1271
|
+
r76 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1272
|
+
@index += 1
|
1273
|
+
else
|
1274
|
+
terminal_parse_failure(']')
|
1275
|
+
r76 = nil
|
1276
|
+
end
|
1277
|
+
s68 << r76
|
1278
|
+
end
|
1279
|
+
end
|
1280
|
+
end
|
1281
|
+
end
|
1282
|
+
end
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
if s68.last
|
1286
|
+
r68 = instantiate_node(JSONPath::Nodes::SliceNode,input, i68...index, s68)
|
1287
|
+
r68.extend(Child14)
|
1288
|
+
else
|
1289
|
+
self.index = i68
|
1290
|
+
r68 = nil
|
1291
|
+
end
|
1292
|
+
if r68
|
1293
|
+
r0 = r68
|
1294
|
+
else
|
1295
|
+
i77, s77 = index, []
|
1296
|
+
if input.index('[', index) == index
|
1297
|
+
r78 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1298
|
+
@index += 1
|
1299
|
+
else
|
1300
|
+
terminal_parse_failure('[')
|
1301
|
+
r78 = nil
|
1302
|
+
end
|
1303
|
+
s77 << r78
|
1304
|
+
if r78
|
1305
|
+
r79 = _nt_number
|
1306
|
+
s77 << r79
|
1307
|
+
if r79
|
1308
|
+
if input.index('::', index) == index
|
1309
|
+
r80 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1310
|
+
@index += 2
|
1311
|
+
else
|
1312
|
+
terminal_parse_failure('::')
|
1313
|
+
r80 = nil
|
1314
|
+
end
|
1315
|
+
s77 << r80
|
1316
|
+
if r80
|
1317
|
+
r81 = _nt_number
|
1318
|
+
s77 << r81
|
1319
|
+
if r81
|
1320
|
+
if input.index(']', index) == index
|
1321
|
+
r82 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1322
|
+
@index += 1
|
1323
|
+
else
|
1324
|
+
terminal_parse_failure(']')
|
1325
|
+
r82 = nil
|
1326
|
+
end
|
1327
|
+
s77 << r82
|
1328
|
+
end
|
1329
|
+
end
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
if s77.last
|
1333
|
+
r77 = instantiate_node(JSONPath::Nodes::SliceNode,input, i77...index, s77)
|
1334
|
+
r77.extend(Child15)
|
1335
|
+
else
|
1336
|
+
self.index = i77
|
1337
|
+
r77 = nil
|
1338
|
+
end
|
1339
|
+
if r77
|
1340
|
+
r0 = r77
|
1341
|
+
else
|
1342
|
+
i83, s83 = index, []
|
1343
|
+
r84 = _nt_lower
|
1344
|
+
s83 << r84
|
1345
|
+
if r84
|
1346
|
+
if input.index('[', index) == index
|
1347
|
+
r85 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1348
|
+
@index += 1
|
1349
|
+
else
|
1350
|
+
terminal_parse_failure('[')
|
1351
|
+
r85 = nil
|
1352
|
+
end
|
1353
|
+
s83 << r85
|
1354
|
+
if r85
|
1355
|
+
r86 = _nt_number
|
1356
|
+
s83 << r86
|
1357
|
+
if r86
|
1358
|
+
if input.index('::', index) == index
|
1359
|
+
r87 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1360
|
+
@index += 2
|
1361
|
+
else
|
1362
|
+
terminal_parse_failure('::')
|
1363
|
+
r87 = nil
|
1364
|
+
end
|
1365
|
+
s83 << r87
|
1366
|
+
if r87
|
1367
|
+
r88 = _nt_number
|
1368
|
+
s83 << r88
|
1369
|
+
if r88
|
1370
|
+
if input.index(']', index) == index
|
1371
|
+
r89 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1372
|
+
@index += 1
|
1373
|
+
else
|
1374
|
+
terminal_parse_failure(']')
|
1375
|
+
r89 = nil
|
1376
|
+
end
|
1377
|
+
s83 << r89
|
1378
|
+
end
|
1379
|
+
end
|
1380
|
+
end
|
1381
|
+
end
|
1382
|
+
end
|
1383
|
+
if s83.last
|
1384
|
+
r83 = instantiate_node(JSONPath::Nodes::SliceNode,input, i83...index, s83)
|
1385
|
+
r83.extend(Child16)
|
1386
|
+
else
|
1387
|
+
self.index = i83
|
1388
|
+
r83 = nil
|
1389
|
+
end
|
1390
|
+
if r83
|
1391
|
+
r0 = r83
|
1392
|
+
else
|
1393
|
+
i90, s90 = index, []
|
1394
|
+
if input.index('[(', index) == index
|
1395
|
+
r91 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1396
|
+
@index += 2
|
1397
|
+
else
|
1398
|
+
terminal_parse_failure('[(')
|
1399
|
+
r91 = nil
|
1400
|
+
end
|
1401
|
+
s90 << r91
|
1402
|
+
if r91
|
1403
|
+
s92, i92 = [], index
|
1404
|
+
loop do
|
1405
|
+
i93, s93 = index, []
|
1406
|
+
i94 = index
|
1407
|
+
if input.index(')]', index) == index
|
1408
|
+
r95 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1409
|
+
@index += 2
|
1410
|
+
else
|
1411
|
+
terminal_parse_failure(')]')
|
1412
|
+
r95 = nil
|
1413
|
+
end
|
1414
|
+
if r95
|
1415
|
+
r94 = nil
|
1416
|
+
else
|
1417
|
+
self.index = i94
|
1418
|
+
r94 = instantiate_node(SyntaxNode,input, index...index)
|
1419
|
+
end
|
1420
|
+
s93 << r94
|
1421
|
+
if r94
|
1422
|
+
if index < input_length
|
1423
|
+
r96 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1424
|
+
@index += 1
|
1425
|
+
else
|
1426
|
+
terminal_parse_failure("any character")
|
1427
|
+
r96 = nil
|
1428
|
+
end
|
1429
|
+
s93 << r96
|
1430
|
+
end
|
1431
|
+
if s93.last
|
1432
|
+
r93 = instantiate_node(SyntaxNode,input, i93...index, s93)
|
1433
|
+
r93.extend(Child17)
|
1434
|
+
else
|
1435
|
+
self.index = i93
|
1436
|
+
r93 = nil
|
1437
|
+
end
|
1438
|
+
if r93
|
1439
|
+
s92 << r93
|
1440
|
+
else
|
1441
|
+
break
|
1442
|
+
end
|
1443
|
+
end
|
1444
|
+
if s92.empty?
|
1445
|
+
self.index = i92
|
1446
|
+
r92 = nil
|
1447
|
+
else
|
1448
|
+
r92 = instantiate_node(SyntaxNode,input, i92...index, s92)
|
1449
|
+
end
|
1450
|
+
s90 << r92
|
1451
|
+
if r92
|
1452
|
+
if input.index(')]', index) == index
|
1453
|
+
r97 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1454
|
+
@index += 2
|
1455
|
+
else
|
1456
|
+
terminal_parse_failure(')]')
|
1457
|
+
r97 = nil
|
1458
|
+
end
|
1459
|
+
s90 << r97
|
1460
|
+
end
|
1461
|
+
end
|
1462
|
+
if s90.last
|
1463
|
+
r90 = instantiate_node(JSONPath::Nodes::ExprNode,input, i90...index, s90)
|
1464
|
+
r90.extend(Child18)
|
1465
|
+
else
|
1466
|
+
self.index = i90
|
1467
|
+
r90 = nil
|
1468
|
+
end
|
1469
|
+
if r90
|
1470
|
+
r0 = r90
|
1471
|
+
else
|
1472
|
+
i98, s98 = index, []
|
1473
|
+
r99 = _nt_lower
|
1474
|
+
s98 << r99
|
1475
|
+
if r99
|
1476
|
+
if input.index('[(', index) == index
|
1477
|
+
r100 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1478
|
+
@index += 2
|
1479
|
+
else
|
1480
|
+
terminal_parse_failure('[(')
|
1481
|
+
r100 = nil
|
1482
|
+
end
|
1483
|
+
s98 << r100
|
1484
|
+
if r100
|
1485
|
+
s101, i101 = [], index
|
1486
|
+
loop do
|
1487
|
+
i102, s102 = index, []
|
1488
|
+
i103 = index
|
1489
|
+
if input.index(')]', index) == index
|
1490
|
+
r104 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1491
|
+
@index += 2
|
1492
|
+
else
|
1493
|
+
terminal_parse_failure(')]')
|
1494
|
+
r104 = nil
|
1495
|
+
end
|
1496
|
+
if r104
|
1497
|
+
r103 = nil
|
1498
|
+
else
|
1499
|
+
self.index = i103
|
1500
|
+
r103 = instantiate_node(SyntaxNode,input, index...index)
|
1501
|
+
end
|
1502
|
+
s102 << r103
|
1503
|
+
if r103
|
1504
|
+
if index < input_length
|
1505
|
+
r105 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1506
|
+
@index += 1
|
1507
|
+
else
|
1508
|
+
terminal_parse_failure("any character")
|
1509
|
+
r105 = nil
|
1510
|
+
end
|
1511
|
+
s102 << r105
|
1512
|
+
end
|
1513
|
+
if s102.last
|
1514
|
+
r102 = instantiate_node(SyntaxNode,input, i102...index, s102)
|
1515
|
+
r102.extend(Child19)
|
1516
|
+
else
|
1517
|
+
self.index = i102
|
1518
|
+
r102 = nil
|
1519
|
+
end
|
1520
|
+
if r102
|
1521
|
+
s101 << r102
|
1522
|
+
else
|
1523
|
+
break
|
1524
|
+
end
|
1525
|
+
end
|
1526
|
+
if s101.empty?
|
1527
|
+
self.index = i101
|
1528
|
+
r101 = nil
|
1529
|
+
else
|
1530
|
+
r101 = instantiate_node(SyntaxNode,input, i101...index, s101)
|
1531
|
+
end
|
1532
|
+
s98 << r101
|
1533
|
+
if r101
|
1534
|
+
if input.index(')]', index) == index
|
1535
|
+
r106 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1536
|
+
@index += 2
|
1537
|
+
else
|
1538
|
+
terminal_parse_failure(')]')
|
1539
|
+
r106 = nil
|
1540
|
+
end
|
1541
|
+
s98 << r106
|
1542
|
+
end
|
1543
|
+
end
|
1544
|
+
end
|
1545
|
+
if s98.last
|
1546
|
+
r98 = instantiate_node(JSONPath::Nodes::ExprNode,input, i98...index, s98)
|
1547
|
+
r98.extend(Child20)
|
1548
|
+
else
|
1549
|
+
self.index = i98
|
1550
|
+
r98 = nil
|
1551
|
+
end
|
1552
|
+
if r98
|
1553
|
+
r0 = r98
|
1554
|
+
else
|
1555
|
+
i107, s107 = index, []
|
1556
|
+
if input.index('[?(', index) == index
|
1557
|
+
r108 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
1558
|
+
@index += 3
|
1559
|
+
else
|
1560
|
+
terminal_parse_failure('[?(')
|
1561
|
+
r108 = nil
|
1562
|
+
end
|
1563
|
+
s107 << r108
|
1564
|
+
if r108
|
1565
|
+
s109, i109 = [], index
|
1566
|
+
loop do
|
1567
|
+
i110, s110 = index, []
|
1568
|
+
i111 = index
|
1569
|
+
if input.index(')]', index) == index
|
1570
|
+
r112 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1571
|
+
@index += 2
|
1572
|
+
else
|
1573
|
+
terminal_parse_failure(')]')
|
1574
|
+
r112 = nil
|
1575
|
+
end
|
1576
|
+
if r112
|
1577
|
+
r111 = nil
|
1578
|
+
else
|
1579
|
+
self.index = i111
|
1580
|
+
r111 = instantiate_node(SyntaxNode,input, index...index)
|
1581
|
+
end
|
1582
|
+
s110 << r111
|
1583
|
+
if r111
|
1584
|
+
if index < input_length
|
1585
|
+
r113 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1586
|
+
@index += 1
|
1587
|
+
else
|
1588
|
+
terminal_parse_failure("any character")
|
1589
|
+
r113 = nil
|
1590
|
+
end
|
1591
|
+
s110 << r113
|
1592
|
+
end
|
1593
|
+
if s110.last
|
1594
|
+
r110 = instantiate_node(SyntaxNode,input, i110...index, s110)
|
1595
|
+
r110.extend(Child21)
|
1596
|
+
else
|
1597
|
+
self.index = i110
|
1598
|
+
r110 = nil
|
1599
|
+
end
|
1600
|
+
if r110
|
1601
|
+
s109 << r110
|
1602
|
+
else
|
1603
|
+
break
|
1604
|
+
end
|
1605
|
+
end
|
1606
|
+
if s109.empty?
|
1607
|
+
self.index = i109
|
1608
|
+
r109 = nil
|
1609
|
+
else
|
1610
|
+
r109 = instantiate_node(SyntaxNode,input, i109...index, s109)
|
1611
|
+
end
|
1612
|
+
s107 << r109
|
1613
|
+
if r109
|
1614
|
+
if input.index(')]', index) == index
|
1615
|
+
r114 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1616
|
+
@index += 2
|
1617
|
+
else
|
1618
|
+
terminal_parse_failure(')]')
|
1619
|
+
r114 = nil
|
1620
|
+
end
|
1621
|
+
s107 << r114
|
1622
|
+
end
|
1623
|
+
end
|
1624
|
+
if s107.last
|
1625
|
+
r107 = instantiate_node(JSONPath::Nodes::FilterNode,input, i107...index, s107)
|
1626
|
+
r107.extend(Child22)
|
1627
|
+
else
|
1628
|
+
self.index = i107
|
1629
|
+
r107 = nil
|
1630
|
+
end
|
1631
|
+
if r107
|
1632
|
+
r0 = r107
|
1633
|
+
else
|
1634
|
+
i115, s115 = index, []
|
1635
|
+
r116 = _nt_lower
|
1636
|
+
s115 << r116
|
1637
|
+
if r116
|
1638
|
+
if input.index('[?(', index) == index
|
1639
|
+
r117 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
1640
|
+
@index += 3
|
1641
|
+
else
|
1642
|
+
terminal_parse_failure('[?(')
|
1643
|
+
r117 = nil
|
1644
|
+
end
|
1645
|
+
s115 << r117
|
1646
|
+
if r117
|
1647
|
+
s118, i118 = [], index
|
1648
|
+
loop do
|
1649
|
+
i119, s119 = index, []
|
1650
|
+
i120 = index
|
1651
|
+
if input.index(')]', index) == index
|
1652
|
+
r121 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1653
|
+
@index += 2
|
1654
|
+
else
|
1655
|
+
terminal_parse_failure(')]')
|
1656
|
+
r121 = nil
|
1657
|
+
end
|
1658
|
+
if r121
|
1659
|
+
r120 = nil
|
1660
|
+
else
|
1661
|
+
self.index = i120
|
1662
|
+
r120 = instantiate_node(SyntaxNode,input, index...index)
|
1663
|
+
end
|
1664
|
+
s119 << r120
|
1665
|
+
if r120
|
1666
|
+
if index < input_length
|
1667
|
+
r122 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1668
|
+
@index += 1
|
1669
|
+
else
|
1670
|
+
terminal_parse_failure("any character")
|
1671
|
+
r122 = nil
|
1672
|
+
end
|
1673
|
+
s119 << r122
|
1674
|
+
end
|
1675
|
+
if s119.last
|
1676
|
+
r119 = instantiate_node(SyntaxNode,input, i119...index, s119)
|
1677
|
+
r119.extend(Child23)
|
1678
|
+
else
|
1679
|
+
self.index = i119
|
1680
|
+
r119 = nil
|
1681
|
+
end
|
1682
|
+
if r119
|
1683
|
+
s118 << r119
|
1684
|
+
else
|
1685
|
+
break
|
1686
|
+
end
|
1687
|
+
end
|
1688
|
+
if s118.empty?
|
1689
|
+
self.index = i118
|
1690
|
+
r118 = nil
|
1691
|
+
else
|
1692
|
+
r118 = instantiate_node(SyntaxNode,input, i118...index, s118)
|
1693
|
+
end
|
1694
|
+
s115 << r118
|
1695
|
+
if r118
|
1696
|
+
if input.index(')]', index) == index
|
1697
|
+
r123 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1698
|
+
@index += 2
|
1699
|
+
else
|
1700
|
+
terminal_parse_failure(')]')
|
1701
|
+
r123 = nil
|
1702
|
+
end
|
1703
|
+
s115 << r123
|
1704
|
+
end
|
1705
|
+
end
|
1706
|
+
end
|
1707
|
+
if s115.last
|
1708
|
+
r115 = instantiate_node(JSONPath::Nodes::FilterNode,input, i115...index, s115)
|
1709
|
+
r115.extend(Child24)
|
1710
|
+
else
|
1711
|
+
self.index = i115
|
1712
|
+
r115 = nil
|
1713
|
+
end
|
1714
|
+
if r115
|
1715
|
+
r0 = r115
|
1716
|
+
else
|
1717
|
+
i124, s124 = index, []
|
1718
|
+
if input.index('[', index) == index
|
1719
|
+
r125 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1720
|
+
@index += 1
|
1721
|
+
else
|
1722
|
+
terminal_parse_failure('[')
|
1723
|
+
r125 = nil
|
1724
|
+
end
|
1725
|
+
s124 << r125
|
1726
|
+
if r125
|
1727
|
+
r126 = _nt_word_list
|
1728
|
+
s124 << r126
|
1729
|
+
if r126
|
1730
|
+
if input.index(']', index) == index
|
1731
|
+
r127 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1732
|
+
@index += 1
|
1733
|
+
else
|
1734
|
+
terminal_parse_failure(']')
|
1735
|
+
r127 = nil
|
1736
|
+
end
|
1737
|
+
s124 << r127
|
1738
|
+
end
|
1739
|
+
end
|
1740
|
+
if s124.last
|
1741
|
+
r124 = instantiate_node(JSONPath::Nodes::KeyNode,input, i124...index, s124)
|
1742
|
+
r124.extend(Child25)
|
1743
|
+
else
|
1744
|
+
self.index = i124
|
1745
|
+
r124 = nil
|
1746
|
+
end
|
1747
|
+
if r124
|
1748
|
+
r0 = r124
|
1749
|
+
else
|
1750
|
+
i128, s128 = index, []
|
1751
|
+
r129 = _nt_lower
|
1752
|
+
s128 << r129
|
1753
|
+
if r129
|
1754
|
+
if input.index('[', index) == index
|
1755
|
+
r130 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1756
|
+
@index += 1
|
1757
|
+
else
|
1758
|
+
terminal_parse_failure('[')
|
1759
|
+
r130 = nil
|
1760
|
+
end
|
1761
|
+
s128 << r130
|
1762
|
+
if r130
|
1763
|
+
r131 = _nt_word_list
|
1764
|
+
s128 << r131
|
1765
|
+
if r131
|
1766
|
+
if input.index(']', index) == index
|
1767
|
+
r132 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1768
|
+
@index += 1
|
1769
|
+
else
|
1770
|
+
terminal_parse_failure(']')
|
1771
|
+
r132 = nil
|
1772
|
+
end
|
1773
|
+
s128 << r132
|
1774
|
+
end
|
1775
|
+
end
|
1776
|
+
end
|
1777
|
+
if s128.last
|
1778
|
+
r128 = instantiate_node(JSONPath::Nodes::KeyNode,input, i128...index, s128)
|
1779
|
+
r128.extend(Child26)
|
1780
|
+
else
|
1781
|
+
self.index = i128
|
1782
|
+
r128 = nil
|
1783
|
+
end
|
1784
|
+
if r128
|
1785
|
+
r0 = r128
|
1786
|
+
else
|
1787
|
+
self.index = i0
|
1788
|
+
r0 = nil
|
1789
|
+
end
|
1790
|
+
end
|
1791
|
+
end
|
1792
|
+
end
|
1793
|
+
end
|
1794
|
+
end
|
1795
|
+
end
|
1796
|
+
end
|
1797
|
+
end
|
1798
|
+
end
|
1799
|
+
end
|
1800
|
+
end
|
1801
|
+
end
|
1802
|
+
end
|
1803
|
+
end
|
1804
|
+
end
|
1805
|
+
end
|
1806
|
+
end
|
1807
|
+
end
|
1808
|
+
end
|
1809
|
+
end
|
1810
|
+
|
1811
|
+
node_cache[:child][start_index] = r0
|
1812
|
+
|
1813
|
+
return r0
|
1814
|
+
end
|
1815
|
+
|
1816
|
+
def _nt_bareword
|
1817
|
+
start_index = index
|
1818
|
+
if node_cache[:bareword].has_key?(index)
|
1819
|
+
cached = node_cache[:bareword][index]
|
1820
|
+
@index = cached.interval.end if cached
|
1821
|
+
return cached
|
1822
|
+
end
|
1823
|
+
|
1824
|
+
s0, i0 = [], index
|
1825
|
+
loop do
|
1826
|
+
if input.index(Regexp.new('[a-zA-Z0-9]'), index) == index
|
1827
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1828
|
+
@index += 1
|
1829
|
+
else
|
1830
|
+
r1 = nil
|
1831
|
+
end
|
1832
|
+
if r1
|
1833
|
+
s0 << r1
|
1834
|
+
else
|
1835
|
+
break
|
1836
|
+
end
|
1837
|
+
end
|
1838
|
+
if s0.empty?
|
1839
|
+
self.index = i0
|
1840
|
+
r0 = nil
|
1841
|
+
else
|
1842
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1843
|
+
end
|
1844
|
+
|
1845
|
+
node_cache[:bareword][start_index] = r0
|
1846
|
+
|
1847
|
+
return r0
|
1848
|
+
end
|
1849
|
+
|
1850
|
+
end
|
1851
|
+
|
1852
|
+
class JSONPathGrammarParser < Treetop::Runtime::CompiledParser
|
1853
|
+
include JSONPathGrammar
|
1854
|
+
end
|