bindy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d66f073aa559946178b2bd63c84424dbaa717e8
4
- data.tar.gz: 2a6b9b901e1d0f043ee9f79db2b5ec51e9dfdcdb
3
+ metadata.gz: 93a8d234b78c67c34b225d41485360843621cbfa
4
+ data.tar.gz: 2d7085724da8c7c56b11ce6fde2db90f66ee1404
5
5
  SHA512:
6
- metadata.gz: 7acbd71c59c5b8909a7f960799a5756ea1f112e8e9285f22ae4412ad6ea113cf9bc5d1f6b5d1ec2fba6c260e3045dcdbfebeffd2ad5b4ed5e265a25ed9031e2b
7
- data.tar.gz: 9171518e14d9d47565d35725cc85fa616596f8ae93cc2daef9f246b34be16297ad30332dad6e368dcee10e888a7a0166e0cbd2790e7031c75010eff56c6322a0
6
+ metadata.gz: 41d424c54474052f5b46bc95edb1569b1eec62e312c27517f72b7361af6397d7cbbd27c4d95032cc9375e57c6c1679edf94e5d55f74c7b009f36ae2e4746429c
7
+ data.tar.gz: a4edb27d4a48052ab523cfbb567481cc6380cda06b103a6cf541f32ccb62a19cdd0f89f2649c9b864d12ad1c75bfe7a4ae66ba64a422c315d8a75e43d7ed13a2
@@ -8,37 +8,17 @@ module Bindy
8
8
  @variables = variables
9
9
  end
10
10
 
11
- def bind(object)
12
- case object
13
- when Hash then bind_hash object
14
- when Array then bind_array object
15
- when String then bind_string object
16
- else raise "Unbindable #{object}"
17
- end
11
+ def evaluate(expression)
12
+ raise ArgumentError, "Expression must be a string (#{expression})" unless expression.kind_of?(String)
13
+ Language.parse(expression).evaluate(self)
18
14
  end
19
15
 
20
16
  def var(name)
21
17
  name.split('.').inject(variables) do |vars, key|
22
- vars.fetch(key, vars.fetch(key.to_sym))
18
+ vars.fetch(key) { vars.fetch(key.to_sym) }
23
19
  end
24
20
  rescue KeyError
25
- raise "Undefined variable #{name}"
26
- end
27
-
28
- private
29
-
30
- def bind_hash(hash)
31
- hash.each_with_object({}) do |(k,v),h|
32
- h[k] = bind v
33
- end
34
- end
35
-
36
- def bind_array(array)
37
- array.map { |v| bind v }
38
- end
39
-
40
- def bind_string(string)
41
- Language.parse(string).evaluate(self)
21
+ raise ArgumentError, "Undefined variable #{name}"
42
22
  end
43
23
 
44
24
  end
