Skip to content

Commit

Permalink
add array content syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosenarruzza committed Dec 22, 2020
1 parent 1ffb8b1 commit 0b093f7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
21 changes: 21 additions & 0 deletions lib/rasti/db/nql/nodes/array_content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Rasti
module DB
module NQL
module Nodes
class ArrayContent < Treetop::Runtime::SyntaxNode

def values
[left.value] + right_value
end

private

def right_value
right.is_a?(self.class) ? right.values : [right.value]
end

end
end
end
end
end
7 changes: 1 addition & 6 deletions lib/rasti/db/nql/nodes/constants/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ module Constants
class Array < Base

def value
contents.add_values([])
end

def add_values(value_array)
left.add_values(value_array)
right.add_values(value_array)
contents.is_a?(ArrayContent) ? contents.values : [contents.value]
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/rasti/db/nql/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ def _nt_array_content
end
end
if s0.last
r0 = instantiate_node(Nodes::Constants::Array,input, i0...index, s0)
r0 = instantiate_node(Nodes::ArrayContent,input, i0...index, s0)
r0.extend(ArrayContent0)
else
@index = i0
Expand Down
2 changes: 1 addition & 1 deletion lib/rasti/db/nql/syntax.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module Rasti
end

rule array_content
left:basic space* ',' space* right:(array_content / basic) <Nodes::Constants::Array>
left:basic space* ',' space* right:(array_content / basic) <Nodes::ArrayContent>
end

rule space
Expand Down

0 comments on commit 0b093f7

Please sign in to comment.