Class: Yadriggy::SymbolLiteral
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb
Overview
Symbol.
Instance Attribute Summary collapse
-
#column ⇒ Integer
readonly
The column.
-
#line_no ⇒ Integer
readonly
The line number.
-
#name ⇒ String
readonly
The symbol name.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
- #const_value ⇒ Object
-
#initialize(sexp) ⇒ SymbolLiteral
constructor
A new instance of SymbolLiteral.
-
#to_sym ⇒ Symbol
A symbol the literal represents.
-
#value ⇒ Object
Gets the symbol represented by this node.
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value_in_class
Constructor Details
#initialize(sexp) ⇒ SymbolLiteral
Returns a new instance of SymbolLiteral.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/yadriggy/ast.rb', line 331 def initialize(sexp) if sexp[0] == :dyna_symbol sexp2 = if sexp[1][0] == :string_content sexp[1][1] else sexp[1][0] end init(has_tag?(sexp2, :@tstring_content)) elsif sexp[0] == :symbol_literal init(has_tag?(sexp[1], :symbol)[1]) else init(has_tag?(sexp, :symbol)[1]) end end |
Instance Attribute Details
#column ⇒ Integer (readonly)
Returns the column.
327 328 329 |
# File 'lib/yadriggy/ast.rb', line 327 def column @column end |
#line_no ⇒ Integer (readonly)
Returns the line number.
325 326 327 |
# File 'lib/yadriggy/ast.rb', line 325 def line_no @line_no end |
#name ⇒ String (readonly)
Returns the symbol name.
For example, if the object represents :sym
, then
"sym"
(without a colon) is returned.
323 324 325 |
# File 'lib/yadriggy/ast.rb', line 323 def name @name end |
Class Method Details
.tags ⇒ Object
329 |
# File 'lib/yadriggy/ast.rb', line 329 def self.() [:symbol, :symbol_literal, :dyna_symbol] end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
354 355 356 |
# File 'lib/yadriggy/ast.rb', line 354 def accept(evaluator) evaluator.symbol(self) end |
#const_value ⇒ Object
297 |
# File 'lib/yadriggy/ast_value.rb', line 297 def const_value() value end |
#to_sym ⇒ Symbol
Returns a symbol the literal represents.
347 348 349 |
# File 'lib/yadriggy/ast.rb', line 347 def to_sym name.to_sym end |
#value ⇒ Object
Gets the symbol represented by this node.
293 294 295 |
# File 'lib/yadriggy/ast_value.rb', line 293 def value() name.to_sym end |