///
///  @file    _cmd_exec.c
///
///  @brief   Auxiliary file for cmd_exec.c, containing command tables.
///
///           This file defines data that is statically stored, rather than
///           just being declared, and is intended to be used by only one
///           source file, through use of the #include directive. This is why
///           it is created in the include/ directory, with a file type of
///           .c, and with the same name (prefaced by a leading underscore)
///           as the file which will use it.
///
///  *** This file is automatically generated. DO NOT MODIFY. ***
///
///  @copyright 2020-2023 Franklin P. Johnston / Nowwith Treble Software
///
///  Permission is hereby granted, free of charge, to any person obtaining a
///  copy of this software and associated documentation files (the "Software"),
///  to deal in the Software without restriction, including without limitation
///  the rights to use, copy, modify, merge, publish, distribute, sublicense,
///  and/or sell copies of the Software, and to permit persons to whom the
///  Software is furnished to do so, subject to the following conditions:
///
///  The above copyright notice and this permission notice shall be included in
///  all copies or substantial portions of the Software.
///
///  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
///  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
///  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
///  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIA-
///  BILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
///  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
///  THE SOFTWARE.
///
////////////////////////////////////////////////////////////////////////////////

// Command table definitions

///  @typedef scan_func
///  @brief   Function to scan command.

typedef bool (scan_func)(struct cmd *cmd);

///  @typedef exec_func
///  @brief   Function to execute command.

typedef void (exec_func)(struct cmd *cmd);

///  @struct cmd_table
///
///  @brief  Format of command tables used to scan and execute commands.

struct cmd_table
{
    scan_func *scan;                ///< Scan function
    exec_func *exec;                ///< Execute function

//#if     defined(TRACE)

//    const char *scan_name;          ///< Name of scan function
//    const char *exec_name;          ///< Name of execute function

//#endif

};

#define NO_ARGS     (bool)false     ///< m & n args are not preserved by command

#define MN_ARGS     (bool)true      ///< m & n args are preserved by command

/// @def    ENTRY(chr, scan, exec)
/// @brief  Defines entries in command table.

//#if     defined(TRACE)

//#define ENTRY(chr, scan, exec) [chr] = { scan, exec, #scan, #exec }

//#else

#define ENTRY(chr, scan, exec) [chr] = { scan, exec }

//#endif

///
///  @var    cmd_table
///
///  @brief  Dispatch table, defining functions to scan and execute commands.
///

