Class: LangTOML

Inherits:
Resyma::Language show all
Defined in:
lib/resyma/nise/toml.rb

Instance Attribute Summary

Attributes inherited from Resyma::Language

#engine

Instance Method Summary collapse

Methods inherited from Resyma::Language

#build_language, #built?, #initialize, #load, load, #load_ast, #load_parsetree!

Constructor Details

This class inherits a constructor from Resyma::Language

Instance Method Details

#syntaxObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/resyma/nise/toml.rb', line 35

def syntax
  [array, 
   (id; ("."; id)..; "="; [int, str, "true", "false", array, hash])]... >>
  begin
    bdr = LangTOMLBuilder.new
    until nodes.empty?
      car = nodes.shift
      if car.symbol == :array
        namespace = 
          LangTOMLNamespace.new.load_parsetree!(
            car, src_binding, src_filename, src_lineno
          )
        bdr.prefix = namespace
      else
        path = [car]
        car = nodes.shift
        until car.symbol == :eq
          path.push car if car.symbol == :id
          car = nodes.shift
        end
        value = nodes.shift
        bdr.add!(path.map(&:to_literal), 
                 value.to_ruby(src_binding, src_filename, src_lineno))
      end
    end
    bdr.root
  end
end