Class: SyntaxTree::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

This is the parent node of all of the syntax tree nodes. It’s pretty much exclusively here to make it easier to operate with the tree in cases where you’re trying to monkey-patch or strictly type.

Direct Known Subclasses

ARef, ARefField, Alias, ArgBlock, ArgParen, ArgStar, Args, ArgsForward, ArrayLiteral, AryPtn, Assign, Assoc, AssocSplat, BEGINBlock, Backref, Backtick, BareAssocHash, Begin, Binary, BlockArg, BlockVar, BodyStmt, BraceBlock, Break, CHAR, CVar, Call, Case, ClassDeclaration, Comma, Command, CommandCall, Comment, Const, ConstPathField, ConstPathRef, ConstRef, Def, DefEndless, Defined, Defs, DoBlock, Dot2, Dot3, DynaSymbol, ENDBlock, Else, Elsif, EmbDoc, EmbExprBeg, EmbExprEnd, EmbVar, EndContent, Ensure, ExcessedComma, FCall, Field, FloatLiteral, FndPtn, For, GVar, HashLiteral, Heredoc, HeredocBeg, HshPtn, IVar, Ident, If, IfMod, IfOp, Imaginary, In, Int, Kw, KwRestParam, LBrace, LBracket, LParen, Label, LabelEnd, Lambda, MAssign, MLHS, MLHSParen, MRHS, MethodAddBlock, ModuleDeclaration, Next, Not, Op, OpAssign, Params, Paren, Period, PinnedBegin, PinnedVarRef, Program, QSymbols, QSymbolsBeg, QWords, QWordsBeg, RAssign, RBrace, RBracket, RParen, RationalLiteral, Redo, RegexpBeg, RegexpContent, RegexpEnd, RegexpLiteral, Rescue, RescueEx, RescueMod, RestParam, Retry, Return, Return0, SClass, Statements, StringConcat, StringContent, StringDVar, StringEmbExpr, StringLiteral, Super, SymBeg, SymbolContent, SymbolLiteral, Symbols, SymbolsBeg, TLamBeg, TLambda, TStringBeg, TStringContent, TStringEnd, TopConstField, TopConstRef, Unary, Undef, Unless, UnlessMod, Until, UntilMod, VCall, VarAlias, VarField, VarRef, VoidStmt, When, While, WhileMod, Word, Words, WordsBeg, XString, XStringLiteral, Yield, Yield0, ZSuper

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationObject (readonly)

Location

the location of this node



74
75
76
# File 'lib/syntax_tree/node.rb', line 74

def location
  @location
end

Instance Method Details

#accept(visitor) ⇒ Object

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/syntax_tree/node.rb', line 76

def accept(visitor)
  raise NotImplementedError
end

#child_nodesObject

Raises:

  • (NotImplementedError)


80
81
82
# File 'lib/syntax_tree/node.rb', line 80

def child_nodes
  raise NotImplementedError
end

#deconstructObject

Raises:

  • (NotImplementedError)


84
85
86
# File 'lib/syntax_tree/node.rb', line 84

def deconstruct
  raise NotImplementedError
end

#deconstruct_keys(keys) ⇒ Object

Raises:

  • (NotImplementedError)


88
89
90
# File 'lib/syntax_tree/node.rb', line 88

def deconstruct_keys(keys)
  raise NotImplementedError
end

#format(q) ⇒ Object

Raises:

  • (NotImplementedError)


92
93
94
# File 'lib/syntax_tree/node.rb', line 92

def format(q)
  raise NotImplementedError
end

#pretty_print(q) ⇒ Object



96
97
98
99
# File 'lib/syntax_tree/node.rb', line 96

def pretty_print(q)
  visitor = Visitor::PrettyPrintVisitor.new(q)
  visitor.visit(self)
end

#to_json(*opts) ⇒ Object



101
102
103
104
# File 'lib/syntax_tree/node.rb', line 101

def to_json(*opts)
  visitor = Visitor::JSONVisitor.new
  visitor.visit(self).to_json(*opts)
end