changed sed a litte

This commit is contained in:
hyung-hwan 2009-03-05 04:40:20 +00:00
parent fc2877524c
commit 25288e45ad
3 changed files with 13 additions and 39 deletions

View File

@ -36,7 +36,7 @@ enum qse_sed_errnum_t
QSE_SED_EA1PHB, /* address 1 prohibited */
QSE_SED_EA2PHB, /* address 2 prohibited */
QSE_SED_ENEWLN, /* a new line is expected */
QSE_SED_EBASLA /* \ is expected */
QSE_SED_EBSEXP /* \ is expected */
};
typedef struct qse_sed_t qse_sed_t;

View File

@ -213,7 +213,7 @@ static int command (qse_sed_t* sed)
* of a group. this way, all the commands in a group
* can be skipped. the branch target is set once a
* corresponding } is met. */
cmd->type = QSE_SED_C_JMP;
cmd->type = QSE_SED_CMD_B;
cmd->negfl = !cmd->negfl;
break;
@ -233,8 +233,8 @@ static int command (qse_sed_t* sed)
/* TODO: ... */
break;
case QSE_T('='):
cmd->type = QSE_SED_C_EQ;
case QSE_SED_CMD_EQ:
cmd->type = c;
if (cmd->a2.type != QSE_SED_A_NONE)
{
sed->errnum = QSE_SED_EA2PHB;
@ -242,21 +242,22 @@ static int command (qse_sed_t* sed)
}
break;
case QSE_T('a'):
cmd->type = QSE_SED_C_A;
case QSE_SED_CMD_A:
case QSE_SED_CMD_I:
cmd->type = c;
if (cmd->a2.type != QSE_SED_A_NONE)
{
sed->errnum = QSE_SED_EA2PHB;
return -1;
}
/* get the first non-space character */
c = NXTSC (sed);
while (ISSPACE(c)) c = NXTSC (sed);
if (c == QSE_CHAR_EOF)
{
/* expected \ after 'a' */
sed->errnum = QSE_SED_EBASLA;
sed->errnum = QSE_SED_EBSEXP;
return -1;
}
@ -291,9 +292,6 @@ static int command (qse_sed_t* sed)
case QSE_T('c'):
break;
case QSE_T('i'):
break;
case QSE_T('g'):
break;

View File

@ -59,35 +59,11 @@ struct qse_sed_c_t
enum
{
QSE_SED_C_JMP,
QSE_SED_CMD_B = QSE_T('b'), /* branch */
QSE_SED_CMD_EQ = QSE_T('='), /* print current line number */
QSE_SED_C_A, /* append text */
QSE_SED_C_B,
QSE_SED_C_C,
QSE_SED_C_CD,
QSE_SED_C_CN,
QSE_SED_C_CO,
QSE_SED_C_CP,
QSE_SED_C_D,
QSE_SED_C_E,
QSE_SED_C_EQ, /* print the current line number */
QSE_SED_C_F,
QSE_SED_C_G,
QSE_SED_C_CG,
QSE_SED_C_H,
QSE_SED_C_CH,
QSE_SED_C_I,
QSE_SED_C_L,
QSE_SED_C_N,
QSE_SED_C_P,
QSE_SED_C_Q,
QSE_SED_C_R,
QSE_SED_C_S,
QSE_SED_C_T,
QSE_SED_C_W,
QSE_SED_C_CW,
QSE_SED_C_Y,
QSE_SED_C_X
QSE_SED_CMD_A = QSE_T('a'), /* append text */
QSE_SED_CMD_I = QSE_T('i') /* insert text */
} type;
/* TODO: change the data type to a shorter one to save space */