Class: Vmaps::Parser
- Inherits:
-
Object
- Object
- Vmaps::Parser
- Defined in:
- lib/vmaps/parser.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse_to_mappings ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
5 6 7 |
# File 'lib/vmaps/parser.rb', line 5 def initialize source @source = source.split("\n") end |
Instance Method Details
#parse_to_mappings ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vmaps/parser.rb', line 9 def parse_to_mappings mappings = Array.new mapping = Mapping.new @source.each do |line| if line[0] == "\t" mapping.set_from = line.sub("\tLast set from ", '') mappings << mapping mapping = Mapping.new else mapping.mode = line[0..2].strip mapping.mode = 'nvxso' if mapping.mode.empty? parts = line[3..-1].split(' ') mapping.lhs = parts.shift if parts.first.start_with?('*', '&', '@') mapping.special = parts.shift end mapping.rhs = parts.join() end end return mappings end |