Module: AtCoderFriends::Generator::CxxBuiltinConstGen

Included in:
CxxBuiltin
Defined in:
lib/at_coder_friends/generator/cxx_builtin.rb

Overview

generates C++ constants

Instance Method Summary collapse

Instance Method Details

#cnv_const_value(v) ⇒ Object



16
17
18
19
20
21
# File 'lib/at_coder_friends/generator/cxx_builtin.rb', line 16

def cnv_const_value(v)
  v
    .sub(/\b10\^/, '1e')
    .sub(/\b2\^/, '1<<')
    .gsub(',', "'")
end

#gen_const(c) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/at_coder_friends/generator/cxx_builtin.rb', line 7

def gen_const(c)
  v = cnv_const_value(c.value)
  if c.type == :max
    "const int #{c.name.upcase}_MAX = #{v};"
  else
    "const int MOD = #{v};"
  end
end