Class: Aurum::Builder::DotLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/aurum/grammar/builder/dot_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDotLogger

Returns a new instance of DotLogger.



5
6
7
# File 'lib/aurum/grammar/builder/dot_logger.rb', line 5

def initialize
  @dot_graphs = {}
end

Instance Attribute Details

#dot_graphsObject (readonly)

Returns the value of attribute dot_graphs.



4
5
6
# File 'lib/aurum/grammar/builder/dot_logger.rb', line 4

def dot_graphs
  @dot_graphs
end

Instance Method Details

#lexical_table_automata(name, automata, accepts) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/aurum/grammar/builder/dot_logger.rb', line 21

def lexical_table_automata name, automata, accepts
  dot = %Q_digraph grammar {\nrankdir=LR;\n_
  accepts.each {|state, action| dot << lexical_action_to_dot(action, state)}
  automata.table.each_with_index do |transitions, index|
    dot << %Q{#{index} [shape = circle, color = palegreen, style = filled]\n}
    dot << %Q{#{index} -> action_#{index}\n} if accepts.has_key?(index)
    transitions.each {|transition| dot << %Q{#{index} -> #{transition.destination} [label="#{transition.character_set.inspect}"]\n} }
  end
  dot << "}\n"
  @dot_graphs[name] = dot
end

#parsing_table_states(name, states) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/aurum/grammar/builder/dot_logger.rb', line 13

def parsing_table_states name, states
  dot = %Q_digraph grammar {\nrankdir=LR;\n_
  @productions.each_with_index {|production, index| dot << production_to_dot(production, index)}
  states.each {|state| dot << state_to_dot(state)}
  dot << "}\n"
  @dot_graphs[name] = dot
end

#productions(productions) ⇒ Object



9
10
11
# File 'lib/aurum/grammar/builder/dot_logger.rb', line 9

def productions productions
  @productions = productions.to_a
end