class Calcula::Exprs::IdentExpr

Expression for identifiers

@author Paul T.

Public Class Methods

new(name) click to toggle source

@param name [Calcula::Token] This token should have the type ID

# File lib/Exprs/IdentExpr.rb, line 9
def initialize(name)
  @name = name
end

Public Instance Methods

children() click to toggle source

@see Calcula::Expr#children @param (see Calcula::Expr#children) @return (see Calcula::Expr#children)

# File lib/Exprs/IdentExpr.rb, line 32
def children
  []
end
to_s(form: :src) click to toggle source

@see Calcula::Expr#to_s @param (see Calcula::Expr#to_s) @return (see Calcula::Expr#to_s)

# File lib/Exprs/IdentExpr.rb, line 16
def to_s(form: :src)
  case form
  when :src then
    @name.text
  when :tree then
    "(ident #{@name.text})"
  when :ruby then
    @name.text.tr("'", "_")
  else
    nil
  end
end