Class: MSFLVisitors::Parsers::MSFLParser

Inherits:
Object
  • Object
show all
Includes:
MSFL::Validators::Definitions::HashKey
Defined in:
lib/msfl_visitors/parsers/msfl_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(obj, lhs = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/msfl_visitors/parsers/msfl_parser.rb', line 7

def parse(obj, lhs = false)
  # send("parse_#{obj.class.to_s.gsub('::', '_')}", obj, lhs)
  case obj

    when Float, Fixnum
      MSFLVisitors::Nodes::Number.new obj

    when Hash
      parse_Hash obj, lhs

    when MSFL::Types::Set
      parse_Set obj, lhs

    when Symbol, String, NilClass
      MSFLVisitors::Nodes::Word.new obj.to_s

    else
      fail ArgumentError, "Invalid NMSFL, unable to parse."
  end
end