*** empty log message ***

This commit is contained in:
hyung-hwan 2006-07-18 15:28:26 +00:00
parent a70e9a0f76
commit 6df65679cd

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c,v 1.2 2006-07-17 14:27:09 bacon Exp $
* $Id: rex.c,v 1.3 2006-07-18 15:28:26 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -39,7 +39,6 @@ struct __code
#define PC_UBOUND(rex,base) (rex)->code[(base)].dc.ubound
#define PC_VALUE(rex,base) (rex)->code[(base)].cc
xp_awk_rex_t* xp_awk_rex_open (xp_awk_rex_t* rex)
{
if (rex == XP_NULL)
@ -58,11 +57,13 @@ void xp_awk_rex_close (xp_awk_rex_t* rex)
if (rex->__dynamic) xp_free (rex);
}
int xp_awk_rex_compile (const xp_awk_rex_t* rex, const xp_char_t* ptn)
int xp_awk_rex_compile (xp_awk_rex_t* rex, const xp_char_t* ptn)
{
const xp_char_t* p = ptn;
xp_char_t c;
rex->ptn = ptn;
while (*p != XP_T('\0'))
{
c = *p++; // TODO: backspace escaping...
@ -75,3 +76,78 @@ int xp_awk_rex_compile (const xp_awk_rex_t* rex, const xp_char_t* ptn)
return -1;
}
int __compile_expression (xp_awk_rex_t* rex)
{
if (__compile_branch (rex) == -1) return -1;
while (rex->curc == VBAR)
{
GET_NEXT_CHAR (rex);
branch_base = rex->code_size;
if (compie_branch(rex) == -1) return -1;
rex->code[branch_base]++;
rex->code[len_base] += xxxxx;
}
}
int __compile_branch (xp_awk_rex_t* rex)
{
while (1)
{
atom_base = rex->code_size;
n = compile_atom ();
if (n == -1) return -1;
if (n == 1) break;
c = rex->curc;
if (c == PLUS) /* + */
{
__apply_bound (1, MAX);
get_next_char ();
}
else if (c == STAR) /* * */
{
__apply_bound (0, MAX);
get_next_char ();
}
else if (c == QUEST) /* ? */
{
__apply_bound (0, 1);
get_next_char ();
}
else if (c == LBRACE) /* { */
{
if (__compile_bound(rex) == -1) return -1;
}
}
}
int __compile_atom (xp_awk_rex_t* rex)
{
xp_char_t c;
c = rex->curc;
if (c == LPAREN)
{
}
else
{
if (c == CARET)
else if (c == DOLLAR)
else if (c == PERIOD)
else if (c == LBRACKET)
else if (....)
}
return n;
}
int __compile_bound (xp_awk_rex_t* rex)
{
}