meta: split into independent repo; add build system, frontend
This commit is contained in:
18
tool/CMakeLists.txt
Normal file
18
tool/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
file(GLOB tool_sources
|
||||
*.c *.h
|
||||
cmd/*.c cmd/*.h)
|
||||
|
||||
if (WIN32)
|
||||
set(rc_file ${CMAKE_CURRENT_SOURCE_DIR}/../res/win32/frontend.rc)
|
||||
endif ()
|
||||
|
||||
add_executable(mie-tool ${tool_sources} ${rc_file})
|
||||
target_link_libraries(
|
||||
mie-tool
|
||||
mie
|
||||
Bluelib::Core
|
||||
Bluelib::Ds
|
||||
Bluelib::Cmd)
|
||||
|
||||
set_target_properties(mie-tool PROPERTIES OUTPUT_NAME "mie")
|
||||
target_compile_definitions(mie-tool PRIVATE MIE_STATIC=${MIE_STATIC})
|
||||
10
tool/cmd/cmd.h
Normal file
10
tool/cmd/cmd.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef CMD_CMD_H_
|
||||
#define CMD_CMD_H_
|
||||
|
||||
enum command_id {
|
||||
CMD_ROOT,
|
||||
CMD_VALIDATE,
|
||||
CMD_INTERNAL,
|
||||
};
|
||||
|
||||
#endif
|
||||
50
tool/cmd/internal.c
Normal file
50
tool/cmd/internal.c
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "cmd.h"
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
|
||||
enum {
|
||||
OPT_PRINT_SYMBOLS = 0x1000,
|
||||
OPT_PRINT_KEYWORDS,
|
||||
};
|
||||
|
||||
static int internal(const b_command* cmd, const b_arglist* args, const b_array* _)
|
||||
{
|
||||
#if 0
|
||||
if (b_arglist_get_count(args, OPT_PRINT_SYMBOLS, B_COMMAND_INVALID_ID)) {
|
||||
internal_lexer_print_symbol_tree(lex);
|
||||
}
|
||||
|
||||
if (b_arglist_get_count(args, OPT_PRINT_KEYWORDS, B_COMMAND_INVALID_ID)) {
|
||||
internal_lexer_print_keyword_dict(lex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_NAME("internal");
|
||||
B_COMMAND_SHORT_NAME('X');
|
||||
B_COMMAND_DESC("internal frontend debugging tools.");
|
||||
B_COMMAND_FUNCTION(internal);
|
||||
|
||||
B_COMMAND_OPTION(OPT_PRINT_SYMBOLS)
|
||||
{
|
||||
B_OPTION_LONG_NAME("print-symbols");
|
||||
B_OPTION_SHORT_NAME('s');
|
||||
B_OPTION_DESC(
|
||||
"print the symbol tree used by the language lexer.");
|
||||
}
|
||||
|
||||
B_COMMAND_OPTION(OPT_PRINT_KEYWORDS)
|
||||
{
|
||||
B_OPTION_LONG_NAME("print-keywords");
|
||||
B_OPTION_SHORT_NAME('k');
|
||||
B_OPTION_DESC(
|
||||
"print the keyword dictionary used by the language lexer.");
|
||||
}
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
}
|
||||
18
tool/cmd/root.c
Normal file
18
tool/cmd/root.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
|
||||
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID)
|
||||
{
|
||||
B_COMMAND_NAME("mie");
|
||||
B_COMMAND_DESC("Mie IR manipulation tool.");
|
||||
B_COMMAND_HELP_OPTION();
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
|
||||
B_COMMAND_USAGE()
|
||||
{
|
||||
B_COMMAND_USAGE_COMMAND_PLACEHOLDER();
|
||||
B_COMMAND_USAGE_OPT_PLACEHOLDER();
|
||||
B_COMMAND_USAGE_ARG_PLACEHOLDER();
|
||||
}
|
||||
}
|
||||
29
tool/cmd/validate.c
Normal file
29
tool/cmd/validate.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/ir/convert.h>
|
||||
#include <mie/ir/value.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
enum {
|
||||
OPT_TEMP,
|
||||
};
|
||||
|
||||
int validate(const b_command* cmd, const b_arglist* args, const b_array* _)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_VALIDATE, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_NAME("validate");
|
||||
B_COMMAND_SHORT_NAME('V');
|
||||
B_COMMAND_DESC("validate a mie ir file.");
|
||||
B_COMMAND_HELP_OPTION();
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
B_COMMAND_FUNCTION(validate);
|
||||
}
|
||||
8
tool/main.c
Normal file
8
tool/main.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "cmd/cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
return b_command_dispatch(CMD_ROOT, argc, argv);
|
||||
}
|
||||
Reference in New Issue
Block a user