jievro-ast 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jievro/ast/node.rb +22 -5
- data/lib/jievro/ast/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33a181a0534dd9330f5d1c5b89ac33661b9342c3
|
4
|
+
data.tar.gz: ecd41b90443142d815da9d22bd4d710345d1489d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7919d97abb207eaf55de1462937a435b497ec1905a1833a9b1c5626f6e09a0c121aceb732f7bc121f35939c56fd06e7a19ceb34c395e966c201568ad66c7aa12
|
7
|
+
data.tar.gz: aea2150135592b1f5ea645b59a154d177a2b1be91ec668a74ac80dc4f1f1d324e879b4c4ff7e03867600180188faf964e65a441bc33f53aa6404f217d196a4cc
|
data/Gemfile.lock
CHANGED
data/lib/jievro/ast/node.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jievro
|
2
2
|
module Ast
|
3
3
|
class Node
|
4
|
-
attr_reader :parent, :type, :
|
4
|
+
attr_reader :parent, :type, :value
|
5
5
|
|
6
6
|
def initialize(initializer, parent = nil, key = nil)
|
7
7
|
@parent = parent
|
@@ -29,6 +29,10 @@ module Jievro
|
|
29
29
|
@value[key]
|
30
30
|
end
|
31
31
|
|
32
|
+
def key
|
33
|
+
@key.to_s
|
34
|
+
end
|
35
|
+
|
32
36
|
def keys
|
33
37
|
@value.keys
|
34
38
|
end
|
@@ -44,6 +48,21 @@ module Jievro
|
|
44
48
|
{}
|
45
49
|
end
|
46
50
|
|
51
|
+
def each
|
52
|
+
each_with_index do |v, i|
|
53
|
+
yield v
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def each_with_index
|
58
|
+
fatal Exception, 'Cannot loop a literal node' \
|
59
|
+
if @type == '__literal'
|
60
|
+
|
61
|
+
@value.keys.each do |v|
|
62
|
+
yield @value[v], v
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
47
66
|
private
|
48
67
|
|
49
68
|
def initialize_as_literal(initializer)
|
@@ -68,12 +87,10 @@ module Jievro
|
|
68
87
|
@type = initializer[:__type]
|
69
88
|
|
70
89
|
initializer.keys.each do |k|
|
71
|
-
key = k.to_s
|
72
|
-
|
73
90
|
# skip all the meta info
|
74
|
-
next if
|
91
|
+
next if k.to_s.to_s.start_with?('__')
|
75
92
|
|
76
|
-
@value[k] = Node.new(initializer[k], self,
|
93
|
+
@value[k] = Node.new(initializer[k], self, k)
|
77
94
|
end
|
78
95
|
end
|
79
96
|
end
|
data/lib/jievro/ast/version.rb
CHANGED