*** empty log message ***
This commit is contained in:
parent
63a47ebb7c
commit
145c854513
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.46 2006-04-24 14:38:46 bacon Exp $
|
* $Id: awk.c,v 1.47 2006-04-24 15:34:52 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -95,10 +95,10 @@ int xp_awk_close (xp_awk_t* awk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: write a function to clear awk->parse data structure.
|
/* TODO: write a function to clear awk->parse data structure.
|
||||||
this would be need either as a separate function or as a part of xp_awk_clear...
|
this would be need either as a separate function or as a part of xp_awk_clear...
|
||||||
do i have to pass an option to xp_awk_clear to do this??? */
|
do i have to pass an option to xp_awk_clear to do this??? */
|
||||||
|
|
||||||
void xp_awk_clear (xp_awk_t* awk)
|
void xp_awk_clear (xp_awk_t* awk)
|
||||||
{
|
{
|
||||||
/* TODO: kill all associated run instances... */
|
/* TODO: kill all associated run instances... */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c,v 1.90 2006-04-24 11:36:12 bacon Exp $
|
* $Id: parse.c,v 1.91 2006-04-24 15:34:52 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -115,6 +115,7 @@ static xp_awk_nde_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top);
|
|||||||
static xp_awk_nde_t* __parse_statement (xp_awk_t* awk);
|
static xp_awk_nde_t* __parse_statement (xp_awk_t* awk);
|
||||||
static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk);
|
static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk);
|
||||||
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk);
|
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk);
|
||||||
|
static xp_awk_nde_t* __parse_assignment (xp_awk_t* awk);
|
||||||
|
|
||||||
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
|
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
|
||||||
|
|
||||||
@ -384,10 +385,16 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
if (__parse_begin(awk) == XP_NULL) return XP_NULL;
|
if (__parse_begin(awk) == XP_NULL) return XP_NULL;
|
||||||
}
|
}
|
||||||
else if (MATCH(awk, TOKEN_END))
|
else if (MATCH(awk,TOKEN_END))
|
||||||
{
|
{
|
||||||
if (__parse_end(awk) == XP_NULL) return XP_NULL;
|
if (__parse_end(awk) == XP_NULL) return XP_NULL;
|
||||||
}
|
}
|
||||||
|
else if (MATCH(awk,TOKEN_LBRACE))
|
||||||
|
{
|
||||||
|
if (__parse_patternless(awk) == XP_NULL) return XP_NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* TODO: process patterns and expressions */
|
/* TODO: process patterns and expressions */
|
||||||
/*
|
/*
|
||||||
expressions
|
expressions
|
||||||
@ -398,10 +405,20 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
|||||||
(pattern)
|
(pattern)
|
||||||
pattern, pattern
|
pattern, pattern
|
||||||
*/
|
*/
|
||||||
else
|
|
||||||
|
if (__parse_expression (awk) == XP_NULL) return XP_NULL;
|
||||||
|
if (MATCH(awk,TOKEN_LBRACE))
|
||||||
{
|
{
|
||||||
if (__parse_patternless(awk) == XP_NULL) return XP_NULL;
|
if (__parse_patternless(awk) == XP_NULL) return XP_NULL;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* { print $0; } */
|
||||||
|
/* TODO: XXXX */
|
||||||
|
xp_printf (XP_TEXT("BLOCKLESS NOT IMPLEMENTED....\n"));
|
||||||
|
PANIC (awk, XP_AWK_EINTERNAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return awk;
|
return awk;
|
||||||
}
|
}
|
||||||
@ -656,7 +673,7 @@ static xp_awk_nde_t* __parse_patternless (xp_awk_t* awk)
|
|||||||
nde = __parse_action (awk);
|
nde = __parse_action (awk);
|
||||||
if (nde == XP_NULL) return XP_NULL;
|
if (nde == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
chain = (xp_awk_chain_t*)xp_malloc(xp_sizeof(xp_awk_chain_t));
|
chain = (xp_awk_chain_t*) xp_malloc (xp_sizeof(xp_awk_chain_t));
|
||||||
if (chain == XP_NULL)
|
if (chain == XP_NULL)
|
||||||
{
|
{
|
||||||
xp_awk_clrpt (nde);
|
xp_awk_clrpt (nde);
|
||||||
@ -1042,6 +1059,26 @@ static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
|
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
|
||||||
|
{
|
||||||
|
xp_awk_nde_t* nde, * tmp;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
tmp = __parse_assignment(awk);
|
||||||
|
if (tmp == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
|
nde = tmp; break; /* TODO */
|
||||||
|
|
||||||
|
if (!match(awk, TOKEN_COMMA)) break;
|
||||||
|
if (__get_token(awk) == -1) return XP_NULL;
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
|
||||||
|
/* TODO: XP_AWK_NDE_GRP -> should i support i this way??? */
|
||||||
|
return nde;
|
||||||
|
}
|
||||||
|
|
||||||
|
static xp_awk_nde_t* __parse_assignment (xp_awk_t* awk)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* <expression> ::= <assignment> | <basic expression>
|
* <expression> ::= <assignment> | <basic expression>
|
||||||
@ -1088,7 +1125,7 @@ static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nde = (xp_awk_nde_ass_t*)xp_malloc(xp_sizeof(xp_awk_nde_ass_t));
|
nde = (xp_awk_nde_ass_t*) xp_malloc (xp_sizeof(xp_awk_nde_ass_t));
|
||||||
if (nde == XP_NULL)
|
if (nde == XP_NULL)
|
||||||
{
|
{
|
||||||
xp_awk_clrpt (x);
|
xp_awk_clrpt (x);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.72 2006-04-24 14:38:46 bacon Exp $
|
* $Id: run.c,v 1.73 2006-04-24 15:34:52 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -56,6 +56,8 @@ static int __run_nextfile_statement (xp_awk_run_t* run, xp_awk_nde_nextfile_t* n
|
|||||||
static xp_awk_val_t* __eval_expression (
|
static xp_awk_val_t* __eval_expression (
|
||||||
xp_awk_run_t* run, xp_awk_nde_t* nde);
|
xp_awk_run_t* run, xp_awk_nde_t* nde);
|
||||||
|
|
||||||
|
static xp_awk_val_t* __eval_group (xp_awk_run_t* run, xp_awk_nde_t* nde);
|
||||||
|
|
||||||
static xp_awk_val_t* __eval_assignment (
|
static xp_awk_val_t* __eval_assignment (
|
||||||
xp_awk_run_t* run, xp_awk_nde_t* nde);
|
xp_awk_run_t* run, xp_awk_nde_t* nde);
|
||||||
static xp_awk_val_t* __do_assignment (
|
static xp_awk_val_t* __do_assignment (
|
||||||
@ -467,8 +469,6 @@ static int __run_pattern_blocks (xp_awk_run_t* run)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde)
|
static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde)
|
||||||
{
|
{
|
||||||
xp_awk_nde_t* p;
|
xp_awk_nde_t* p;
|
||||||
@ -833,6 +833,7 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
/* the order of functions here should match the order
|
/* the order of functions here should match the order
|
||||||
* of node types declared in tree.h */
|
* of node types declared in tree.h */
|
||||||
|
__eval_group,
|
||||||
__eval_assignment,
|
__eval_assignment,
|
||||||
__eval_binary,
|
__eval_binary,
|
||||||
__eval_unary,
|
__eval_unary,
|
||||||
@ -860,6 +861,14 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
|||||||
return __eval_func[nde->type-XP_AWK_NDE_ASS] (run, nde);
|
return __eval_func[nde->type-XP_AWK_NDE_ASS] (run, nde);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xp_awk_val_t* __eval_group (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||||
|
{
|
||||||
|
/* NOT INIMPELMETED YET */
|
||||||
|
xp_printf (XP_TEXT("eval_group not implemented\n"));
|
||||||
|
PANIC (awk, XP_AWK_EINTERNAL);
|
||||||
|
return XP_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static xp_awk_val_t* __eval_assignment (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
static xp_awk_val_t* __eval_assignment (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||||
{
|
{
|
||||||
xp_awk_val_t* val, * res;
|
xp_awk_val_t* val, * res;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user