static const struct cmd_table cmd_table[] =
{
    ENTRY(NUL,         scan_white,       NULL            ),
    ENTRY(CTRL_A,      scan_ctrl_A,      exec_ctrl_A     ),
    ENTRY(CTRL_B,      scan_ctrl_B,      NULL            ),
    ENTRY(CTRL_C,      NULL,             exec_ctrl_C     ),
    ENTRY(CTRL_D,      NULL,             exec_ctrl_D     ),
    ENTRY(CTRL_E,      scan_flag1,       exec_ctrl_E     ),
    ENTRY(CTRL_F,      NULL,             exec_bad        ),
    ENTRY(CTRL_G,      NULL,             exec_bad        ),
    ENTRY(CTRL_H,      scan_ctrl_H,      NULL            ),
    ENTRY(CTRL_I,      scan_ctrl_I,      exec_ctrl_I     ),
    ENTRY(CTRL_J,      scan_white,       NULL            ),
    ENTRY(CTRL_K,      NULL,             exec_bad        ),
    ENTRY(CTRL_L,      scan_white,       NULL            ),
    ENTRY(CTRL_M,      scan_white,       NULL            ),
    ENTRY(CTRL_N,      scan_flag1,       NULL            ),
    ENTRY(CTRL_O,      NULL,             exec_ctrl_O     ),
    ENTRY(CTRL_P,      scan_ctrl_P,      NULL            ),
    ENTRY(CTRL_Q,      scan_ctrl_Q,      exec_ctrl_Q     ),
    ENTRY(CTRL_R,      NULL,             exec_ctrl_R     ),
    ENTRY(CTRL_S,      scan_ctrl_S,      NULL            ),
    ENTRY(CTRL_T,      scan_ctrl_T,      exec_ctrl_T     ),
    ENTRY(CTRL_U,      scan_ctrl_U,      exec_ctrl_U     ),
    ENTRY(CTRL_V,      NULL,             exec_ctrl_V     ),
    ENTRY(CTRL_W,      NULL,             exec_ctrl_W     ),
    ENTRY(CTRL_X,      scan_flag1,       exec_ctrl_X     ),
    ENTRY(CTRL_Y,      scan_ctrl_Y,      NULL            ),
    ENTRY(CTRL_Z,      scan_ctrl_Z,      NULL            ),
    ENTRY(CTRL_LEFT,   NULL,             exec_escape     ),
    ENTRY(CTRL_BACK,   NULL,             exec_bad        ),
    ENTRY(CTRL_RIGHT,  NULL,             exec_bad        ),
    ENTRY(CTRL_UP,     scan_ctrl_up,     NULL            ),
    ENTRY(CTRL_UNDER,  scan_ctrl_under,  NULL            ),
    ENTRY(SPACE,       scan_white,       NULL            ),
    ENTRY('!',         scan_tag,         exec_tag        ),
    ENTRY('"',         scan_if,          exec_if         ),
    ENTRY('#',         scan_or,          NULL            ),
    ENTRY('$',         NULL,             exec_bad        ),
    ENTRY('%',         scan_percent,     exec_percent    ),
    ENTRY('&',         scan_and,         NULL            ),
    ENTRY('\'',        NULL,             exec_endif      ),
    ENTRY('(',         scan_left,        NULL            ),
    ENTRY(')',         scan_right,       NULL            ),
    ENTRY('*',         scan_mul,         NULL            ),
    ENTRY('+',         scan_add,         NULL            ),
    ENTRY(',',         scan_comma,       NULL            ),
    ENTRY('-',         scan_sub,         NULL            ),
    ENTRY('.',         scan_dot,         NULL            ),
    ENTRY('/',         scan_div,         NULL            ),
    ENTRY('0',         scan_number,      NULL            ),
    ENTRY('1',         scan_number,      NULL            ),
    ENTRY('2',         scan_number,      NULL            ),
    ENTRY('3',         scan_number,      NULL            ),
    ENTRY('4',         scan_number,      NULL            ),
    ENTRY('5',         scan_number,      NULL            ),
    ENTRY('6',         scan_number,      NULL            ),
    ENTRY('7',         scan_number,      NULL            ),
    ENTRY('8',         scan_number,      NULL            ),
    ENTRY('9',         scan_number,      NULL            ),
    ENTRY(':',         scan_colon,       NULL            ),
    ENTRY(';',         scan_semi,        exec_semi       ),
    ENTRY('<',         scan_less,        exec_less       ),
    ENTRY('=',         scan_equals,      exec_equals     ),
    ENTRY('>',         scan_greater,     exec_greater    ),
    ENTRY('?',         NULL,             exec_trace      ),
    ENTRY('@',         scan_atsign,      NULL            ),
    ENTRY('A',         scan_A,           exec_A          ),
    ENTRY('a',         scan_A,           exec_A          ),
    ENTRY('B',         scan_B,           NULL            ),
    ENTRY('b',         scan_B,           NULL            ),
    ENTRY('C',         scan_C,           exec_C          ),
    ENTRY('c',         scan_C,           exec_C          ),
    ENTRY('D',         scan_D,           exec_D          ),
    ENTRY('d',         scan_D,           exec_D          ),
    ENTRY('E',         scan_false,       NULL            ),
    ENTRY('e',         scan_false,       NULL            ),
    ENTRY('F',         scan_false,       NULL            ),
    ENTRY('f',         scan_false,       NULL            ),
    ENTRY('G',         scan_G,           exec_G          ),
    ENTRY('g',         scan_G,           exec_G          ),
    ENTRY('H',         scan_H,           NULL            ),
    ENTRY('h',         scan_H,           NULL            ),
    ENTRY('I',         scan_I,           exec_I          ),
    ENTRY('i',         scan_I,           exec_I          ),
    ENTRY('J',         scan_J,           exec_J          ),
    ENTRY('j',         scan_J,           exec_J          ),
    ENTRY('K',         scan_K,           exec_K          ),
    ENTRY('k',         scan_K,           exec_K          ),
    ENTRY('L',         scan_C,           exec_L          ),
    ENTRY('l',         scan_C,           exec_L          ),
    ENTRY('M',         scan_M,           exec_M          ),
    ENTRY('m',         scan_M,           exec_M          ),
    ENTRY('N',         scan_N,           exec_N          ),
    ENTRY('n',         scan_N,           exec_N          ),
    ENTRY('O',         scan_O,           exec_O          ),
    ENTRY('o',         scan_O,           exec_O          ),
    ENTRY('P',         scan_P,           exec_P          ),
    ENTRY('p',         scan_P,           exec_P          ),
    ENTRY('Q',         scan_Q,           NULL            ),
    ENTRY('q',         scan_Q,           NULL            ),
    ENTRY('R',         scan_C,           exec_R          ),
    ENTRY('r',         scan_C,           exec_R          ),
    ENTRY('S',         scan_S,           exec_S          ),
    ENTRY('s',         scan_S,           exec_S          ),
    ENTRY('T',         scan_T,           exec_T          ),
    ENTRY('t',         scan_T,           exec_T          ),
    ENTRY('U',         scan_U,           exec_U          ),
    ENTRY('u',         scan_U,           exec_U          ),
    ENTRY('V',         scan_V,           exec_V          ),
    ENTRY('v',         scan_V,           exec_V          ),
    ENTRY('W',         scan_W,           exec_W          ),
    ENTRY('w',         scan_W,           exec_W          ),
    ENTRY('X',         scan_X,           exec_X          ),
    ENTRY('x',         scan_X,           exec_X          ),
    ENTRY('Y',         scan_Y,           exec_Y          ),
    ENTRY('y',         scan_Y,           exec_Y          ),
    ENTRY('Z',         scan_Z,           NULL            ),
    ENTRY('z',         scan_Z,           NULL            ),
    ENTRY('[',         scan_pushQ,       exec_pushQ      ),
    ENTRY('\\',        NULL,             exec_back       ),
    ENTRY(']',         scan_popQ,        exec_popQ       ),
    ENTRY('^',         scan_false,       NULL            ),
    ENTRY('_',         scan_under,       exec_under      ),
    ENTRY('`',         NULL,             exec_bad        ),
    ENTRY('{',         NULL,             exec_bad        ),
    ENTRY('|',         NULL,             exec_else       ),
    ENTRY('}',         NULL,             exec_bad        ),
    ENTRY('~',         scan_xor,         NULL            ),
    ENTRY(DEL,         NULL,             exec_bad        ),
};


