Class: Dhaka::LexerSupport::OrNode

Inherits:
ASTNode
  • Object
show all
Defined in:
lib/dhaka/lexer/regex_grammar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ASTNode

#accepting, #checkpoint

Constructor Details

#initialize(*children) ⇒ OrNode

Returns a new instance of OrNode.



163
164
165
# File 'lib/dhaka/lexer/regex_grammar.rb', line 163

def initialize(*children)
  @children = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



162
163
164
# File 'lib/dhaka/lexer/regex_grammar.rb', line 162

def children
  @children
end

Instance Method Details

#calculate_follow_setsObject



198
199
200
201
202
# File 'lib/dhaka/lexer/regex_grammar.rb', line 198

def calculate_follow_sets
  children.each do |child|
    child.calculate_follow_sets
  end
end

#firstObject



174
175
176
177
178
179
180
# File 'lib/dhaka/lexer/regex_grammar.rb', line 174

def first
  result = Set.new
  children.each do |child|
    result.merge child.first
  end
  result
end

#labelObject



166
167
168
# File 'lib/dhaka/lexer/regex_grammar.rb', line 166

def label
  "|"
end

#lastObject



182
183
184
185
186
187
188
# File 'lib/dhaka/lexer/regex_grammar.rb', line 182

def last
  result = Set.new
  children.each do |child|
    result.merge child.last
  end
  result
end

#nullableObject



170
171
172
# File 'lib/dhaka/lexer/regex_grammar.rb', line 170

def nullable
  children.any? {|child| child.nullable}
end

#to_dot(graph) ⇒ Object



190
191
192
193
194
195
196
# File 'lib/dhaka/lexer/regex_grammar.rb', line 190

def to_dot(graph)
  graph.node(self, :label => label)
  children.each do |child|
    graph.edge(self, child)
    child.to_dot(graph)
  end
end