Class: OrigenTesters::ATP::Parser
- Inherits:
-
Sexpistol
- Object
- Sexpistol
- OrigenTesters::ATP::Parser
- Defined in:
- lib/origen_testers/atp/parser.rb
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #string_to_ast(string) ⇒ Object
- #to_sexp(ast_array) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
4 5 6 7 |
# File 'lib/origen_testers/atp/parser.rb', line 4 def initialize # This accessor moves to Sexpistol::Parser in newer versions of the gem self.ruby_keyword_literals = true end |
Instance Method Details
#string_to_ast(string) ⇒ Object
9 10 11 |
# File 'lib/origen_testers/atp/parser.rb', line 9 def string_to_ast(string) to_sexp(parse_string(string)) end |
#to_sexp(ast_array) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/origen_testers/atp/parser.rb', line 13 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 |