///  @var    e_table
///  @brief  Table for all commands starting with E.

static const struct cmd_table e_table[] =
{
    ENTRY('%',         scan_EQ,          exec_E_percent  ),
    ENTRY('1',         scan_flag2,       exec_E1         ),
    ENTRY('2',         scan_flag2,       exec_E2         ),
    ENTRY('3',         scan_flag2,       exec_E3         ),
    ENTRY('4',         scan_flag2,       exec_E4         ),
    ENTRY('A',         NULL,             exec_EA         ),
    ENTRY('a',         NULL,             exec_EA         ),
    ENTRY('B',         scan_ER,          exec_EB         ),
    ENTRY('b',         scan_ER,          exec_EB         ),
    ENTRY('C',         NULL,             exec_EC         ),
    ENTRY('c',         NULL,             exec_EC         ),
    ENTRY('D',         scan_flag2,       exec_ED         ),
    ENTRY('d',         scan_flag2,       exec_ED         ),
    ENTRY('E',         scan_flag1,       exec_EE         ),
    ENTRY('e',         scan_flag1,       exec_EE         ),
    ENTRY('F',         NULL,             exec_EF         ),
    ENTRY('f',         NULL,             exec_EF         ),
    ENTRY('G',         scan_ER,          exec_EG         ),
    ENTRY('g',         scan_ER,          exec_EG         ),
    ENTRY('H',         scan_flag2,       exec_EH         ),
    ENTRY('h',         scan_flag2,       exec_EH         ),
    ENTRY('I',         scan_EI,          exec_EI         ),
    ENTRY('i',         scan_EI,          exec_EI         ),
    ENTRY('J',         scan_EJ,          NULL            ),
    ENTRY('j',         scan_EJ,          NULL            ),
    ENTRY('K',         NULL,             exec_EK         ),
    ENTRY('k',         NULL,             exec_EK         ),
    ENTRY('L',         scan_EL,          exec_EL         ),
    ENTRY('l',         scan_EL,          exec_EL         ),
    ENTRY('M',         scan_EM,          exec_EM         ),
    ENTRY('m',         scan_EM,          exec_EM         ),
    ENTRY('N',         scan_ER,          exec_EN         ),
    ENTRY('n',         scan_ER,          exec_EN         ),
    ENTRY('O',         scan_EO,          exec_EO         ),
    ENTRY('o',         scan_EO,          exec_EO         ),
    ENTRY('P',         NULL,             exec_EP         ),
    ENTRY('p',         NULL,             exec_EP         ),
    ENTRY('Q',         scan_EQ,          exec_EQ         ),
    ENTRY('q',         scan_EQ,          exec_EQ         ),
    ENTRY('R',         scan_ER,          exec_ER         ),
    ENTRY('r',         scan_ER,          exec_ER         ),
    ENTRY('S',         scan_flag2,       exec_ES         ),
    ENTRY('s',         scan_flag2,       exec_ES         ),
    ENTRY('T',         scan_flag2,       exec_ET         ),
    ENTRY('t',         scan_flag2,       exec_ET         ),
    ENTRY('U',         scan_flag1,       exec_EU         ),
    ENTRY('u',         scan_flag1,       exec_EU         ),
    ENTRY('V',         scan_flag2,       exec_EV         ),
    ENTRY('v',         scan_flag2,       exec_EV         ),
    ENTRY('W',         scan_ER,          exec_EW         ),
    ENTRY('w',         scan_ER,          exec_EW         ),
    ENTRY('X',         NULL,             exec_EX         ),
    ENTRY('x',         NULL,             exec_EX         ),
    ENTRY('Y',         scan_Y,           exec_EY         ),
    ENTRY('y',         scan_Y,           exec_EY         ),
    ENTRY('Z',         scan_ER,          exec_EZ         ),
    ENTRY('z',         scan_ER,          exec_EZ         ),
    ENTRY('_',         scan_E_under,     exec_E_under    ),
};


