class Mahoujin::Graphics::Stringify
Public Instance Methods
stringify(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 4 def stringify(atom) stringify_atom(atom) end
Private Instance Methods
stringify_atom(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 10 def stringify_atom(atom) send "stringify_#{atom.class.underscore_name}", atom end
stringify_choice(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 26 def stringify_choice(atom) atom.atoms.map(&->(a) { stringify_atom(a) }).join(' | ') end
stringify_concatenation(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 30 def stringify_concatenation(atom) atom.atoms.map(&->(a) { stringify_atom(a) }).join(', ') end
stringify_exception(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 54 def stringify_exception(atom) atom.content end
stringify_grouping(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 46 def stringify_grouping(atom) "( #{stringify_atom(atom.atom)} )" end
stringify_non_terminal(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 58 def stringify_non_terminal(atom) atom.content end
stringify_optional(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 38 def stringify_optional(atom) "[ #{stringify_atom(atom.atom)} ]" end
stringify_prose(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 50 def stringify_prose(atom) "? #{atom.content} ?" end
stringify_rule(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 18 def stringify_rule(atom) "#{stringify_atom(atom.rule_name_atom)} = #{stringify_atom(atom.atom)};" end
stringify_rule_name(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 22 def stringify_rule_name(atom) atom.content end
stringify_specific_repetition(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 34 def stringify_specific_repetition(atom) "#{atom.number} * #{stringify_atom(atom.atom)}" end
stringify_syntax(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 14 def stringify_syntax(atom) atom.atoms.map(&->(a) { stringify_atom(a) }).join("\n") end
stringify_terminal(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 62 def stringify_terminal(atom) atom.content.include?("'") ? "\"#{atom.content}\"" : "'#{atom.content}'" end
stringify_zero_or_more_repetition(atom)
click to toggle source
# File lib/mahoujin/graphics/stringify.rb, line 42 def stringify_zero_or_more_repetition(atom) "{ #{stringify_atom(atom.atom)} }" end