vanilla 1.2 → 1.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +61 -60
- data/bin/vanilla +6 -35
- data/config.example.yml +6 -0
- data/config.ru +10 -0
- data/lib/defensio.rb +59 -0
- data/lib/tasks/vanilla.rake +173 -0
- data/lib/vanilla.rb +3 -10
- data/lib/vanilla/app.rb +48 -104
- data/lib/vanilla/console.rb +5 -19
- data/lib/vanilla/dynasnips/comments.rb +108 -0
- data/lib/vanilla/dynasnips/current_snip.rb +32 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/debug.rb +3 -5
- data/lib/vanilla/dynasnips/edit.rb +60 -0
- data/lib/vanilla/dynasnips/edit_link.rb +20 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/index.rb +2 -4
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/kind.rb +12 -14
- data/{pristine_app/soups → lib/vanilla}/dynasnips/link_to.rb +0 -2
- data/lib/vanilla/dynasnips/link_to_current_snip.rb +16 -0
- data/lib/vanilla/dynasnips/login.rb +56 -0
- data/lib/vanilla/dynasnips/new.rb +14 -0
- data/lib/vanilla/dynasnips/notes.rb +42 -0
- data/{pristine_app/soups → lib/vanilla}/dynasnips/pre.rb +4 -6
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/rand.rb +0 -2
- data/{pristine_app/soups → lib/vanilla}/dynasnips/raw.rb +5 -8
- data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/url_to.rb +0 -0
- data/lib/vanilla/renderers/base.rb +22 -32
- data/lib/vanilla/renderers/bold.rb +2 -0
- data/lib/vanilla/renderers/erb.rb +2 -0
- data/lib/vanilla/renderers/markdown.rb +2 -0
- data/lib/vanilla/renderers/raw.rb +2 -0
- data/lib/vanilla/renderers/ruby.rb +5 -9
- data/lib/vanilla/renderers/textile.rb +2 -0
- data/lib/vanilla/request.rb +15 -16
- data/lib/vanilla/routes.rb +18 -5
- data/lib/vanilla/snip_reference.rb +534 -0
- data/lib/vanilla/snip_reference.treetop +48 -0
- data/lib/vanilla/snip_reference_parser.rb +99 -82
- data/lib/vanilla/snips/start.rb +28 -0
- data/lib/vanilla/snips/system.rb +77 -0
- data/lib/vanilla/snips/tutorial.rb +244 -0
- data/lib/vanilla/soup_with_timestamps.rb +21 -0
- data/public/hatch.png +0 -0
- data/public/javascripts/jquery.autogrow-textarea.js +54 -0
- data/public/javascripts/jquery.js +4376 -0
- data/public/javascripts/vanilla.js +22 -0
- data/spec/dynasnip_spec.rb +28 -0
- data/spec/renderers/base_renderer_spec.rb +40 -0
- data/spec/renderers/erb_renderer_spec.rb +27 -0
- data/spec/renderers/markdown_renderer_spec.rb +29 -0
- data/spec/renderers/raw_renderer_spec.rb +21 -0
- data/spec/renderers/ruby_renderer_spec.rb +59 -0
- data/spec/renderers/vanilla_app_detecting_renderer_spec.rb +35 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/tmp/config.yml +2 -0
- data/spec/tmp/soup/current_snip.yml +15 -0
- data/spec/tmp/soup/system.yml +5 -0
- data/spec/vanilla_app_spec.rb +38 -0
- data/spec/vanilla_presenting_spec.rb +84 -0
- data/spec/vanilla_request_spec.rb +73 -0
- metadata +79 -170
- data/lib/vanilla/renderers.rb +0 -12
- data/lib/vanilla/renderers/haml.rb +0 -13
- data/lib/vanilla/static.rb +0 -28
- data/pristine_app/Gemfile +0 -3
- data/pristine_app/Gemfile.lock +0 -32
- data/pristine_app/README +0 -47
- data/pristine_app/config.ru +0 -26
- data/pristine_app/public/vanilla.css +0 -15
- data/pristine_app/soups/base/layout.snip +0 -18
- data/pristine_app/soups/base/start.snip +0 -19
- data/pristine_app/soups/dynasnips/current_snip.rb +0 -29
- data/pristine_app/soups/dynasnips/link_to_current_snip.rb +0 -14
- data/pristine_app/soups/dynasnips/page_title.rb +0 -9
- data/pristine_app/soups/extras/comments.rb +0 -78
- data/pristine_app/soups/tutorial/bad_dynasnip.snip +0 -8
- data/pristine_app/soups/tutorial/hello_world.snip +0 -20
- data/pristine_app/soups/tutorial/markdown_example.snip +0 -13
- data/pristine_app/soups/tutorial/snip.snip +0 -9
- data/pristine_app/soups/tutorial/soup.snip +0 -3
- data/pristine_app/soups/tutorial/test.snip +0 -30
- data/pristine_app/soups/tutorial/textile_example.snip +0 -11
- data/pristine_app/soups/tutorial/tutorial-another-snip.snip +0 -1
- data/pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip +0 -1
- data/pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown +0 -56
- data/pristine_app/soups/tutorial/tutorial-layout.snip +0 -56
- data/pristine_app/soups/tutorial/tutorial-links.snip +0 -4
- data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +0 -77
- data/pristine_app/soups/tutorial/tutorial.snip.markdown +0 -69
- data/pristine_app/soups/tutorial/vanilla-rb.snip +0 -16
- data/pristine_app/soups/tutorial/vanilla.snip +0 -8
- data/test/dynasnip_test.rb +0 -42
- data/test/dynasnips/link_to_current_snip_test.rb +0 -19
- data/test/dynasnips/link_to_test.rb +0 -27
- data/test/dynasnips/page_title_test.rb +0 -19
- data/test/renderers/base_renderer_test.rb +0 -43
- data/test/renderers/erb_renderer_test.rb +0 -29
- data/test/renderers/haml_renderer_test.rb +0 -35
- data/test/renderers/markdown_renderer_test.rb +0 -31
- data/test/renderers/raw_renderer_test.rb +0 -23
- data/test/renderers/ruby_renderer_test.rb +0 -59
- data/test/snip_inclusion_test.rb +0 -56
- data/test/snip_reference_parser_test.rb +0 -123
- data/test/test_helper.rb +0 -75
- data/test/vanilla_app_test.rb +0 -83
- data/test/vanilla_presenting_test.rb +0 -125
- data/test/vanilla_request_test.rb +0 -87
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vanilla/renderers/base'
|
2
|
+
|
1
3
|
module Vanilla::Renderers
|
2
4
|
# Snips that render_as "Ruby" should define a class.
|
3
5
|
# The class should have instance methods for any HTTP request methods that the dynasnip
|
@@ -25,16 +27,10 @@ module Vanilla::Renderers
|
|
25
27
|
handler_klass.new
|
26
28
|
end
|
27
29
|
instance.enclosing_snip = @enclosing_snip if instance.respond_to?(:enclosing_snip)
|
28
|
-
|
29
|
-
|
30
|
-
message = method
|
31
|
-
else
|
32
|
-
message = :handle
|
33
|
-
end
|
34
|
-
if @args.is_a?(Array)
|
35
|
-
instance.send(message, *@args).to_s
|
30
|
+
if (method = app.request.method) && instance.respond_to?(method)
|
31
|
+
instance.send(method, *@args).to_s
|
36
32
|
else
|
37
|
-
instance.
|
33
|
+
instance.handle(*@args).to_s
|
38
34
|
end
|
39
35
|
end
|
40
36
|
end
|
data/lib/vanilla/request.rb
CHANGED
@@ -4,10 +4,9 @@ module Vanilla
|
|
4
4
|
# Create a request with symbolised access to the params, and some special
|
5
5
|
# accessors to the snip, part and format based on our routing.
|
6
6
|
class Request
|
7
|
-
attr_reader :snip_name, :part, :format, :method
|
8
|
-
|
7
|
+
attr_reader :snip_name, :part, :format, :method
|
8
|
+
|
9
9
|
def initialize(env, app)
|
10
|
-
@env = env
|
11
10
|
@rack_request = Rack::Request.new(env)
|
12
11
|
@app = app
|
13
12
|
determine_request_uri_parts
|
@@ -17,46 +16,46 @@ module Vanilla
|
|
17
16
|
# Don't you just love how terse functional programming tends to look like maths?
|
18
17
|
@symbolised_params ||= @rack_request.params.inject({}) { |p, (k,v)| p[k.to_sym] = v; p }
|
19
18
|
end
|
20
|
-
|
19
|
+
|
21
20
|
# Returns the snip referenced by the request's URL. Performs no exception
|
22
21
|
# handling, so if the snip does not exist, an exception will be thrown.
|
23
22
|
def snip
|
24
23
|
@app.soup[snip_name]
|
25
24
|
end
|
26
|
-
|
25
|
+
|
27
26
|
def cookies
|
28
27
|
@rack_request.cookies
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
def ip
|
32
31
|
@rack_request.env["REMOTE_ADDR"]
|
33
32
|
end
|
34
|
-
|
33
|
+
|
35
34
|
def session
|
36
35
|
@rack_request.env["rack.session"]
|
37
36
|
end
|
38
|
-
|
37
|
+
|
39
38
|
private
|
40
|
-
|
39
|
+
|
41
40
|
def determine_request_uri_parts
|
42
41
|
@snip_name, @part, @format = request_uri_parts(@rack_request)
|
43
42
|
@format ||= 'html'
|
44
43
|
@method = (params.delete(:_method) || @rack_request.request_method).downcase
|
45
44
|
end
|
46
|
-
|
45
|
+
|
47
46
|
def uri_path(request)
|
48
47
|
request.path_info
|
49
48
|
end
|
50
|
-
|
51
|
-
URL_ROOT = /\A
|
49
|
+
|
50
|
+
URL_ROOT = /\A\/\Z/ # i.e. /
|
52
51
|
URL_SNIP = /\A\/([\w\-\s]+)(\/|\.(\w+))?\Z/ # i.e. /start, /start.html
|
53
52
|
URL_SNIP_AND_PART = /\A\/([\w\-\s]+)\/([\w\-\s]+)(\/|\.(\w+))?\Z/ # i.e. /blah/part, /blah/part.raw
|
54
|
-
|
53
|
+
|
55
54
|
# Returns an array of the requested snip, part and format
|
56
55
|
def request_uri_parts(request)
|
57
56
|
case CGI.unescape(uri_path(request))
|
58
57
|
when URL_ROOT
|
59
|
-
[
|
58
|
+
['start', nil, 'html']
|
60
59
|
when URL_SNIP
|
61
60
|
[$1, nil, $3]
|
62
61
|
when URL_SNIP_AND_PART
|
@@ -65,6 +64,6 @@ module Vanilla
|
|
65
64
|
[]
|
66
65
|
end
|
67
66
|
end
|
68
|
-
|
67
|
+
|
69
68
|
end
|
70
|
-
end
|
69
|
+
end
|
data/lib/vanilla/routes.rb
CHANGED
@@ -2,11 +2,7 @@ module Vanilla
|
|
2
2
|
# Expects to be able to call 'soup' on whatever it is included into
|
3
3
|
module Routes
|
4
4
|
def link_to(link_text, snip_name=link_text, part=nil)
|
5
|
-
|
6
|
-
%{<a href="#{url_to(snip_name, part)}">#{link_text}</a>}
|
7
|
-
else
|
8
|
-
%{<a class="missing" href="#{url_to(snip_name, part)}">#{link_text}</a>}
|
9
|
-
end
|
5
|
+
soup[snip_name] ? existing_link(link_text, snip_name, part) : new_link(snip_name)
|
10
6
|
end
|
11
7
|
|
12
8
|
def url_to(snip_name, part=nil)
|
@@ -14,5 +10,22 @@ module Vanilla
|
|
14
10
|
url += "/#{part}" if part
|
15
11
|
url
|
16
12
|
end
|
13
|
+
|
14
|
+
def url_to_raw(snip_name, part=nil)
|
15
|
+
url = url_to(snip_name, part)
|
16
|
+
url += ".raw"
|
17
|
+
end
|
18
|
+
|
19
|
+
def existing_link(link_text, snip_name=link_text, part=nil)
|
20
|
+
%{<a href="#{url_to(snip_name, part)}">#{link_text}</a>}
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit_link(snip_name, link_text)
|
24
|
+
%[<a href="/edit?name=#{snip_name.gsub(" ", "+")}">#{link_text}</a>]
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_link(snip_name="New")
|
28
|
+
%[<a href="/new?name=#{snip_name ? snip_name.gsub(" ", "+") : nil}" class="new">#{snip_name}</a>]
|
29
|
+
end
|
17
30
|
end
|
18
31
|
end
|
@@ -0,0 +1,534 @@
|
|
1
|
+
module SnipReference
|
2
|
+
include Treetop::Runtime
|
3
|
+
|
4
|
+
def root
|
5
|
+
@root || :snip_call
|
6
|
+
end
|
7
|
+
|
8
|
+
module SnipCall0
|
9
|
+
def spaces
|
10
|
+
elements[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def argument_list
|
14
|
+
elements[1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module SnipCall1
|
19
|
+
end
|
20
|
+
|
21
|
+
def _nt_snip_call
|
22
|
+
start_index = index
|
23
|
+
if node_cache[:snip_call].has_key?(index)
|
24
|
+
cached = node_cache[:snip_call][index]
|
25
|
+
@index = cached.interval.end if cached
|
26
|
+
return cached
|
27
|
+
end
|
28
|
+
|
29
|
+
i0, s0 = index, []
|
30
|
+
if has_terminal?("{", false, index)
|
31
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
32
|
+
@index += 1
|
33
|
+
else
|
34
|
+
terminal_parse_failure("{")
|
35
|
+
r1 = nil
|
36
|
+
end
|
37
|
+
s0 << r1
|
38
|
+
if r1
|
39
|
+
r2 = _nt_snip_name
|
40
|
+
s0 << r2
|
41
|
+
if r2
|
42
|
+
i4, s4 = index, []
|
43
|
+
r5 = _nt_spaces
|
44
|
+
s4 << r5
|
45
|
+
if r5
|
46
|
+
r6 = _nt_argument_list
|
47
|
+
s4 << r6
|
48
|
+
end
|
49
|
+
if s4.last
|
50
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
51
|
+
r4.extend(SnipCall0)
|
52
|
+
else
|
53
|
+
@index = i4
|
54
|
+
r4 = nil
|
55
|
+
end
|
56
|
+
if r4
|
57
|
+
r3 = r4
|
58
|
+
else
|
59
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
60
|
+
end
|
61
|
+
s0 << r3
|
62
|
+
if r3
|
63
|
+
if has_terminal?("}", false, index)
|
64
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
65
|
+
@index += 1
|
66
|
+
else
|
67
|
+
terminal_parse_failure("}")
|
68
|
+
r7 = nil
|
69
|
+
end
|
70
|
+
s0 << r7
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
if s0.last
|
75
|
+
r0 = instantiate_node(SnipCall,input, i0...index, s0)
|
76
|
+
r0.extend(SnipCall1)
|
77
|
+
else
|
78
|
+
@index = i0
|
79
|
+
r0 = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
node_cache[:snip_call][start_index] = r0
|
83
|
+
|
84
|
+
r0
|
85
|
+
end
|
86
|
+
|
87
|
+
module SnipName0
|
88
|
+
def word
|
89
|
+
elements[0]
|
90
|
+
end
|
91
|
+
|
92
|
+
def word
|
93
|
+
elements[2]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def _nt_snip_name
|
98
|
+
start_index = index
|
99
|
+
if node_cache[:snip_name].has_key?(index)
|
100
|
+
cached = node_cache[:snip_name][index]
|
101
|
+
@index = cached.interval.end if cached
|
102
|
+
return cached
|
103
|
+
end
|
104
|
+
|
105
|
+
i0 = index
|
106
|
+
i1, s1 = index, []
|
107
|
+
r2 = _nt_word
|
108
|
+
s1 << r2
|
109
|
+
if r2
|
110
|
+
if has_terminal?(".", false, index)
|
111
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
112
|
+
@index += 1
|
113
|
+
else
|
114
|
+
terminal_parse_failure(".")
|
115
|
+
r3 = nil
|
116
|
+
end
|
117
|
+
s1 << r3
|
118
|
+
if r3
|
119
|
+
r4 = _nt_word
|
120
|
+
s1 << r4
|
121
|
+
end
|
122
|
+
end
|
123
|
+
if s1.last
|
124
|
+
r1 = instantiate_node(SnipNameWithAttribute,input, i1...index, s1)
|
125
|
+
r1.extend(SnipName0)
|
126
|
+
else
|
127
|
+
@index = i1
|
128
|
+
r1 = nil
|
129
|
+
end
|
130
|
+
if r1
|
131
|
+
r0 = r1
|
132
|
+
else
|
133
|
+
r5 = _nt_word
|
134
|
+
r5.extend(SnipName)
|
135
|
+
if r5
|
136
|
+
r0 = r5
|
137
|
+
else
|
138
|
+
@index = i0
|
139
|
+
r0 = nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
node_cache[:snip_name][start_index] = r0
|
144
|
+
|
145
|
+
r0
|
146
|
+
end
|
147
|
+
|
148
|
+
module ArgumentList0
|
149
|
+
def argument_separator
|
150
|
+
elements[0]
|
151
|
+
end
|
152
|
+
|
153
|
+
def argument_list
|
154
|
+
elements[1]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
module ArgumentList1
|
159
|
+
def argument
|
160
|
+
elements[0]
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
def _nt_argument_list
|
166
|
+
start_index = index
|
167
|
+
if node_cache[:argument_list].has_key?(index)
|
168
|
+
cached = node_cache[:argument_list][index]
|
169
|
+
@index = cached.interval.end if cached
|
170
|
+
return cached
|
171
|
+
end
|
172
|
+
|
173
|
+
i0, s0 = index, []
|
174
|
+
r1 = _nt_argument
|
175
|
+
s0 << r1
|
176
|
+
if r1
|
177
|
+
i3, s3 = index, []
|
178
|
+
r4 = _nt_argument_separator
|
179
|
+
s3 << r4
|
180
|
+
if r4
|
181
|
+
r5 = _nt_argument_list
|
182
|
+
s3 << r5
|
183
|
+
end
|
184
|
+
if s3.last
|
185
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
186
|
+
r3.extend(ArgumentList0)
|
187
|
+
else
|
188
|
+
@index = i3
|
189
|
+
r3 = nil
|
190
|
+
end
|
191
|
+
if r3
|
192
|
+
r2 = r3
|
193
|
+
else
|
194
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
195
|
+
end
|
196
|
+
s0 << r2
|
197
|
+
end
|
198
|
+
if s0.last
|
199
|
+
r0 = instantiate_node(ArgumentList,input, i0...index, s0)
|
200
|
+
r0.extend(ArgumentList1)
|
201
|
+
else
|
202
|
+
@index = i0
|
203
|
+
r0 = nil
|
204
|
+
end
|
205
|
+
|
206
|
+
node_cache[:argument_list][start_index] = r0
|
207
|
+
|
208
|
+
r0
|
209
|
+
end
|
210
|
+
|
211
|
+
def _nt_argument
|
212
|
+
start_index = index
|
213
|
+
if node_cache[:argument].has_key?(index)
|
214
|
+
cached = node_cache[:argument][index]
|
215
|
+
@index = cached.interval.end if cached
|
216
|
+
return cached
|
217
|
+
end
|
218
|
+
|
219
|
+
i0 = index
|
220
|
+
r1 = _nt_unquoted_words
|
221
|
+
r1.extend(NormalArgument)
|
222
|
+
if r1
|
223
|
+
r0 = r1
|
224
|
+
else
|
225
|
+
r2 = _nt_quoted_word
|
226
|
+
r2.extend(NormalArgument)
|
227
|
+
if r2
|
228
|
+
r0 = r2
|
229
|
+
else
|
230
|
+
@index = i0
|
231
|
+
r0 = nil
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
node_cache[:argument][start_index] = r0
|
236
|
+
|
237
|
+
r0
|
238
|
+
end
|
239
|
+
|
240
|
+
module ArgumentSeparator0
|
241
|
+
def optional_spaces
|
242
|
+
elements[1]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def _nt_argument_separator
|
247
|
+
start_index = index
|
248
|
+
if node_cache[:argument_separator].has_key?(index)
|
249
|
+
cached = node_cache[:argument_separator][index]
|
250
|
+
@index = cached.interval.end if cached
|
251
|
+
return cached
|
252
|
+
end
|
253
|
+
|
254
|
+
i0, s0 = index, []
|
255
|
+
if has_terminal?(",", false, index)
|
256
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
257
|
+
@index += 1
|
258
|
+
else
|
259
|
+
terminal_parse_failure(",")
|
260
|
+
r1 = nil
|
261
|
+
end
|
262
|
+
s0 << r1
|
263
|
+
if r1
|
264
|
+
r2 = _nt_optional_spaces
|
265
|
+
s0 << r2
|
266
|
+
end
|
267
|
+
if s0.last
|
268
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
269
|
+
r0.extend(ArgumentSeparator0)
|
270
|
+
else
|
271
|
+
@index = i0
|
272
|
+
r0 = nil
|
273
|
+
end
|
274
|
+
|
275
|
+
node_cache[:argument_separator][start_index] = r0
|
276
|
+
|
277
|
+
r0
|
278
|
+
end
|
279
|
+
|
280
|
+
def _nt_word
|
281
|
+
start_index = index
|
282
|
+
if node_cache[:word].has_key?(index)
|
283
|
+
cached = node_cache[:word][index]
|
284
|
+
@index = cached.interval.end if cached
|
285
|
+
return cached
|
286
|
+
end
|
287
|
+
|
288
|
+
i0 = index
|
289
|
+
r1 = _nt_unquoted_word
|
290
|
+
if r1
|
291
|
+
r0 = r1
|
292
|
+
else
|
293
|
+
r2 = _nt_quoted_word
|
294
|
+
if r2
|
295
|
+
r0 = r2
|
296
|
+
else
|
297
|
+
@index = i0
|
298
|
+
r0 = nil
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
node_cache[:word][start_index] = r0
|
303
|
+
|
304
|
+
r0
|
305
|
+
end
|
306
|
+
|
307
|
+
def _nt_unquoted_word
|
308
|
+
start_index = index
|
309
|
+
if node_cache[:unquoted_word].has_key?(index)
|
310
|
+
cached = node_cache[:unquoted_word][index]
|
311
|
+
@index = cached.interval.end if cached
|
312
|
+
return cached
|
313
|
+
end
|
314
|
+
|
315
|
+
s0, i0 = [], index
|
316
|
+
loop do
|
317
|
+
if has_terminal?('\G[a-zA-Z0-9_\\-]', true, index)
|
318
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
319
|
+
@index += 1
|
320
|
+
else
|
321
|
+
r1 = nil
|
322
|
+
end
|
323
|
+
if r1
|
324
|
+
s0 << r1
|
325
|
+
else
|
326
|
+
break
|
327
|
+
end
|
328
|
+
end
|
329
|
+
if s0.empty?
|
330
|
+
@index = i0
|
331
|
+
r0 = nil
|
332
|
+
else
|
333
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
334
|
+
end
|
335
|
+
|
336
|
+
node_cache[:unquoted_word][start_index] = r0
|
337
|
+
|
338
|
+
r0
|
339
|
+
end
|
340
|
+
|
341
|
+
module QuotedWord0
|
342
|
+
end
|
343
|
+
|
344
|
+
module QuotedWord1
|
345
|
+
end
|
346
|
+
|
347
|
+
def _nt_quoted_word
|
348
|
+
start_index = index
|
349
|
+
if node_cache[:quoted_word].has_key?(index)
|
350
|
+
cached = node_cache[:quoted_word][index]
|
351
|
+
@index = cached.interval.end if cached
|
352
|
+
return cached
|
353
|
+
end
|
354
|
+
|
355
|
+
i0 = index
|
356
|
+
i1, s1 = index, []
|
357
|
+
if has_terminal?("\"", false, index)
|
358
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
359
|
+
@index += 1
|
360
|
+
else
|
361
|
+
terminal_parse_failure("\"")
|
362
|
+
r2 = nil
|
363
|
+
end
|
364
|
+
s1 << r2
|
365
|
+
if r2
|
366
|
+
r3 = _nt_unquoted_words
|
367
|
+
s1 << r3
|
368
|
+
if r3
|
369
|
+
if has_terminal?("\"", false, index)
|
370
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
371
|
+
@index += 1
|
372
|
+
else
|
373
|
+
terminal_parse_failure("\"")
|
374
|
+
r4 = nil
|
375
|
+
end
|
376
|
+
s1 << r4
|
377
|
+
end
|
378
|
+
end
|
379
|
+
if s1.last
|
380
|
+
r1 = instantiate_node(QuotedWord,input, i1...index, s1)
|
381
|
+
r1.extend(QuotedWord0)
|
382
|
+
else
|
383
|
+
@index = i1
|
384
|
+
r1 = nil
|
385
|
+
end
|
386
|
+
if r1
|
387
|
+
r0 = r1
|
388
|
+
else
|
389
|
+
i5, s5 = index, []
|
390
|
+
if has_terminal?("'", false, index)
|
391
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
392
|
+
@index += 1
|
393
|
+
else
|
394
|
+
terminal_parse_failure("'")
|
395
|
+
r6 = nil
|
396
|
+
end
|
397
|
+
s5 << r6
|
398
|
+
if r6
|
399
|
+
r7 = _nt_unquoted_words
|
400
|
+
s5 << r7
|
401
|
+
if r7
|
402
|
+
if has_terminal?("'", false, index)
|
403
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
404
|
+
@index += 1
|
405
|
+
else
|
406
|
+
terminal_parse_failure("'")
|
407
|
+
r8 = nil
|
408
|
+
end
|
409
|
+
s5 << r8
|
410
|
+
end
|
411
|
+
end
|
412
|
+
if s5.last
|
413
|
+
r5 = instantiate_node(QuotedWord,input, i5...index, s5)
|
414
|
+
r5.extend(QuotedWord1)
|
415
|
+
else
|
416
|
+
@index = i5
|
417
|
+
r5 = nil
|
418
|
+
end
|
419
|
+
if r5
|
420
|
+
r0 = r5
|
421
|
+
else
|
422
|
+
@index = i0
|
423
|
+
r0 = nil
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
node_cache[:quoted_word][start_index] = r0
|
428
|
+
|
429
|
+
r0
|
430
|
+
end
|
431
|
+
|
432
|
+
def _nt_unquoted_words
|
433
|
+
start_index = index
|
434
|
+
if node_cache[:unquoted_words].has_key?(index)
|
435
|
+
cached = node_cache[:unquoted_words][index]
|
436
|
+
@index = cached.interval.end if cached
|
437
|
+
return cached
|
438
|
+
end
|
439
|
+
|
440
|
+
s0, i0 = [], index
|
441
|
+
loop do
|
442
|
+
if has_terminal?('\G[a-zA-Z0-9_\\- ]', true, index)
|
443
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
444
|
+
@index += 1
|
445
|
+
else
|
446
|
+
r1 = nil
|
447
|
+
end
|
448
|
+
if r1
|
449
|
+
s0 << r1
|
450
|
+
else
|
451
|
+
break
|
452
|
+
end
|
453
|
+
end
|
454
|
+
if s0.empty?
|
455
|
+
@index = i0
|
456
|
+
r0 = nil
|
457
|
+
else
|
458
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
459
|
+
end
|
460
|
+
|
461
|
+
node_cache[:unquoted_words][start_index] = r0
|
462
|
+
|
463
|
+
r0
|
464
|
+
end
|
465
|
+
|
466
|
+
def _nt_optional_spaces
|
467
|
+
start_index = index
|
468
|
+
if node_cache[:optional_spaces].has_key?(index)
|
469
|
+
cached = node_cache[:optional_spaces][index]
|
470
|
+
@index = cached.interval.end if cached
|
471
|
+
return cached
|
472
|
+
end
|
473
|
+
|
474
|
+
s0, i0 = [], index
|
475
|
+
loop do
|
476
|
+
if has_terminal?('\G[ ]', true, index)
|
477
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
478
|
+
@index += 1
|
479
|
+
else
|
480
|
+
r1 = nil
|
481
|
+
end
|
482
|
+
if r1
|
483
|
+
s0 << r1
|
484
|
+
else
|
485
|
+
break
|
486
|
+
end
|
487
|
+
end
|
488
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
489
|
+
|
490
|
+
node_cache[:optional_spaces][start_index] = r0
|
491
|
+
|
492
|
+
r0
|
493
|
+
end
|
494
|
+
|
495
|
+
def _nt_spaces
|
496
|
+
start_index = index
|
497
|
+
if node_cache[:spaces].has_key?(index)
|
498
|
+
cached = node_cache[:spaces][index]
|
499
|
+
@index = cached.interval.end if cached
|
500
|
+
return cached
|
501
|
+
end
|
502
|
+
|
503
|
+
s0, i0 = [], index
|
504
|
+
loop do
|
505
|
+
if has_terminal?('\G[ ]', true, index)
|
506
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
507
|
+
@index += 1
|
508
|
+
else
|
509
|
+
r1 = nil
|
510
|
+
end
|
511
|
+
if r1
|
512
|
+
s0 << r1
|
513
|
+
else
|
514
|
+
break
|
515
|
+
end
|
516
|
+
end
|
517
|
+
if s0.empty?
|
518
|
+
@index = i0
|
519
|
+
r0 = nil
|
520
|
+
else
|
521
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
522
|
+
end
|
523
|
+
|
524
|
+
node_cache[:spaces][start_index] = r0
|
525
|
+
|
526
|
+
r0
|
527
|
+
end
|
528
|
+
|
529
|
+
end
|
530
|
+
|
531
|
+
class SnipReferenceParser < Treetop::Runtime::CompiledParser
|
532
|
+
include SnipReference
|
533
|
+
end
|
534
|
+
|