@@ -0,0 +1,702 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Bindy
5
+ module Language
6
+ include Treetop::Runtime
7
+
8
+ def root
9
+ @root ||= :expression
10
+ end
11
+
12
+ def _nt_expression
13
+ start_index = index
14
+ if node_cache[:expression].has_key?(index)
15
+ cached = node_cache[:expression][index]
16
+ if cached
17
+ node_cache[:expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
18
+ @index = cached.interval.end
19
+ end
20
+ return cached
21
+ end
22
+
23
+ i0 = index
24
+ r1 = _nt_function
25
+ if r1
26
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
27
+ r0 = r1
28
+ else
29
+ r2 = _nt_value
30
+ if r2
31
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
32
+ r0 = r2
33
+ else
34
+ @index = i0
35
+ r0 = nil
36
+ end
37
+ end
38
+
39
+ node_cache[:expression][start_index] = r0
40
+
41
+ r0
42
+ end
43
+
44
+ module Function0
45
+ def identifier
46
+ elements[0]
47
+ end
48
+
49
+ def arg_list
50
+ elements[4]
51
+ end
52
+
53
+ end
54
+
55
+ def _nt_function
56
+ start_index = index
57
+ if node_cache[:function].has_key?(index)
58
+ cached = node_cache[:function][index]
59
+ if cached
60
+ node_cache[:function][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
61
+ @index = cached.interval.end
62
+ end
63
+ return cached
64
+ end
65
+
66
+ i0, s0 = index, []
67
+ r1 = _nt_identifier
68
+ s0 << r1
69
+ if r1
70
+ s2, i2 = [], index
71
+ loop do
72
+ r3 = _nt_space
73
+ if r3
74
+ s2 << r3
75
+ else
76
+ break
77
+ end
78
+ end
79
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
80
+ s0 << r2
81
+ if r2
82
+ if (match_len = has_terminal?('(', false, index))
83
+ r4 = true
84
+ @index += match_len
85
+ else
86
+ terminal_parse_failure('\'(\'')
87
+ r4 = nil
88
+ end
89
+ s0 << r4
90
+ if r4
91
+ s5, i5 = [], index
92
+ loop do
93
+ r6 = _nt_space
94
+ if r6
95
+ s5 << r6
96
+ else
97
+ break
98
+ end
99
+ end
100
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
101
+ s0 << r5
102
+ if r5
103
+ r7 = _nt_arg_list
104
+ s0 << r7
105
+ if r7
106
+ s8, i8 = [], index
107
+ loop do
108
+ r9 = _nt_space
109
+ if r9
110
+ s8 << r9
111
+ else
112
+ break
113
+ end
114
+ end
115
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
116
+ s0 << r8
117
+ if r8
118
+ if (match_len = has_terminal?(')', false, index))
119
+ r10 = true
120
+ @index += match_len
121
+ else
122
+ terminal_parse_failure('\')\'')
123
+ r10 = nil
124
+ end
125
+ s0 << r10
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ if s0.last
133
+ r0 = instantiate_node(Function,input, i0...index, s0)
134
+ r0.extend(Function0)
135
+ else
136
+ @index = i0
137
+ r0 = nil
138
+ end
139
+
140
+ node_cache[:function][start_index] = r0
141
+
142
+ r0
143
+ end
144
+
145
+ module ArgList0
146
+ def expression
147
+ elements[0]
148
+ end
149
+
150
+ def arg_list
151
+ elements[4]
152
+ end
153
+ end
154
+
155
+ def _nt_arg_list
156
+ start_index = index
157
+ if node_cache[:arg_list].has_key?(index)
158
+ cached = node_cache[:arg_list][index]
159
+ if cached
160
+ node_cache[:arg_list][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
161
+ @index = cached.interval.end
162
+ end
163
+ return cached
164
+ end
165
+
166
+ i0 = index
167
+ i1, s1 = index, []
168
+ r2 = _nt_expression
169
+ s1 << r2
170
+ if r2
171
+ s3, i3 = [], index
172
+ loop do
173
+ r4 = _nt_space
174
+ if r4
175
+ s3 << r4
176
+ else
177
+ break
178
+ end
179
+ end
180
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
181
+ s1 << r3
182
+ if r3
183
+ if (match_len = has_terminal?(',', false, index))
184
+ r5 = true
185
+ @index += match_len
186
+ else
187
+ terminal_parse_failure('\',\'')
188
+ r5 = nil
189
+ end
190
+ s1 << r5
191
+ if r5
192
+ s6, i6 = [], index
193
+ loop do
194
+ r7 = _nt_space
195
+ if r7
196
+ s6 << r7
197
+ else
198
+ break
199
+ end
200
+ end
201
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
202
+ s1 << r6
203
+ if r6
204
+ r8 = _nt_arg_list
205
+ s1 << r8
206
+ end
207
+ end
208
+ end
209
+ end
210
+ if s1.last
211
+ r1 = instantiate_node(ArgList,input, i1...index, s1)
212
+ r1.extend(ArgList0)
213
+ else
214
+ @index = i1
215
+ r1 = nil
216
+ end
217
+ if r1
218
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
219
+ r0 = r1
220
+ else
221
+ r9 = _nt_expression
222
+ if r9
223
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
224
+ r0 = r9
225
+ else
226
+ s10, i10 = [], index
227
+ loop do
228
+ r11 = _nt_space
229
+ if r11
230
+ s10 << r11
231
+ else
232
+ break
233
+ end
234
+ end
235
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
236
+ if r10
237
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
238
+ r0 = r10
239
+ else
240
+ @index = i0
241
+ r0 = nil
242
+ end
243
+ end
244
+ end
245
+
246
+ node_cache[:arg_list][start_index] = r0
247
+
248
+ r0
249
+ end
250
+
251
+ def _nt_identifier
252
+ start_index = index
253
+ if node_cache[:identifier].has_key?(index)
254
+ cached = node_cache[:identifier][index]
255
+ if cached
256
+ node_cache[:identifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
257
+ @index = cached.interval.end
258
+ end
259
+ return cached
260
+ end
261
+
262
+ s0, i0 = [], index
263
+ loop do
264
+ if has_terminal?(@regexps[gr = '\A[a-z\\_]'] ||= Regexp.new(gr), :regexp, index)
265
+ r1 = true
266
+ @index += 1
267
+ else
268
+ terminal_parse_failure('[a-z\\_]')
269
+ r1 = nil
270
+ end
271
+ if r1
272
+ s0 << r1
273
+ else
274
+ break
275
+ end
276
+ end
277
+ if s0.empty?
278
+ @index = i0
279
+ r0 = nil
280
+ else
281
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
282
+ end
283
+
284
+ node_cache[:identifier][start_index] = r0
285
+
286
+ r0
287
+ end
288
+
289
+ def _nt_value
290
+ start_index = index
291
+ if node_cache[:value].has_key?(index)
292
+ cached = node_cache[:value][index]
293
+ if cached
294
+ node_cache[:value][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
295
+ @index = cached.interval.end
296
+ end
297
+ return cached
298
+ end
299
+
300
+ i0 = index
301
+ r1 = _nt_number
302
+ if r1
303
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
304
+ r0 = r1
305
+ else
306
+ r2 = _nt_boolean
307
+ if r2
308
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
309
+ r0 = r2
310
+ else
311
+ r3 = _nt_string
312
+ if r3
313
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
314
+ r0 = r3
315
+ else
316
+ @index = i0
317
+ r0 = nil
318
+ end
319
+ end
320
+ end
321
+
322
+ node_cache[:value][start_index] = r0
323
+
324
+ r0
325
+ end
326
+
327
+ module String0
328
+ def value
329
+ elements[1]
330
+ end
331
+
332
+ end
333
+
334
+ def _nt_string
335
+ start_index = index
336
+ if node_cache[:string].has_key?(index)
337
+ cached = node_cache[:string][index]
338
+ if cached
339
+ node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
340
+ @index = cached.interval.end
341
+ end
342
+ return cached
343
+ end
344
+
345
+ i0, s0 = index, []
346
+ if (match_len = has_terminal?("'", false, index))
347
+ r1 = true
348
+ @index += match_len
349
+ else
350
+ terminal_parse_failure('"\'"')
351
+ r1 = nil
352
+ end
353
+ s0 << r1
354
+ if r1
355
+ s2, i2 = [], index
356
+ loop do
357
+ if has_terminal?(@regexps[gr = '\A[\\da-zA-ZáéíóúüñÁÉÍÓÚÜÑ¿?!¡\\s\\@\\#\\$\\%\\&\\/\\\\\\*\\_\\-\\+\\/\\\\\\*\\_\\-\\+\\.\\:\\,\\;\\<\\>\\|\\"\\\\(\\)]'] ||= Regexp.new(gr), :regexp, index)
358
+ r3 = true
359
+ @index += 1
360
+ else
361
+ terminal_parse_failure('[\\da-zA-ZáéíóúüñÁÉÍÓÚÜÑ¿?!¡\\s\\@\\#\\$\\%\\&\\/\\\\\\*\\_\\-\\+\\/\\\\\\*\\_\\-\\+\\.\\:\\,\\;\\<\\>\\|\\"\\\\(\\)]')
362
+ r3 = nil
363
+ end
364
+ if r3
365
+ s2 << r3
366
+ else
367
+ break
368
+ end
369
+ end
370
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
371
+ s0 << r2
372
+ if r2
373
+ if (match_len = has_terminal?("'", false, index))
374
+ r4 = true
375
+ @index += match_len
376
+ else
377
+ terminal_parse_failure('"\'"')
378
+ r4 = nil
379
+ end
380
+ s0 << r4
381
+ end
382
+ end
383
+ if s0.last
384
+ r0 = instantiate_node(LiteralString,input, i0...index, s0)
385
+ r0.extend(String0)
386
+ else
387
+ @index = i0
388
+ r0 = nil
389
+ end
390
+
391
+ node_cache[:string][start_index] = r0
392
+
393
+ r0
394
+ end
395
+
396
+ def _nt_number
397
+ start_index = index
398
+ if node_cache[:number].has_key?(index)
399
+ cached = node_cache[:number][index]
400
+ if cached
401
+ node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
402
+ @index = cached.interval.end
403
+ end
404
+ return cached
405
+ end
406
+
407
+ i0 = index
408
+ r1 = _nt_float
409
+ if r1
410
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
411
+ r0 = r1
412
+ else
413
+ r2 = _nt_integer
414
+ if r2
415
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
416
+ r0 = r2
417
+ else
418
+ @index = i0
419
+ r0 = nil
420
+ end
421
+ end
422
+
423
+ node_cache[:number][start_index] = r0
424
+
425
+ r0
426
+ end
427
+
428
+ module Integer0
429
+ end
430
+
431
+ def _nt_integer
432
+ start_index = index
433
+ if node_cache[:integer].has_key?(index)
434
+ cached = node_cache[:integer][index]
435
+ if cached
436
+ node_cache[:integer][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
437
+ @index = cached.interval.end
438
+ end
439
+ return cached
440
+ end
441
+
442
+ i0, s0 = index, []
443
+ if has_terminal?(@regexps[gr = '\A[\\+\\-]'] ||= Regexp.new(gr), :regexp, index)
444
+ r2 = true
445
+ @index += 1
446
+ else
447
+ terminal_parse_failure('[\\+\\-]')
448
+ r2 = nil
449
+ end
450
+ if r2
451
+ r1 = r2
452
+ else
453
+ r1 = instantiate_node(SyntaxNode,input, index...index)
454
+ end
455
+ s0 << r1
456
+ if r1
457
+ s3, i3 = [], index
458
+ loop do
459
+ if has_terminal?(@regexps[gr = '\A[\\d]'] ||= Regexp.new(gr), :regexp, index)
460
+ r4 = true
461
+ @index += 1
462
+ else
463
+ terminal_parse_failure('[\\d]')
464
+ r4 = nil
465
+ end
466
+ if r4
467
+ s3 << r4
468
+ else
469
+ break
470
+ end
471
+ end
472
+ if s3.empty?
473
+ @index = i3
474
+ r3 = nil
475
+ else
476
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
477
+ end
478
+ s0 << r3
479
+ end
480
+ if s0.last
481
+ r0 = instantiate_node(LiteralInteger,input, i0...index, s0)
482
+ r0.extend(Integer0)
483
+ else
484
+ @index = i0
485
+ r0 = nil
486
+ end
487
+
488
+ node_cache[:integer][start_index] = r0
489
+
490
+ r0
491
+ end
492
+
493
+ module Float0
494
+ end
495
+
496
+ def _nt_float
497
+ start_index = index
498
+ if node_cache[:float].has_key?(index)
499
+ cached = node_cache[:float][index]
500
+ if cached
501
+ node_cache[:float][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
502
+ @index = cached.interval.end
503
+ end
504
+ return cached
505
+ end
506
+
507
+ i0, s0 = index, []
508
+ if has_terminal?(@regexps[gr = '\A[\\+\\-]'] ||= Regexp.new(gr), :regexp, index)
509
+ r2 = true
510
+ @index += 1
511
+ else
512
+ terminal_parse_failure('[\\+\\-]')
513
+ r2 = nil
514
+ end
515
+ if r2
516
+ r1 = r2
517
+ else
518
+ r1 = instantiate_node(SyntaxNode,input, index...index)
519
+ end
520
+ s0 << r1
521
+ if r1
522
+ s3, i3 = [], index
523
+ loop do
524
+ if has_terminal?(@regexps[gr = '\A[\\d]'] ||= Regexp.new(gr), :regexp, index)
525
+ r4 = true
526
+ @index += 1
527
+ else
528
+ terminal_parse_failure('[\\d]')
529
+ r4 = nil
530
+ end
531
+ if r4
532
+ s3 << r4
533
+ else
534
+ break
535
+ end
536
+ end
537
+ if s3.empty?
538
+ @index = i3
539
+ r3 = nil
540
+ else
541
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
542
+ end
543
+ s0 << r3
544
+ if r3
545
+ if (match_len = has_terminal?('.', false, index))
546
+ r5 = true
547
+ @index += match_len
548
+ else
549
+ terminal_parse_failure('\'.\'')
550
+ r5 = nil
551
+ end
552
+ s0 << r5
553
+ if r5
554
+ s6, i6 = [], index
555
+ loop do
556
+ if has_terminal?(@regexps[gr = '\A[\\d]'] ||= Regexp.new(gr), :regexp, index)
557
+ r7 = true
558
+ @index += 1
559
+ else
560
+ terminal_parse_failure('[\\d]')
561
+ r7 = nil
562
+ end
563
+ if r7
564
+ s6 << r7
565
+ else
566
+ break
567
+ end
568
+ end
569
+ if s6.empty?
570
+ @index = i6
571
+ r6 = nil
572
+ else
573
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
574
+ end
575
+ s0 << r6
576
+ end
577
+ end
578
+ end
579
+ if s0.last
580
+ r0 = instantiate_node(LiteralFloat,input, i0...index, s0)
581
+ r0.extend(Float0)
582
+ else
583
+ @index = i0
584
+ r0 = nil
585
+ end
586
+
587
+ node_cache[:float][start_index] = r0
588
+
589
+ r0
590
+ end
591
+
592
+ def _nt_boolean
593
+ start_index = index
594
+ if node_cache[:boolean].has_key?(index)
595
+ cached = node_cache[:boolean][index]
596
+ if cached
597
+ node_cache[:boolean][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
598
+ @index = cached.interval.end
599
+ end
600
+ return cached
601
+ end
602
+
603
+ i0 = index
604
+ r1 = _nt_true
605
+ if r1
606
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
607
+ r0 = r1
608
+ else
609
+ r2 = _nt_false
610
+ if r2
611
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
612
+ r0 = r2
613
+ else
614
+ @index = i0
615
+ r0 = nil
616
+ end
617
+ end
618
+
619
+ node_cache[:boolean][start_index] = r0
620
+
621
+ r0
622
+ end
623
+
624
+ def _nt_true
625
+ start_index = index
626
+ if node_cache[:true].has_key?(index)
627
+ cached = node_cache[:true][index]
628
+ if cached
629
+ node_cache[:true][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
630
+ @index = cached.interval.end
631
+ end
632
+ return cached
633
+ end
634
+
635
+ if (match_len = has_terminal?('true', false, index))
636
+ r0 = instantiate_node(LiteralTrue,input, index...(index + match_len))
637
+ @index += match_len
638
+ else
639
+ terminal_parse_failure('\'true\'')
640
+ r0 = nil
641
+ end
642
+
643
+ node_cache[:true][start_index] = r0
644
+
645
+ r0
646
+ end
647
+
648
+ def _nt_false
649
+ start_index = index
650
+ if node_cache[:false].has_key?(index)
651
+ cached = node_cache[:false][index]
652
+ if cached
653
+ node_cache[:false][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
654
+ @index = cached.interval.end
655
+ end
656
+ return cached
657
+ end
658
+
659
+ if (match_len = has_terminal?('false', false, index))
660
+ r0 = instantiate_node(LiteralFalse,input, index...(index + match_len))
661
+ @index += match_len
662
+ else
663
+ terminal_parse_failure('\'false\'')
664
+ r0 = nil
665
+ end
666
+
667
+ node_cache[:false][start_index] = r0
668
+
669
+ r0
670
+ end
671
+
672
+ def _nt_space
673
+ start_index = index
674
+ if node_cache[:space].has_key?(index)
675
+ cached = node_cache[:space][index]
676
+ if cached
677
+ node_cache[:space][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
678
+ @index = cached.interval.end
679
+ end
680
+ return cached
681
+ end
682
+
683
+ if has_terminal?(@regexps[gr = '\A[\\s\\t\\n]'] ||= Regexp.new(gr), :regexp, index)
684
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
685
+ @index += 1
686
+ else
687
+ terminal_parse_failure('[\\s\\t\\n]')
688
+ r0 = nil
689
+ end
690
+
691
+ node_cache[:space][start_index] = r0
692
+
693
+ r0
694
+ end
695
+
696
+ end
697
+
698
+ class LanguageParser < Treetop::Runtime::CompiledParser
699
+ include Language
700
+ end
701
+
702
+ end
@@ -11,7 +11,8 @@ module Bindy
11
11
 
12
12
  rule arg_list
13
13
  expression space* ',' space* arg_list <ArgList> /
14
- expression
14
+ expression /
15
+ space*
15
16
  end
16
17
 
17
18
  rule identifier
@@ -23,7 +24,7 @@ module Bindy
23
24
  end
24
25
 
25
26
  rule string
26
- [\da-zA-ZáéíóúüñÁÉÍÓÚÜÑ¿?!¡\s\@\#\$\%\&\/\\\*\_\-\+\/\\\*\_\-\+\.\,\:\;\<\>\|\"\']+ <LiteralString>
27
+ "'" value:[\da-zA-ZáéíóúüñÁÉÍÓÚÜÑ¿?!¡\s\@\#\$\%\&\/\\\*\_\-\+\/\\\*\_\-\+\.\:\,\;\<\>\|\"\\(\)]* "'" <LiteralString>
27
28
  end
28
29
 
29
30
  rule number
@@ -27,7 +27,13 @@ module Bindy
27
27
  end
28
28
 
29
29
  def arguments
30
- arg_list.respond_to?(:to_a) ? arg_list.to_a : [arg_list]
30
+ if arg_list.text_value.empty?
31
+ []
32
+ elsif arg_list.respond_to?(:to_a)
33
+ arg_list.to_a
34
+ else
35
+ [arg_list]
36
+ end
31
37
  end
32
38
  end
33
39
 
@@ -39,7 +45,7 @@ module Bindy
39
45
 
40
46
  class LiteralString < Treetop::Runtime::SyntaxNode
41
47
  def evaluate(context)
42
- text_value
48
+ value.text_value
43
49
  end
44
50
  end
45
51
 
@@ -1,3 +1,3 @@
1
1
  module Bindy
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -128,6 +128,7 @@ files:
128
128
  - bindy.gemspec
129
129
  - lib/bindy.rb
130
130
  - lib/bindy/context.rb
131
+ - lib/bindy/language.rb
131
132
  - lib/bindy/language.treetop
132
133
  - lib/bindy/language_interpreters.rb
133
134
  - lib/bindy/version.rb
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  version: '0'
152
153
  requirements: []
153
154
  rubyforge_project:
154
- rubygems_version: 2.4.3
155
+ rubygems_version: 2.4.7
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: Context binding for functions evaluation