Sha256: ea47fa8e75676f658664f66511b57a6cbc3fb67dded3fb5f5b26e6906f88cf16

Contents?: true

Size: 676 Bytes

Versions: 15

Compression:

Stored size: 676 Bytes

Contents

require 'sexpistol'
module OrigenTesters::ATP
  class Parser < Sexpistol
    def initialize
      # This accessor moves to Sexpistol::Parser in newer versions of the gem
      self.ruby_keyword_literals = true
    end

    def string_to_ast(string)
      to_sexp(parse_string(string))
    end

    def to_sexp(ast_array)
      children = ast_array.map do |item|
        if  item.is_a?(Array)
          to_sexp(item)
        else
          item
        end
      end
      type = children.shift
      return type if type.is_a?(OrigenTesters::ATP::AST::Node)
      type = type.to_s.gsub('-', '_').to_sym
      OrigenTesters::ATP::AST::Node.new(type, children)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
origen_testers-0.52.8 lib/origen_testers/atp/parser.rb
origen_testers-0.52.7 lib/origen_testers/atp/parser.rb
origen_testers-0.52.6 lib/origen_testers/atp/parser.rb
origen_testers-0.52.5 lib/origen_testers/atp/parser.rb
origen_testers-0.52.4 lib/origen_testers/atp/parser.rb
origen_testers-0.52.3 lib/origen_testers/atp/parser.rb
origen_testers-0.52.1 lib/origen_testers/atp/parser.rb
origen_testers-0.52.0 lib/origen_testers/atp/parser.rb
origen_testers-0.51.5 lib/origen_testers/atp/parser.rb
origen_testers-0.51.4 lib/origen_testers/atp/parser.rb
origen_testers-0.51.3 lib/origen_testers/atp/parser.rb
origen_testers-0.51.2 lib/origen_testers/atp/parser.rb
origen_testers-0.51.1 lib/origen_testers/atp/parser.rb
origen_testers-0.51.0 lib/origen_testers/atp/parser.rb
origen_testers-0.50.0 lib/origen_testers/atp/parser.rb