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

View File

@ -59,35 +59,11 @@ struct qse_sed_c_t
enum 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_CMD_A = QSE_T('a'), /* append text */
QSE_SED_C_B, QSE_SED_CMD_I = QSE_T('i') /* insert text */
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
} type; } type;
/* TODO: change the data type to a shorter one to save space */ /* TODO: change the data type to a shorter one to save space */