Class: Dhaka::LexerSupport::OrNode
- Defined in:
- lib/dhaka/lexer/regex_grammar.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #calculate_follow_sets ⇒ Object
- #first ⇒ Object
-
#initialize(*children) ⇒ OrNode
constructor
A new instance of OrNode.
- #label ⇒ Object
- #last ⇒ Object
- #nullable ⇒ Object
- #to_dot(graph) ⇒ Object
Methods inherited from ASTNode
Constructor Details
#initialize(*children) ⇒ OrNode
Returns a new instance of OrNode.
162 163 164 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 162 def initialize(*children) @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
161 162 163 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 161 def children @children end |
Instance Method Details
#calculate_follow_sets ⇒ Object
197 198 199 200 201 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 197 def calculate_follow_sets children.each do |child| child.calculate_follow_sets end end |
#first ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 173 def first result = Set.new children.each do |child| result.merge child.first end result end |
#label ⇒ Object
165 166 167 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 165 def label "|" end |
#last ⇒ Object
181 182 183 184 185 186 187 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 181 def last result = Set.new children.each do |child| result.merge child.last end result end |
#nullable ⇒ Object
169 170 171 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 169 def nullable children.any? {|child| child.nullable} end |
#to_dot(graph) ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/dhaka/lexer/regex_grammar.rb', line 189 def to_dot(graph) graph.node(self, :label => label) children.each do |child| graph.edge(self, child) child.to_dot(graph) end end |