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

Constructor Details

#initialize(*children) ⇒ OrNode

Returns a new instance of OrNode.



175
176
177
# File 'lib/lexer/regex_grammar.rb', line 175

def initialize(*children)
  @children = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



174
175
176
# File 'lib/lexer/regex_grammar.rb', line 174

def children
  @children
end

Instance Method Details

#calculate_follow_setsObject



206
207
208
209
210
# File 'lib/lexer/regex_grammar.rb', line 206

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

#firstObject



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

def first
  children.inject(Set.new([])) do |result, child|
    result | child.first
  end
end

#labelObject



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

def label
  "|"
end

#lastObject



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

def last
  children.inject(Set.new([])) do |result, child|
    result | child.last
  end
end

#nullableObject



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

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

#to_dot(graph) ⇒ Object



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

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