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 |
# File 'lib/origen_testers/atp/parser.rb', line 4 def initialize self.ruby_keyword_literals = true end |
Instance Method Details
#string_to_ast(string) ⇒ Object
8 9 10 |
# File 'lib/origen_testers/atp/parser.rb', line 8 def string_to_ast(string) to_sexp(parse_string(string)) end |
#to_sexp(ast_array) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/origen_testers/atp/parser.rb', line 12 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 |