Class: Dhaka::LexerSupport::OrNode

Inherits:
ASTNode
  • Object
show all
Defined in:
lib/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.



180
181
182
# File 'lib/lexer/regex_grammar.rb', line 180

def initialize(*children)
  @children = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



179
180
181
# File 'lib/lexer/regex_grammar.rb', line 179

def children
  @children
end

Instance Method Details

#calculate_follow_setsObject



215
216
217
218
219
# File 'lib/lexer/regex_grammar.rb', line 215

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

#firstObject



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

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

#labelObject



183
184
185
# File 'lib/lexer/regex_grammar.rb', line 183

def label
  "|"
end

#lastObject



199
200
201
202
203
204
205
# File 'lib/lexer/regex_grammar.rb', line 199

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

#nullableObject



187
188
189
# File 'lib/lexer/regex_grammar.rb', line 187

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

#to_dot(graph) ⇒ Object



207
208
209
210
211
212
213
# File 'lib/lexer/regex_grammar.rb', line 207

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