code-ruby 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/code +8 -5
- data/lib/code/concerns/shared.rb +102 -98
- data/lib/code/format.rb +23 -19
- data/lib/code/network.rb +23 -28
- data/lib/code/node/call.rb +9 -8
- data/lib/code/node/code.rb +1 -1
- data/lib/code/node/list.rb +10 -8
- data/lib/code/node/square_bracket.rb +4 -2
- data/lib/code/object/boolean.rb +13 -17
- data/lib/code/object/class.rb +32 -27
- data/lib/code/object/code.rb +2 -9
- data/lib/code/object/context.rb +4 -2
- data/lib/code/object/cryptography.rb +12 -6
- data/lib/code/object/date.rb +910 -449
- data/lib/code/object/decimal.rb +229 -856
- data/lib/code/object/dictionary.rb +113 -42
- data/lib/code/object/duration.rb +3 -7
- data/lib/code/object/function.rb +64 -40
- data/lib/code/object/global.rb +121 -208
- data/lib/code/object/html.rb +4 -2
- data/lib/code/object/http.rb +32 -26
- data/lib/code/object/ics.rb +2 -1
- data/lib/code/object/identifier_list.rb +16 -11
- data/lib/code/object/integer.rb +270 -942
- data/lib/code/object/json.rb +8 -3
- data/lib/code/object/list.rb +97 -109
- data/lib/code/object/nothing.rb +11 -11
- data/lib/code/object/number.rb +20 -10
- data/lib/code/object/parameter.rb +18 -9
- data/lib/code/object/range.rb +62 -108
- data/lib/code/object/smtp.rb +20 -12
- data/lib/code/object/string.rb +52 -28
- data/lib/code/object/super.rb +2 -1
- data/lib/code/object/time.rb +1146 -572
- data/lib/code/object/url.rb +4 -2
- data/lib/code/object.rb +119 -80
- data/lib/code/parser.rb +34 -32
- metadata +1 -1
data/lib/code/object/url.rb
CHANGED
|
@@ -5,7 +5,8 @@ class Code
|
|
|
5
5
|
class Url < Object
|
|
6
6
|
CLASS_DOCUMENTATION = {
|
|
7
7
|
name: "Url",
|
|
8
|
-
description:
|
|
8
|
+
description:
|
|
9
|
+
"encodes text for urls, decodes url-escaped text, and parses strings as urls.",
|
|
9
10
|
examples: [
|
|
10
11
|
"Url.encode(\"hello world\")",
|
|
11
12
|
"Url.decode(\"a%2Fb%3Fx%3D1\")",
|
|
@@ -33,7 +34,8 @@ class Code
|
|
|
33
34
|
},
|
|
34
35
|
"parse" => {
|
|
35
36
|
name: "parse",
|
|
36
|
-
description:
|
|
37
|
+
description:
|
|
38
|
+
"returns a url parsed from a value, or an empty url when parsing fails.",
|
|
37
39
|
examples: [
|
|
38
40
|
"Url.parse(\"https://example.com/a?b=1\")",
|
|
39
41
|
"Url.parse(\"/path\")",
|
data/lib/code/object.rb
CHANGED
|
@@ -14,11 +14,7 @@ class Code
|
|
|
14
14
|
CLASS_DOCUMENTATION = {
|
|
15
15
|
name: "Object",
|
|
16
16
|
description: "provides the shared behavior available to every value.",
|
|
17
|
-
examples: [
|
|
18
|
-
"Object",
|
|
19
|
-
"Object.new",
|
|
20
|
-
"Object.documentation.description"
|
|
21
|
-
]
|
|
17
|
+
examples: %w[Object Object.new Object.documentation.description]
|
|
22
18
|
}.freeze
|
|
23
19
|
INSTANCE_FUNCTIONS = {
|
|
24
20
|
"documentation" => {
|
|
@@ -32,7 +28,8 @@ class Code
|
|
|
32
28
|
},
|
|
33
29
|
"functions" => {
|
|
34
30
|
name: "functions",
|
|
35
|
-
description:
|
|
31
|
+
description:
|
|
32
|
+
"returns documented instance and class functions available on the value.",
|
|
36
33
|
examples: [
|
|
37
34
|
"[].functions.keys.include?(:map)",
|
|
38
35
|
"1.functions.keys.include?(:to_string)",
|
|
@@ -41,7 +38,8 @@ class Code
|
|
|
41
38
|
},
|
|
42
39
|
"instance_functions" => {
|
|
43
40
|
name: "instance_functions",
|
|
44
|
-
description:
|
|
41
|
+
description:
|
|
42
|
+
"returns documented functions available on values of the receiver.",
|
|
45
43
|
examples: [
|
|
46
44
|
"[].instance_functions.keys.include?(:map)",
|
|
47
45
|
"1.instance_functions.keys.include?(:to_string)",
|
|
@@ -50,7 +48,8 @@ class Code
|
|
|
50
48
|
},
|
|
51
49
|
"class_functions" => {
|
|
52
50
|
name: "class_functions",
|
|
53
|
-
description:
|
|
51
|
+
description:
|
|
52
|
+
"returns documented functions available on the receiver constructor.",
|
|
54
53
|
examples: [
|
|
55
54
|
"[].class_functions",
|
|
56
55
|
"List.class_functions.keys.include?(:new)",
|
|
@@ -59,7 +58,8 @@ class Code
|
|
|
59
58
|
},
|
|
60
59
|
"respond_to?" => {
|
|
61
60
|
name: "respond_to?",
|
|
62
|
-
description:
|
|
61
|
+
description:
|
|
62
|
+
"returns whether the value responds to the named function.",
|
|
63
63
|
examples: [
|
|
64
64
|
"[].respond_to?(:map)",
|
|
65
65
|
"1.respond_to?(:zero?)",
|
|
@@ -83,7 +83,8 @@ class Code
|
|
|
83
83
|
},
|
|
84
84
|
"presence_in" => {
|
|
85
85
|
name: "presence_in",
|
|
86
|
-
description:
|
|
86
|
+
description:
|
|
87
|
+
"returns the value when it is included in the list, otherwise nothing.",
|
|
87
88
|
examples: [
|
|
88
89
|
"2.presence_in([1, 2, 3])",
|
|
89
90
|
"4.presence_in([1, 2, 3])",
|
|
@@ -92,7 +93,8 @@ class Code
|
|
|
92
93
|
},
|
|
93
94
|
"is_a?" => {
|
|
94
95
|
name: "is_a?",
|
|
95
|
-
description:
|
|
96
|
+
description:
|
|
97
|
+
"returns whether the value is an instance of the class or one of its subclasses.",
|
|
96
98
|
examples: ["1.is_a?(Integer)", ":a.is_a?(String)", "[].is_a?(List)"]
|
|
97
99
|
},
|
|
98
100
|
"is_an?" => {
|
|
@@ -103,11 +105,16 @@ class Code
|
|
|
103
105
|
"kind_of?" => {
|
|
104
106
|
name: "kind_of?",
|
|
105
107
|
description: "alias for is_a?.",
|
|
106
|
-
examples: [
|
|
108
|
+
examples: [
|
|
109
|
+
"1.kind_of?(Integer)",
|
|
110
|
+
":a.kind_of?(String)",
|
|
111
|
+
"[].kind_of?(List)"
|
|
112
|
+
]
|
|
107
113
|
},
|
|
108
114
|
"instance_of?" => {
|
|
109
115
|
name: "instance_of?",
|
|
110
|
-
description:
|
|
116
|
+
description:
|
|
117
|
+
"returns whether the value is exactly an instance of the class.",
|
|
111
118
|
examples: [
|
|
112
119
|
"1.instance_of?(Integer)",
|
|
113
120
|
":a.instance_of?(String)",
|
|
@@ -117,36 +124,41 @@ class Code
|
|
|
117
124
|
"!" => {
|
|
118
125
|
name: "!",
|
|
119
126
|
description: "returns the boolean negation of the value.",
|
|
120
|
-
examples: [
|
|
127
|
+
examples: %w[!true !false !nothing]
|
|
121
128
|
},
|
|
122
129
|
"not" => {
|
|
123
130
|
name: "not",
|
|
124
131
|
description: "returns the boolean negation of the value.",
|
|
125
|
-
examples: [
|
|
132
|
+
examples: %w[true.not false.not nothing.not]
|
|
126
133
|
},
|
|
127
134
|
"!=" => {
|
|
128
135
|
name: "!=",
|
|
129
|
-
description:
|
|
136
|
+
description:
|
|
137
|
+
"returns whether the value is different from another value.",
|
|
130
138
|
examples: ["1 != 2", ":a != :b", "[1] != [2]"]
|
|
131
139
|
},
|
|
132
140
|
"different" => {
|
|
133
141
|
name: "different",
|
|
134
|
-
description:
|
|
142
|
+
description:
|
|
143
|
+
"returns whether the value is different from another value.",
|
|
135
144
|
examples: ["1.different(2)", ":a.different(:b)", "[1].different([2])"]
|
|
136
145
|
},
|
|
137
146
|
"&&" => {
|
|
138
147
|
name: "&&",
|
|
139
|
-
description:
|
|
148
|
+
description:
|
|
149
|
+
"returns the other value when the receiver is truthy, otherwise the receiver.",
|
|
140
150
|
examples: ["true && 1", "false && 1", "1 && 2"]
|
|
141
151
|
},
|
|
142
152
|
"and" => {
|
|
143
153
|
name: "and",
|
|
144
|
-
description:
|
|
145
|
-
|
|
154
|
+
description:
|
|
155
|
+
"returns the other value when the receiver is truthy, otherwise the receiver.",
|
|
156
|
+
examples: %w[true.and(1) false.and(1) 1.and(2)]
|
|
146
157
|
},
|
|
147
158
|
"+" => {
|
|
148
159
|
name: "+",
|
|
149
|
-
description:
|
|
160
|
+
description:
|
|
161
|
+
"returns the receiver for object types that do not override plus.",
|
|
150
162
|
examples: ["+Object.new", "+nothing", "+[]"]
|
|
151
163
|
},
|
|
152
164
|
"self" => {
|
|
@@ -156,30 +168,34 @@ class Code
|
|
|
156
168
|
},
|
|
157
169
|
".." => {
|
|
158
170
|
name: "..",
|
|
159
|
-
description:
|
|
160
|
-
|
|
171
|
+
description:
|
|
172
|
+
"builds an inclusive range from the receiver to another value.",
|
|
173
|
+
examples: %w[1..3 :a..:c Date.today..Date.tomorrow]
|
|
161
174
|
},
|
|
162
175
|
"inclusive_range" => {
|
|
163
176
|
name: "inclusive_range",
|
|
164
|
-
description:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
description:
|
|
178
|
+
"builds an inclusive range from the receiver to another value.",
|
|
179
|
+
examples: %w[
|
|
180
|
+
1.inclusive_range(3)
|
|
181
|
+
:a.inclusive_range(:c)
|
|
182
|
+
Date.today.inclusive_range(Date.tomorrow)
|
|
169
183
|
]
|
|
170
184
|
},
|
|
171
185
|
"..." => {
|
|
172
186
|
name: "...",
|
|
173
|
-
description:
|
|
174
|
-
|
|
187
|
+
description:
|
|
188
|
+
"builds an exclusive range from the receiver to another value.",
|
|
189
|
+
examples: %w[1...3 :a...:c Date.today...Date.tomorrow]
|
|
175
190
|
},
|
|
176
191
|
"exclusive_range" => {
|
|
177
192
|
name: "exclusive_range",
|
|
178
|
-
description:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
193
|
+
description:
|
|
194
|
+
"builds an exclusive range from the receiver to another value.",
|
|
195
|
+
examples: %w[
|
|
196
|
+
1.exclusive_range(3)
|
|
197
|
+
:a.exclusive_range(:c)
|
|
198
|
+
Date.today.exclusive_range(Date.tomorrow)
|
|
183
199
|
]
|
|
184
200
|
},
|
|
185
201
|
"==" => {
|
|
@@ -199,7 +215,8 @@ class Code
|
|
|
199
215
|
},
|
|
200
216
|
"same_object?" => {
|
|
201
217
|
name: "same_object?",
|
|
202
|
-
description:
|
|
218
|
+
description:
|
|
219
|
+
"returns whether the value and argument are the same object.",
|
|
203
220
|
examples: [
|
|
204
221
|
"a = [] b = a a.same_object?(b)",
|
|
205
222
|
"[].same_object?([])",
|
|
@@ -214,38 +231,42 @@ class Code
|
|
|
214
231
|
"greater" => {
|
|
215
232
|
name: "greater",
|
|
216
233
|
description: "returns whether the value is greater than another value.",
|
|
217
|
-
examples: [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
234
|
+
examples: %w[
|
|
235
|
+
2.greater(1)
|
|
236
|
+
:b.greater(:a)
|
|
237
|
+
Date.tomorrow.greater(Date.today)
|
|
221
238
|
]
|
|
222
239
|
},
|
|
223
240
|
">=" => {
|
|
224
241
|
name: ">=",
|
|
225
|
-
description:
|
|
242
|
+
description:
|
|
243
|
+
"returns whether the value is greater than or equal to another value.",
|
|
226
244
|
examples: ["2 >= 2", ":b >= :a", "Date.today >= Date.today"]
|
|
227
245
|
},
|
|
228
246
|
"greater_or_equal" => {
|
|
229
247
|
name: "greater_or_equal",
|
|
230
|
-
description:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
248
|
+
description:
|
|
249
|
+
"returns whether the value is greater than or equal to another value.",
|
|
250
|
+
examples: %w[
|
|
251
|
+
2.greater_or_equal(2)
|
|
252
|
+
:b.greater_or_equal(:a)
|
|
253
|
+
Date.today.greater_or_equal(Date.today)
|
|
235
254
|
]
|
|
236
255
|
},
|
|
237
256
|
"<=>" => {
|
|
238
257
|
name: "<=>",
|
|
239
|
-
description:
|
|
258
|
+
description:
|
|
259
|
+
"compares the value with another value and returns -1, 0, or 1.",
|
|
240
260
|
examples: ["1 <=> 2", ":a <=> :b", "Date.today <=> Date.tomorrow"]
|
|
241
261
|
},
|
|
242
262
|
"compare" => {
|
|
243
263
|
name: "compare",
|
|
244
|
-
description:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
264
|
+
description:
|
|
265
|
+
"compares the value with another value and returns -1, 0, or 1.",
|
|
266
|
+
examples: %w[
|
|
267
|
+
1.compare(2)
|
|
268
|
+
:a.compare(:b)
|
|
269
|
+
Date.today.compare(Date.tomorrow)
|
|
249
270
|
]
|
|
250
271
|
},
|
|
251
272
|
"<" => {
|
|
@@ -256,20 +277,22 @@ class Code
|
|
|
256
277
|
"less" => {
|
|
257
278
|
name: "less",
|
|
258
279
|
description: "returns whether the value is less than another value.",
|
|
259
|
-
examples: [
|
|
280
|
+
examples: %w[1.less(2) :a.less(:b) Date.today.less(Date.tomorrow)]
|
|
260
281
|
},
|
|
261
282
|
"<=" => {
|
|
262
283
|
name: "<=",
|
|
263
|
-
description:
|
|
284
|
+
description:
|
|
285
|
+
"returns whether the value is less than or equal to another value.",
|
|
264
286
|
examples: ["1 <= 1", ":a <= :b", "Date.today <= Date.today"]
|
|
265
287
|
},
|
|
266
288
|
"less_or_equal" => {
|
|
267
289
|
name: "less_or_equal",
|
|
268
|
-
description:
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
description:
|
|
291
|
+
"returns whether the value is less than or equal to another value.",
|
|
292
|
+
examples: %w[
|
|
293
|
+
1.less_or_equal(1)
|
|
294
|
+
:a.less_or_equal(:b)
|
|
295
|
+
Date.today.less_or_equal(Date.today)
|
|
273
296
|
]
|
|
274
297
|
},
|
|
275
298
|
"===" => {
|
|
@@ -280,16 +303,22 @@ class Code
|
|
|
280
303
|
"strict_equal" => {
|
|
281
304
|
name: "strict_equal",
|
|
282
305
|
description: "returns whether the value strictly equals another value.",
|
|
283
|
-
examples: [
|
|
306
|
+
examples: [
|
|
307
|
+
"1.strict_equal(1)",
|
|
308
|
+
":a.strict_equal(:a)",
|
|
309
|
+
"[1].strict_equal([1])"
|
|
310
|
+
]
|
|
284
311
|
},
|
|
285
312
|
"!==" => {
|
|
286
313
|
name: "!==",
|
|
287
|
-
description:
|
|
314
|
+
description:
|
|
315
|
+
"returns whether the value does not strictly equal another value.",
|
|
288
316
|
examples: ["1 !== 2", ":a !== :b", "[1] !== [2]"]
|
|
289
317
|
},
|
|
290
318
|
"strict_different" => {
|
|
291
319
|
name: "strict_different",
|
|
292
|
-
description:
|
|
320
|
+
description:
|
|
321
|
+
"returns whether the value does not strictly equal another value.",
|
|
293
322
|
examples: [
|
|
294
323
|
"1.strict_different(2)",
|
|
295
324
|
":a.strict_different(:b)",
|
|
@@ -299,32 +328,34 @@ class Code
|
|
|
299
328
|
"falsy?" => {
|
|
300
329
|
name: "falsy?",
|
|
301
330
|
description: "returns whether the value is falsy.",
|
|
302
|
-
examples: [
|
|
331
|
+
examples: %w[nothing.falsy? false.falsy? 1.falsy?]
|
|
303
332
|
},
|
|
304
333
|
"truthy?" => {
|
|
305
334
|
name: "truthy?",
|
|
306
335
|
description: "returns whether the value is truthy.",
|
|
307
|
-
examples: [
|
|
336
|
+
examples: %w[1.truthy? true.truthy? nothing.truthy?]
|
|
308
337
|
},
|
|
309
338
|
"true?" => {
|
|
310
339
|
name: "true?",
|
|
311
340
|
description: "returns whether the value is true.",
|
|
312
|
-
examples: [
|
|
341
|
+
examples: %w[true.true? false.true? 1.true?]
|
|
313
342
|
},
|
|
314
343
|
"false?" => {
|
|
315
344
|
name: "false?",
|
|
316
345
|
description: "returns whether the value is false or nothing.",
|
|
317
|
-
examples: [
|
|
346
|
+
examples: %w[false.false? nothing.false? true.false?]
|
|
318
347
|
},
|
|
319
348
|
"||" => {
|
|
320
349
|
name: "||",
|
|
321
|
-
description:
|
|
350
|
+
description:
|
|
351
|
+
"returns the receiver when truthy, otherwise the other value.",
|
|
322
352
|
examples: ["nothing || 1", "false || 1", "2 || 1"]
|
|
323
353
|
},
|
|
324
354
|
"or" => {
|
|
325
355
|
name: "or",
|
|
326
|
-
description:
|
|
327
|
-
|
|
356
|
+
description:
|
|
357
|
+
"returns the receiver when truthy, otherwise the other value.",
|
|
358
|
+
examples: %w[nothing.or(1) false.or(1) 2.or(1)]
|
|
328
359
|
},
|
|
329
360
|
"to_boolean" => {
|
|
330
361
|
name: "to_boolean",
|
|
@@ -353,12 +384,16 @@ class Code
|
|
|
353
384
|
"to_dictionary" => {
|
|
354
385
|
name: "to_dictionary",
|
|
355
386
|
description: "converts the value to a dictionary.",
|
|
356
|
-
examples: [
|
|
387
|
+
examples: [
|
|
388
|
+
"[].to_dictionary",
|
|
389
|
+
"{}.to_dictionary",
|
|
390
|
+
"[[:a, 1]].to_dictionary"
|
|
391
|
+
]
|
|
357
392
|
},
|
|
358
393
|
"to_duration" => {
|
|
359
394
|
name: "to_duration",
|
|
360
395
|
description: "converts the value to a duration.",
|
|
361
|
-
examples: [
|
|
396
|
+
examples: %w[1.to_duration 1.day.to_duration 2.hours.to_duration]
|
|
362
397
|
},
|
|
363
398
|
"to_integer" => {
|
|
364
399
|
name: "to_integer",
|
|
@@ -383,11 +418,12 @@ class Code
|
|
|
383
418
|
"to_string" => {
|
|
384
419
|
name: "to_string",
|
|
385
420
|
description: "converts the value to a string.",
|
|
386
|
-
examples: [
|
|
421
|
+
examples: %w[1.to_string true.to_string :a.to_string]
|
|
387
422
|
},
|
|
388
423
|
"inspect" => {
|
|
389
424
|
name: "inspect",
|
|
390
|
-
description:
|
|
425
|
+
description:
|
|
426
|
+
"returns a string representation of the value for inspection.",
|
|
391
427
|
examples: ["1.inspect", ":a.inspect", "[1].inspect"]
|
|
392
428
|
},
|
|
393
429
|
"to_time" => {
|
|
@@ -448,7 +484,8 @@ class Code
|
|
|
448
484
|
},
|
|
449
485
|
"tap" => {
|
|
450
486
|
name: "tap",
|
|
451
|
-
description:
|
|
487
|
+
description:
|
|
488
|
+
"calls a function with the receiver and returns the receiver.",
|
|
452
489
|
examples: [
|
|
453
490
|
"1.tap((value) => { value })",
|
|
454
491
|
":a.tap((value) => { value.upcase })",
|
|
@@ -457,7 +494,8 @@ class Code
|
|
|
457
494
|
},
|
|
458
495
|
"then" => {
|
|
459
496
|
name: "then",
|
|
460
|
-
description:
|
|
497
|
+
description:
|
|
498
|
+
"calls a function with the receiver and returns the function result.",
|
|
461
499
|
examples: [
|
|
462
500
|
"1.then((value) => { value + 1 })",
|
|
463
501
|
":a.then((value) => { value.upcase })",
|
|
@@ -472,12 +510,12 @@ class Code
|
|
|
472
510
|
"nothing?" => {
|
|
473
511
|
name: "nothing?",
|
|
474
512
|
description: "returns whether the value is nothing.",
|
|
475
|
-
examples: [
|
|
513
|
+
examples: %w[nothing.nothing? 1.nothing? :a.nothing?]
|
|
476
514
|
},
|
|
477
515
|
"something?" => {
|
|
478
516
|
name: "something?",
|
|
479
517
|
description: "returns whether the value is not nothing.",
|
|
480
|
-
examples: [
|
|
518
|
+
examples: %w[1.something? :a.something? nothing.something?]
|
|
481
519
|
}
|
|
482
520
|
}.freeze
|
|
483
521
|
CLASS_FUNCTIONS = {
|
|
@@ -545,7 +583,9 @@ class Code
|
|
|
545
583
|
end
|
|
546
584
|
|
|
547
585
|
def self.documented_functions_for(klass, scope)
|
|
548
|
-
sorted_dictionary(
|
|
586
|
+
sorted_dictionary(
|
|
587
|
+
function_documentation_for(klass, scope).transform_keys(&:to_s)
|
|
588
|
+
)
|
|
549
589
|
end
|
|
550
590
|
|
|
551
591
|
def self.documentation_for(klass)
|
|
@@ -558,8 +598,7 @@ class Code
|
|
|
558
598
|
|
|
559
599
|
def self.function_documentation_for(klass, scope)
|
|
560
600
|
documentation = function_documentation_registry_for(klass, scope)
|
|
561
|
-
inherited_function_documentation_for(klass, scope)
|
|
562
|
-
.merge(documentation)
|
|
601
|
+
inherited_function_documentation_for(klass, scope).merge(documentation)
|
|
563
602
|
end
|
|
564
603
|
|
|
565
604
|
def self.inherited_function_documentation_for(klass, scope)
|
data/lib/code/parser.rb
CHANGED
|
@@ -32,37 +32,37 @@ class Code
|
|
|
32
32
|
while
|
|
33
33
|
].freeze
|
|
34
34
|
|
|
35
|
-
MULTI_CHAR_OPERATORS = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
35
|
+
MULTI_CHAR_OPERATORS = %w[
|
|
36
|
+
&.
|
|
37
|
+
&&
|
|
38
|
+
&&=
|
|
39
|
+
**
|
|
40
|
+
*=
|
|
41
|
+
+=
|
|
42
|
+
-=
|
|
43
|
+
..
|
|
44
|
+
...
|
|
45
|
+
/=
|
|
46
|
+
::
|
|
47
|
+
<<=
|
|
48
|
+
<<
|
|
49
|
+
<=>
|
|
50
|
+
<=
|
|
51
|
+
===
|
|
52
|
+
==
|
|
53
|
+
=~
|
|
54
|
+
>=
|
|
55
|
+
>>=
|
|
56
|
+
>>
|
|
57
|
+
||=
|
|
58
|
+
||
|
|
59
|
+
|=
|
|
60
|
+
!==
|
|
61
|
+
!=
|
|
62
|
+
!~
|
|
63
|
+
%=
|
|
64
|
+
^=
|
|
65
|
+
=>
|
|
66
66
|
].sort_by(&:length).reverse.freeze
|
|
67
67
|
CONTINUATION_KEYWORDS = %w[or and rescue].freeze
|
|
68
68
|
POSTFIX_CONTINUATIONS = %w[. :: &.].freeze
|
|
@@ -1015,7 +1015,9 @@ class Code
|
|
|
1015
1015
|
next
|
|
1016
1016
|
elsif "([{".include?(char)
|
|
1017
1017
|
depth += 1
|
|
1018
|
-
|
|
1018
|
+
if depth > MAX_NESTING
|
|
1019
|
+
raise_parse_error_at("source is too deeply nested", index)
|
|
1020
|
+
end
|
|
1019
1021
|
elsif ")]}".include?(char)
|
|
1020
1022
|
depth -= 1 if depth.positive?
|
|
1021
1023
|
end
|