class Yadriggy::Number

Numeric literal.

Attributes

column[R]

@return [Integer] the column.

line_no[R]

@return [Integer] the line number.

value[R]

@return [Numeric] the number.

Public Class Methods

new(sexp) click to toggle source
# File lib/yadriggy/ast.rb, line 263
def initialize(sexp)
  @value = case sexp[0]
           when :@int
             if sexp[1].start_with? "0x"
               sexp[1].hex
             else
               sexp[1].to_i
             end
           when :@float
             sexp[1].to_f
           else
             raise "unknown symbol " + sexp[0]
           end
  @line_no = sexp[2][0].to_i
  @column = sexp[2][1].to_i
end
tags() click to toggle source
# File lib/yadriggy/ast.rb, line 259
def self.tags()
  [:@int, :@float]
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 283
def accept(evaluator)
  evaluator.number(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 267
def const_value() value end