*** empty log message ***

This commit is contained in:
hyung-hwan 2006-09-28 06:58:10 +00:00
parent dadcf0c0f1
commit 5a8894fb13
8 changed files with 54 additions and 42 deletions

View File

@ -1,14 +1,9 @@
/*
* $Id: rex.c,v 1.31 2006-09-25 06:17:19 bacon Exp $
* $Id: rex.c,v 1.32 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
enum
{
CT_EOF,

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.209 2006-09-28 06:41:25 bacon Exp $
* $Id: run.c,v 1.210 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -2926,6 +2926,8 @@ static int __cmp_val (
static cmp_val_t func[] =
{
/* this table must be synchronized with
* the XP_AWK_VAL_XXX values in val.h */
__cmp_nil_nil, __cmp_nil_int, __cmp_nil_real, __cmp_nil_str,
__cmp_int_nil, __cmp_int_int, __cmp_int_real, __cmp_int_str,
__cmp_real_nil, __cmp_real_int, __cmp_real_real, __cmp_real_str,
@ -2935,53 +2937,64 @@ static int __cmp_val (
if (left->type == XP_AWK_VAL_MAP || right->type == XP_AWK_VAL_MAP)
{
/* a map can't be compared againt other values */
return -99; // TODO:
run->errnum = XP_AWK_EOPERAND;
return -99;
}
xp_assert (left->type >= XP_AWK_VAL_NIL &&
left->type <= XP_AWK_VAL_STR);
xp_assert (right->type >= XP_AWK_VAL_NIL &&
right->type <= XP_AWK_VAL_STR);
return func[left->type*4+right->type] (run, left, right);
}
static xp_awk_val_t* __eval_binop_eq (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) == 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n == 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_ne (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) != 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n != 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_gt (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) > 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n > 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_ge (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) >= 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n >= 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_lt (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) < 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n < 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_le (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
return (__cmp_val (run, left, right) <= 0)?
xp_awk_val_one: xp_awk_val_zero;
int n = __cmp_val (run, left, right);
if (n == -99) return XP_NULL;
return (n <= 0)? xp_awk_val_one: xp_awk_val_zero;
}
static xp_awk_val_t* __eval_binop_lshift (

View File

@ -1,13 +1,9 @@
/*
* $Id: str.c,v 1.6 2006-09-25 06:17:19 bacon Exp $
* $Id: str.c,v 1.7 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
xp_awk_str_t* xp_awk_str_open (
xp_awk_str_t* str, xp_size_t capa, xp_awk_t* awk)
{

View File

@ -1,13 +1,9 @@
/*
* $Id: tab.c,v 1.18 2006-09-25 06:17:19 bacon Exp $
* $Id: tab.c,v 1.19 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
xp_awk_tab_t* xp_awk_tab_open (xp_awk_tab_t* tab, xp_awk_t* awk)
{
if (tab == XP_NULL)

View File

@ -1,13 +1,9 @@
/*
* $Id: tree.c,v 1.75 2006-09-22 14:04:26 bacon Exp $
* $Id: tree.c,v 1.76 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
static const xp_char_t* __assop_str[] =
{
XP_T("="),

View File

@ -1,13 +1,9 @@
/*
* $Id: val.c,v 1.62 2006-09-27 14:11:32 bacon Exp $
* $Id: val.c,v 1.63 2006-09-28 06:56:30 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
static xp_char_t* __str_to_str (
xp_awk_run_t* run, const xp_char_t* str, xp_size_t str_len,
xp_bool_t clear_buf, xp_awk_str_t* buf, xp_size_t* len);

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h,v 1.41 2006-09-27 14:11:32 bacon Exp $
* $Id: val.h,v 1.42 2006-09-28 06:56:30 bacon Exp $
*/
#ifndef _XP_AWK_VAL_H_
@ -11,10 +11,14 @@
enum
{
/* the values between XP_AWK_VAL_NIL and XP_AWK_VAL_STR inclusive
* must be synchronized with an internal table of the __cmp_val
* function in run.c */
XP_AWK_VAL_NIL = 0,
XP_AWK_VAL_INT = 1,
XP_AWK_VAL_REAL = 2,
XP_AWK_VAL_STR = 3,
XP_AWK_VAL_REX = 4,
XP_AWK_VAL_MAP = 5,
XP_AWK_VAL_REF = 6

16
ase/test/awk/comp.awk Normal file
View File

@ -0,0 +1,16 @@
BEGIN {
print 1 == 1;
print 1 == 0;
print 1.0 == 1;
print 1.1 == 1;
print 1.0 != 1;
print 1.1 != 1;
print "abc" == "abc";
print "abc" != "abc";
a[10] = 2;
print a == 1;
}