Method: PSON::Pure::Parser#parse

Defined in:
lib/puppet/external/pson/pure/parser.rb

#parseObject

Parses the current PSON string source and returns the complete data structure as a result.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/puppet/external/pson/pure/parser.rb', line 84

def parse
  reset
  obj = nil
  until eos?
    case
    when scan(OBJECT_OPEN)
      obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
      @current_nesting = 1
      obj = parse_object
    when scan(ARRAY_OPEN)
      obj and raise ParserError, "source '#{peek(20)}' not in PSON!"
      @current_nesting = 1
      obj = parse_array
    when skip(IGNORE)
      ;
    else
      raise ParserError, "source '#{peek(20)}' not in PSON!"
    end
  end
  obj or raise ParserError, "source did not contain any PSON!"
  obj
end