44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
#include "elna/cli/cl.hpp"
|
|
#include "elna/source/types.hpp"
|
|
#include <iostream>
|
|
|
|
namespace elna
|
|
{
|
|
namespace cli
|
|
{
|
|
void print_error(const std::unique_ptr<source::error>& compile_error)
|
|
{
|
|
std::cerr << compile_error->path().string() << ":"
|
|
<< compile_error->line() << ':' << compile_error->column()
|
|
<< ": " << compile_error->what() << std::endl;
|
|
}
|
|
|
|
constexpr std::size_t pointer_size = 4;
|
|
|
|
std::shared_ptr<source::symbol_table> add_builtin_symbols()
|
|
{
|
|
source::symbol_table result;
|
|
std::vector<std::shared_ptr<const source::type>> intrinsic_arguments;
|
|
|
|
auto boolean_info = std::make_shared<source::type_info>(source::boolean_type);
|
|
auto int_info = std::make_shared<source::type_info>(source::int_type);
|
|
result.enter("Boolean", boolean_info);
|
|
result.enter("Int", int_info);
|
|
|
|
intrinsic_arguments.push_back(int_info->type());
|
|
auto writei = std::make_shared<source::intrinsic_info>(
|
|
source::procedure_type{ intrinsic_arguments, pointer_size });
|
|
result.enter("writei", writei);
|
|
intrinsic_arguments.clear();
|
|
|
|
intrinsic_arguments.push_back(boolean_info->type());
|
|
auto writeb = std::make_shared<source::intrinsic_info>(
|
|
source::procedure_type{ intrinsic_arguments, pointer_size });
|
|
result.enter("writeb", writeb);
|
|
intrinsic_arguments.clear();
|
|
|
|
return std::make_shared<source::symbol_table>(std::move(result));
|
|
}
|
|
}
|
|
}
|