Sha256: 99da8a6c770bcd71a0afb6f4101ac117f0e4bcb79cc07470271d65240d614231

Contents?: true

Size: 598 Bytes

Versions: 25

Compression:

Stored size: 598 Bytes

Contents

require 'sexpistol'
module OrigenTesters::ATP
  class Parser < Sexpistol
    def initialize
      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

25 entries across 25 versions & 1 rubygems

Version Path
origen_testers-0.49.4 lib/origen_testers/atp/parser.rb
origen_testers-0.49.3 lib/origen_testers/atp/parser.rb
origen_testers-0.49.2 lib/origen_testers/atp/parser.rb
origen_testers-0.49.1 lib/origen_testers/atp/parser.rb
origen_testers-0.49.0 lib/origen_testers/atp/parser.rb
origen_testers-0.48.3 lib/origen_testers/atp/parser.rb
origen_testers-0.48.2 lib/origen_testers/atp/parser.rb
origen_testers-0.48.1 lib/origen_testers/atp/parser.rb
origen_testers-0.48.0 lib/origen_testers/atp/parser.rb
origen_testers-0.47.0 lib/origen_testers/atp/parser.rb
origen_testers-0.46.1 lib/origen_testers/atp/parser.rb
origen_testers-0.46.0 lib/origen_testers/atp/parser.rb
origen_testers-0.45.4 lib/origen_testers/atp/parser.rb
origen_testers-0.45.3 lib/origen_testers/atp/parser.rb
origen_testers-0.45.2 lib/origen_testers/atp/parser.rb
origen_testers-0.45.1 lib/origen_testers/atp/parser.rb
origen_testers-0.45.0 lib/origen_testers/atp/parser.rb
origen_testers-0.44.1 lib/origen_testers/atp/parser.rb
origen_testers-0.44.0 lib/origen_testers/atp/parser.rb
origen_testers-0.43.0 lib/origen_testers/atp/parser.rb