///  @var    f_table
///  @brief  Table for all commands starting with F.

static const struct cmd_table f_table[] =
{
    ENTRY('\'',        NULL,             exec_F_endif    ),
    ENTRY('0',         scan_F0,          NULL            ),
    ENTRY('1',         scan_F1,          exec_F1         ),
    ENTRY('2',         scan_F1,          exec_F2         ),
    ENTRY('3',         scan_F1,          exec_F3         ),
    ENTRY('4',         scan_F1,          exec_F4         ),
    ENTRY('<',         NULL,             exec_F_less     ),
    ENTRY('>',         NULL,             exec_F_greater  ),
    ENTRY('B',         scan_FB,          exec_FB         ),
    ENTRY('b',         scan_FB,          exec_FB         ),
    ENTRY('C',         scan_FC,          exec_FC         ),
    ENTRY('c',         scan_FC,          exec_FC         ),
    ENTRY('D',         scan_FD,          exec_FD         ),
    ENTRY('d',         scan_FD,          exec_FD         ),
    ENTRY('F',         scan_FF,          exec_FF         ),
    ENTRY('f',         scan_FF,          exec_FF         ),
    ENTRY('H',         scan_FH,          NULL            ),
    ENTRY('h',         scan_FH,          NULL            ),
    ENTRY('K',         scan_FK,          exec_FK         ),
    ENTRY('k',         scan_FK,          exec_FK         ),
    ENTRY('L',         scan_case,        exec_FL         ),
    ENTRY('l',         scan_case,        exec_FL         ),
    ENTRY('M',         scan_FM,          exec_FM         ),
    ENTRY('m',         scan_FM,          exec_FM         ),
    ENTRY('N',         scan_FN,          exec_FN         ),
    ENTRY('n',         scan_FN,          exec_FN         ),
    ENTRY('Q',         scan_EQ,          exec_FQ         ),
    ENTRY('q',         scan_EQ,          exec_FQ         ),
    ENTRY('R',         scan_FR,          exec_FR         ),
    ENTRY('r',         scan_FR,          exec_FR         ),
    ENTRY('S',         scan_FS,          exec_FS         ),
    ENTRY('s',         scan_FS,          exec_FS         ),
    ENTRY('U',         scan_case,        exec_FU         ),
    ENTRY('u',         scan_case,        exec_FU         ),
    ENTRY('Z',         scan_FZ,          NULL            ),
    ENTRY('z',         scan_FZ,          NULL            ),
    ENTRY('_',         scan_F_under,     exec_F_under    ),
    ENTRY('|',         NULL,             exec_F_else     ),
};
