interim commit while implementing qse_rex_t

This commit is contained in:
2009-11-26 07:32:20 +00:00
parent 782fa151de
commit 09720f3460
10 changed files with 692 additions and 302 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 287 2009-09-15 10:01:02Z hyunghwan.chung $
* $Id: err.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -138,18 +138,19 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
QSE_T("invalid character in CONVFMT"),
QSE_T("invalid character in OFMT"),
QSE_T("recursion too deep in the regular expression"),
QSE_T("a right parenthesis expected in the regular expression"),
QSE_T("a right bracket expected in the regular expression"),
QSE_T("a right brace expected in the regular expression"),
QSE_T("unbalanced parenthesis in the regular expression"),
QSE_T("invalid brace in the regular expression"),
QSE_T("a colon expected in the regular expression"),
QSE_T("invalid character range in the regular expression"),
QSE_T("invalid character class in the regular expression"),
QSE_T("invalid boundary range in the regular expression"),
QSE_T("unexpected end of the regular expression"),
QSE_T("garbage after the regular expression")
QSE_T("no regular expression compiled"),
QSE_T("recursion too deep in regular expression"),
QSE_T("right parenthesis expected in regular expression"),
QSE_T("right bracket expected in regular expression"),
QSE_T("right brace expected in regular expression"),
QSE_T("unbalanced parenthesis in regular expression"),
QSE_T("invalid brace in regular expression"),
QSE_T("colon expected in regular expression"),
QSE_T("invalid character range in regular expression"),
QSE_T("invalid character class in regular expression"),
QSE_T("invalid occurrence bound in regular expression"),
QSE_T("premature end of regular expression"),
QSE_T("garbage after regular expression")
};
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c 306 2009-11-22 13:58:53Z hyunghwan.chung $
* $Id: misc.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -1030,9 +1030,10 @@ qse_char_t* qse_awk_rtx_strxnfld (
#define QSE_AWK_REXERRTOERR(err) \
((err == QSE_REX_ENOERR)? QSE_AWK_ENOERR: \
(err == QSE_REX_ENOMEM)? QSE_AWK_ENOMEM: \
(err == QSE_REX_ENOCOMP)? QSE_AWK_EREXNOCOMP: \
(err == QSE_REX_ERECUR)? QSE_AWK_EREXRECUR: \
(err == QSE_REX_ERPAREN)? QSE_AWK_EREXRPAREN: \
(err == QSE_REX_ERBRACKET)? QSE_AWK_EREXRBRACKET: \
(err == QSE_REX_ERBRACK)? QSE_AWK_EREXRBRACK: \
(err == QSE_REX_ERBRACE)? QSE_AWK_EREXRBRACE: \
(err == QSE_REX_EUNBALPAREN)? QSE_AWK_EREXUNBALPAREN: \
(err == QSE_REX_EINVALBRACE)? QSE_AWK_EREXINVALBRACE: \
@ -1040,7 +1041,7 @@ qse_char_t* qse_awk_rtx_strxnfld (
(err == QSE_REX_ECRANGE)? QSE_AWK_EREXCRANGE: \
(err == QSE_REX_ECCLASS)? QSE_AWK_EREXCCLASS: \
(err == QSE_REX_EBOUND)? QSE_AWK_EREXBOUND: \
(err == QSE_REX_EEND)? QSE_AWK_EREXEND: \
(err == QSE_REX_EPREEND)? QSE_AWK_EREXPREEND: \
(err == QSE_REX_EGARBAGE)? QSE_AWK_EREXGARBAGE: \
QSE_AWK_EINTERN)

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c 306 2009-11-22 13:58:53Z hyunghwan.chung $
* $Id: rex.c 307 2009-11-25 13:32:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -206,9 +206,6 @@ static int build_atom_occ_range (builder_t* rex, atom_t* cmd);
static int next_char (builder_t* rex, int level);
static int add_code (builder_t* rex, void* data, qse_size_t len);
static qse_bool_t __begin_with (
const qse_char_t* str, qse_size_t len, const qse_char_t* what);
static const qse_byte_t* match_pattern (
matcher_t* matcher, const qse_byte_t* base, match_t* mat);
static const qse_byte_t* match_branch (
@ -677,7 +674,7 @@ static int build_atom (builder_t* builder)
if (builder->ptn.curc.type != CT_SPECIAL ||
builder->ptn.curc.value != QSE_T(']'))
{
builder->errnum = QSE_REX_ERBRACKET;
builder->errnum = QSE_REX_ERBRACK;
return -1;
}
@ -819,7 +816,7 @@ static int build_atom_cclass (builder_t* builder, qse_char_t* cc)
while (ccp->name != QSE_NULL)
{
if (__begin_with (builder->ptn.curp, len, ccp->name)) break;
if (qse_strxbeg (builder->ptn.curp, len, ccp->name) != QSE_NULL) break;
ccp++;
}
@ -855,7 +852,7 @@ static int build_atom_cclass (builder_t* builder, qse_char_t* cc)
#ifdef DEBUG_REX
DPUTS (QSE_T("build_atom_cclass: ] expected\n"));
#endif
builder->errnum = QSE_REX_ERBRACKET;
builder->errnum = QSE_REX_ERBRACK;
return -1;
}
@ -973,7 +970,7 @@ what if it is not in the raight format? convert it to ordinary characters?? */
do { \
if (builder->ptn.curp >= builder->ptn.end) \
{ \
builder->errnum = QSE_REX_EEND; \
builder->errnum = QSE_REX_EPREEND; \
return -1; \
} \
} while(0)
@ -1192,23 +1189,6 @@ static int add_code (builder_t* builder, void* data, qse_size_t len)
return 0;
}
static qse_bool_t __begin_with (
const qse_char_t* str, qse_size_t len, const qse_char_t* what)
{
const qse_char_t* end = str + len;
while (str < end)
{
if (*what == QSE_T('\0')) return QSE_TRUE;
if (*what != *str) return QSE_FALSE;
str++; what++;
}
if (*what == QSE_T('\0')) return QSE_TRUE;
return QSE_FALSE;
}
static const qse_byte_t* match_pattern (
matcher_t* matcher, const qse_byte_t* base, match_t* mat)
{

File diff suppressed because it is too large Load Diff