#include #include "cmd.h" #include #include #include enum { OPT_PRINT_SYMBOLS = 0x1000, OPT_PRINT_KEYWORDS, }; static int internal(const fx_command *cmd, const fx_arglist *args, const fx_array *_) { struct ivy_lexer *lex; enum ivy_status status = ivy_lexer_create(&lex); if (status != IVY_OK) { fx_err("failed to initialise lexer (error %s)", ivy_status_to_string(status)); return -1; } if (fx_arglist_get_count(args, OPT_PRINT_SYMBOLS, FX_COMMAND_INVALID_ID)) { internal_lexer_print_symbol_tree(lex); } if (fx_arglist_get_count(args, OPT_PRINT_KEYWORDS, FX_COMMAND_INVALID_ID)) { internal_lexer_print_keyword_dict(lex); } ivy_lexer_destroy(lex); return 0; } B_COMMAND(CMD_INTERNAL, CMD_ROOT) { FX_COMMAND_NAME("internal"); FX_COMMAND_SHORT_NAME('X'); FX_COMMAND_DESC("internal frontend debugging tools."); FX_COMMAND_FUNCTION(internal); FX_COMMAND_OPTION(OPT_PRINT_SYMBOLS) { FX_OPTION_LONG_NAME("print-symbols"); FX_OPTION_SHORT_NAME('s'); FX_OPTION_DESC( "print the symbol tree used by the language lexer."); } FX_COMMAND_OPTION(OPT_PRINT_KEYWORDS) { FX_OPTION_LONG_NAME("print-keywords"); FX_OPTION_SHORT_NAME('k'); FX_OPTION_DESC( "print the keyword dictionary used by the language lexer."); } FX_COMMAND_HELP_OPTION(); }