Module: Yadriggy::AstHelper
- Included in:
- ArrayLiteral, ArrayRef, BeginEnd, Binary, Break, Call, Conditional, ConstPathRef, Exprs, ForLoop, HashLiteral, Loop, ModuleDef, Parameters, Paren, Program, Rescue, Return, StringInterpolation, SymbolLiteral, Unary
- Defined in:
- lib/yadriggy/ast.rb
Overview
Helper module
Instance Method Summary collapse
-
#has_tag?(s, tag) ⇒ Array
The S-expression if it starts with the tag.
-
#to_node(s) ⇒ ASTnode
An AST.
-
#to_nodes(s) ⇒ Array<ASTnode>
ASTs.
Instance Method Details
#has_tag?(s, tag) ⇒ Array
306 307 308 309 |
# 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) ⇒ ASTnode
293 |
# File 'lib/yadriggy/ast.rb', line 293 def to_node(s) ASTree.to_node(s) end |
#to_nodes(s) ⇒ Array<ASTnode>
297 298 299 300 |
# 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 |