Class: MSFLVisitors::Parsers::MSFLParser

Inherits:
Object
  • Object
show all
Defined in:
lib/msfl_visitors/parsers/msfl_parser.rb

Constant Summary collapse

OPERATORS_TO_NODE_CLASS =
{
    and:        Nodes::And,
    or:         Nodes::Or,
    gt:         Nodes::GreaterThan,
    gte:        Nodes::GreaterThanEqual,
    eq:         Nodes::Equal,
    lt:         Nodes::LessThan,
    lte:        Nodes::LessThanEqual,
    in:         Nodes::Containment,
    foreign:    Nodes::Foreign,
    dataset:    Nodes::Dataset,
    filter:     Nodes::ExplicitFilter,
    given:      Nodes::Given,
    partial:    Nodes::Partial,

}

Instance Method Summary collapse

Constructor Details

#initialize(dataset = nil) ⇒ MSFLParser

Returns a new instance of MSFLParser.



43
44
45
# File 'lib/msfl_visitors/parsers/msfl_parser.rb', line 43

def initialize(dataset = nil)
  @dataset = dataset
end

Instance Method Details

#parse(obj, lhs = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/msfl_visitors/parsers/msfl_parser.rb', line 22

def parse(obj, lhs = false)
  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 type: #{obj.class}."
  end
end