module Yadriggy::AstHelper
Helper module
Public Instance Methods
has_tag?(s, tag)
click to toggle source
@param [Array] s an S-expression. @param [Symbol] tag @return [Array] the S-expression if it starts with the tag.
Otherwise, raise an error.
# File lib/yadriggy/ast.rb, line 306 def has_tag?(s, tag) raise "s-exp is not :#{tag.to_s}. #{s}" if !s.nil? && s[0] != tag s end
to_node(s)
click to toggle source
@param [Array] s an S-expression. @return [ASTnode] an AST.
# File lib/yadriggy/ast.rb, line 293 def to_node(s) ASTree.to_node(s) end
to_nodes(s)
click to toggle source
@param [Array] s an array of S-expression. @return [Array<ASTnode>] ASTs.
# File lib/yadriggy/ast.rb, line 297 def to_nodes(s) raise "not an array: #{s}" unless s.class == Array s.map {|e| ASTree.to_node(e) } end