class Speculations::Parser
Public Class Methods
new()
click to toggle source
# File lib/speculations/parser.rb, line 26 def initialize @state = :out end
parsers()
click to toggle source
# File lib/speculations/parser.rb, line 7 def self.parsers @__parsers__ ||= { candidate: State::Candidate, in: State::In, out: State::Out } end
Public Instance Methods
parse_from_file(file)
click to toggle source
# File lib/speculations/parser.rb, line 15 def parse_from_file file @filename = file @input = File .new(file) .each_line(chomp: true) .lazy parse! end
Private Instance Methods
parse!()
click to toggle source
# File lib/speculations/parser.rb, line 30 def parse! root = node = Context.new(filename: @filename) ctxt = nil @input.each_with_index do |line, lnb| @state, node, ctxt = self.class.parsers.fetch(@state).parse(line, lnb.succ, node, ctxt) end root end