Class: Parse::StateGraph
- Inherits:
-
BackLinkedDirectedGraph
- Object
- DirectedGraph
- BackLinkedDirectedGraph
- Parse::StateGraph
- Defined in:
- lib/rpdf2txt-rockit/lalr_parsetable_generator.rb
Constant Summary collapse
- @@node_labeler_with_kernels =
proc{|state| "S" + state.index_number.inspect + ": " + state.kernel_items.inspect }
- @@node_labeler =
proc{|state| "S" + state.index_number.inspect }
Instance Attribute Summary collapse
-
#consistent_reduce_states ⇒ Object
readonly
Returns the value of attribute consistent_reduce_states.
-
#inconsistent_reduce_states ⇒ Object
readonly
Returns the value of attribute inconsistent_reduce_states.
-
#start_state ⇒ Object
readonly
Returns the value of attribute start_state.
Attributes inherited from DirectedGraph
Instance Method Summary collapse
- #add_node(state) ⇒ Object
-
#initialize(startState, *args) ⇒ StateGraph
constructor
A new instance of StateGraph.
- #to_postscript_file(filename, withKernelItems = true) ⇒ Object
Methods inherited from BackLinkedDirectedGraph
#add_link, #back_transition, #back_traverse, #incoming_links_info, #links_to
Methods inherited from DirectedGraph
#acyclic?, #add_link, #add_link_nodes, #children, #cyclic?, #each_reachable_node_once_breadth_first, #each_reachable_node_once_depth_first, #include_node?, #internal_node?, #internal_nodes, #leaf?, #leaf_nodes, #link_nodes, #links_from, #links_from_to, #links_from_to?, #nodes, #recurse_cyclic?, #recurse_each_reachable_breadth_first_visited, #recurse_each_reachable_depth_first_visited, #root?, #root_nodes, #to_dot, #transition, #transitive_closure_floyd_warshal, #traverse
Constructor Details
#initialize(startState, *args) ⇒ StateGraph
Returns a new instance of StateGraph.
13 14 15 16 17 18 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 13 def initialize(startState, *args) super(*args) @start_state = startState @consistent_reduce_states = Array.new @inconsistent_reduce_states = Array.new end |
Instance Attribute Details
#consistent_reduce_states ⇒ Object (readonly)
Returns the value of attribute consistent_reduce_states.
11 12 13 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 11 def consistent_reduce_states @consistent_reduce_states end |
#inconsistent_reduce_states ⇒ Object (readonly)
Returns the value of attribute inconsistent_reduce_states.
11 12 13 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 11 def inconsistent_reduce_states @inconsistent_reduce_states end |
#start_state ⇒ Object (readonly)
Returns the value of attribute start_state.
10 11 12 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 10 def start_state @start_state end |
Instance Method Details
#add_node(state) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 20 def add_node(state) super(state) if state.reduce_state? if state.consistent? a = @consistent_reduce_states else a = @inconsistent_reduce_states end a.push state unless a.include?(state) end end |
#to_postscript_file(filename, withKernelItems = true) ⇒ Object
40 41 42 43 |
# File 'lib/rpdf2txt-rockit/lalr_parsetable_generator.rb', line 40 def to_postscript_file(filename, withKernelItems = true) super(filename, nil, withKernelItems ? @@node_labeler_with_kernels : @@node_labeler ) end |