class Yadriggy::StringLiteral
String literal.
Attributes
column[R]
@return [Integer] the column.
line_no[R]
@return [Integer] the line number.
value[R]
@return [String] the character string.
Public Class Methods
new(sexp)
click to toggle source
# File lib/yadriggy/ast.rb, line 512 def initialize(sexp) @value = case sexp[0] when :@CHAR eval(sexp[1]) else # :@tstring_content if sexp[1] =~ /\n$/ sexp[1] # maybe here document else eval( "<<_YAD_STRING_\n#{sexp[1]}\n_YAD_STRING_\n").chop end end @line_no = sexp[2][0].to_i @column = sexp[2][1].to_i end
normalize(node)
click to toggle source
@param [ASTnode] node an AST. @return [ASTnode] the given AST.
If it is a {StringInterpolation} with a single element, it is converted into a single {StringLiteral}.
# File lib/yadriggy/ast.rb, line 538 def self.normalize(node) if node.class == StringInterpolation if node.contents.length == 1 return node.contents[0] end end node end
Public Instance Methods
accept(evaluator)
click to toggle source
A method for Visitor pattern. @param [Eval] evaluator the visitor of Visitor pattern. @return [void]
# File lib/yadriggy/ast.rb, line 530 def accept(evaluator) evaluator.string_literal(self) end
const_value()
click to toggle source
This is defined by attr_reader. def value() @value end
# File lib/yadriggy/ast_value.rb, line 288 def const_value() value end