lean2/src/builtin/name_conv.lua
Leonardo de Moura 411f14415d feat(builtin): automatically generate Lean/C++ interface for builtin theories
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 18:09:53 -08:00

38 lines
970 B
Lua

-- Output a C++ statement that creates the given name
function name_to_cpp_expr(n)
function rec(n)
if not n:is_atomic() then
rec(n:get_prefix())
io.write(", ")
end
if n:is_string() then
io.write("\"" .. n:get_string() .. "\"")
else
error("numeral hierarchical names are not supported in the C++ interface: " .. tostring(n))
end
end
io.write("name(")
if n:is_atomic() then
rec(n)
else
io.write("{")
rec(n)
io.write("}")
end
io.write(")")
end
-- Output a C++ constant name based on the given hierarchical name
-- It uses '_' to glue the hierarchical name parts
function name_to_cpp_decl(n)
if not n:is_atomic(n) then
name_to_cpp_decl(n:get_prefix())
io.write("_")
end
if n:is_string() then
io.write(n:get_string())
else
error("numeral hierarchical names are not supported in the C++ interface: " .. tostring(n))
end
end