Module: Bai2::Parser

Defined in:
lib/bai2/parser.rb

Defined Under Namespace

Classes: ParseNode

Class Method Summary collapse

Class Method Details

.parse(data, options) ⇒ Object

Parsing is a two-step process:

  1. Build a tree

  2. Parse the tree



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bai2/parser.rb', line 29

def parse(data, options)

  # split records, handle stupid DOS-format files, instantiate records
  records = data.split("\n").map(&:strip).map {|l| Record.new(l, options: options) }

  # merge continuations
  records = merge_continuations(records)

  # build the tree
  root = parse_tree(records)

  root
end