*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-22 12:39:30 +00:00
parent 3d8c2c1cd6
commit 7adb9d1cbd
20 changed files with 723 additions and 722 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.130 2006-10-22 11:34:52 bacon Exp $ * $Id: awk.h,v 1.131 2006-10-22 12:39:29 bacon Exp $
*/ */
#ifndef _SSE_AWK_AWK_H_ #ifndef _SSE_AWK_AWK_H_
@ -141,8 +141,8 @@ enum sse_awk_option_t
/* allow undeclared variables */ /* allow undeclared variables */
SSE_AWK_IMPLICIT = (1 << 0), SSE_AWK_IMPLICIT = (1 << 0),
/* variable requires esselicit declaration */ /* variable requires explicit declaration */
SSE_AWK_ESSELICIT = (1 << 1), SSE_AWK_EXPLICIT = (1 << 1),
/* a function name should not coincide to be a variable name */ /* a function name should not coincide to be a variable name */
SSE_AWK_UNIQUE = (1 << 2), SSE_AWK_UNIQUE = (1 << 2),
@ -162,7 +162,7 @@ enum sse_awk_option_t
/* support string concatenation in tokenization. /* support string concatenation in tokenization.
* this option can change the behavior of a certain construct. * this option can change the behavior of a certain construct.
* getline < "abc" ".def" is treated as if it is getline < "abc.def" * getline < "abc" ".def" is treated as if it is getline < "abc.def"
* when this option is on. If this option is off, the same esseression * when this option is on. If this option is off, the same expression
* is treated as if it is (getline < "abc") ".def". */ * is treated as if it is (getline < "abc") ".def". */
SSE_AWK_STRCONCAT = (1 << 7), SSE_AWK_STRCONCAT = (1 << 7),
@ -179,7 +179,7 @@ enum sse_awk_option_t
SSE_AWK_STRINDEXONE = (1 << 11), SSE_AWK_STRINDEXONE = (1 << 11),
/* strip off leading and trailing spaces when splitting a record /* strip off leading and trailing spaces when splitting a record
* into fields with a regular esseression. * into fields with a regular expression.
* *
* Consider the following program. * Consider the following program.
* BEGIN { FS="[:[:space:]]+"; } * BEGIN { FS="[:[:space:]]+"; }
@ -229,24 +229,24 @@ enum ant_awk_errnum_t
SSE_AWK_ELXCHR, /* lexer came accross an wrong character */ SSE_AWK_ELXCHR, /* lexer came accross an wrong character */
SSE_AWK_ELXUNG, /* lexer failed to unget a character */ SSE_AWK_ELXUNG, /* lexer failed to unget a character */
SSE_AWK_EENDSRC, /* unesseected end of source */ SSE_AWK_EENDSRC, /* unexpected end of source */
SSE_AWK_EENDCOMMENT, /* unesseected end of a comment */ SSE_AWK_EENDCOMMENT, /* unexpected end of a comment */
SSE_AWK_EENDSTR, /* unesseected end of a string */ SSE_AWK_EENDSTR, /* unexpected end of a string */
SSE_AWK_EENDREX, /* unesseected end of a regular esseression */ SSE_AWK_EENDREX, /* unexpected end of a regular expression */
SSE_AWK_ELBRACE, /* left brace esseected */ SSE_AWK_ELBRACE, /* left brace expected */
SSE_AWK_ELPAREN, /* left parenthesis esseected */ SSE_AWK_ELPAREN, /* left parenthesis expected */
SSE_AWK_ERPAREN, /* right parenthesis esseected */ SSE_AWK_ERPAREN, /* right parenthesis expected */
SSE_AWK_ERBRACK, /* right bracket esseected */ SSE_AWK_ERBRACK, /* right bracket expected */
SSE_AWK_ECOMMA, /* comma esseected */ SSE_AWK_ECOMMA, /* comma expected */
SSE_AWK_ESEMICOLON, /* semicolon esseected */ SSE_AWK_ESEMICOLON, /* semicolon expected */
SSE_AWK_ECOLON, /* colon esseected */ SSE_AWK_ECOLON, /* colon expected */
SSE_AWK_EIN, /* keyword 'in' is esseected */ SSE_AWK_EIN, /* keyword 'in' is expected */
SSE_AWK_ENOTVAR, /* not a variable name after 'in' */ SSE_AWK_ENOTVAR, /* not a variable name after 'in' */
SSE_AWK_EESSERESSION, /* esseression esseected */ SSE_AWK_EEXPRESSION, /* expression expected */
SSE_AWK_EWHILE, /* keyword 'while' is esseected */ SSE_AWK_EWHILE, /* keyword 'while' is expected */
SSE_AWK_EASSIGNMENT, /* assignment statement esseected */ SSE_AWK_EASSIGNMENT, /* assignment statement expected */
SSE_AWK_EIDENT, /* identifier esseected */ SSE_AWK_EIDENT, /* identifier expected */
SSE_AWK_EBEGINBLOCK, /* BEGIN requires an action block */ SSE_AWK_EBEGINBLOCK, /* BEGIN requires an action block */
SSE_AWK_EENDBLOCK, /* END requires an action block */ SSE_AWK_EENDBLOCK, /* END requires an action block */
SSE_AWK_EDUPBEGIN, /* duplicate BEGIN */ SSE_AWK_EDUPBEGIN, /* duplicate BEGIN */
@ -266,7 +266,7 @@ enum ant_awk_errnum_t
SSE_AWK_ECONTINUE, /* continue outside a loop */ SSE_AWK_ECONTINUE, /* continue outside a loop */
SSE_AWK_ENEXT, /* next illegal in BEGIN or END block */ SSE_AWK_ENEXT, /* next illegal in BEGIN or END block */
SSE_AWK_ENEXTFILE, /* nextfile illegal in BEGIN or END block */ SSE_AWK_ENEXTFILE, /* nextfile illegal in BEGIN or END block */
SSE_AWK_EGETLINE, /* getline esseected */ SSE_AWK_EGETLINE, /* getline expected */
/* run time error */ /* run time error */
SSE_AWK_EDIVBYZERO, /* divide by zero */ SSE_AWK_EDIVBYZERO, /* divide by zero */
@ -291,15 +291,15 @@ enum ant_awk_errnum_t
SSE_AWK_EIOHANDLER, /* io handler has returned an error */ SSE_AWK_EIOHANDLER, /* io handler has returned an error */
SSE_AWK_EINTERNAL, /* internal error */ SSE_AWK_EINTERNAL, /* internal error */
/* regular esseression error */ /* regular expression error */
SSE_AWK_EREXRPAREN, /* a right parenthesis is esseected */ SSE_AWK_EREXRPAREN, /* a right parenthesis is expected */
SSE_AWK_EREXRBRACKET, /* a right bracket is esseected */ SSE_AWK_EREXRBRACKET, /* a right bracket is expected */
SSE_AWK_EREXRBRACE, /* a right brace is esseected */ SSE_AWK_EREXRBRACE, /* a right brace is expected */
SSE_AWK_EREXCOLON, /* a colon is esseected */ SSE_AWK_EREXCOLON, /* a colon is expected */
SSE_AWK_EREXCRANGE, /* invalid character range */ SSE_AWK_EREXCRANGE, /* invalid character range */
SSE_AWK_EREXCCLASS, /* invalid character class */ SSE_AWK_EREXCCLASS, /* invalid character class */
SSE_AWK_EREXBRANGE, /* invalid boundary range */ SSE_AWK_EREXBRANGE, /* invalid boundary range */
SSE_AWK_EREXEND, /* unesseected end of the pattern */ SSE_AWK_EREXEND, /* unexpected end of the pattern */
SSE_AWK_EREXGARBAGE /* garbage after the pattern */ SSE_AWK_EREXGARBAGE /* garbage after the pattern */
}; };
@ -371,7 +371,7 @@ void sse_awk_setrunerrnum (sse_awk_run_t* run, int errnum);
int sse_awk_clrrec (sse_awk_run_t* run, sse_bool_t skip_inrec_line); int sse_awk_clrrec (sse_awk_run_t* run, sse_bool_t skip_inrec_line);
int sse_awk_setrec (sse_awk_run_t* run, sse_size_t idx, const sse_char_t* str, sse_size_t len); int sse_awk_setrec (sse_awk_run_t* run, sse_size_t idx, const sse_char_t* str, sse_size_t len);
/* utility functions esseorted by awk.h */ /* utility functions exported by awk.h */
sse_long_t sse_awk_strxtolong ( sse_long_t sse_awk_strxtolong (
sse_awk_t* awk, const sse_char_t* str, sse_size_t len, sse_awk_t* awk, const sse_char_t* str, sse_size_t len,
int base, const sse_char_t** endptr); int base, const sse_char_t** endptr);
@ -383,7 +383,7 @@ sse_size_t sse_awk_longtostr (
sse_long_t value, int radix, const sse_char_t* prefix, sse_long_t value, int radix, const sse_char_t* prefix,
sse_char_t* buf, sse_size_t size); sse_char_t* buf, sse_size_t size);
/* string functions esseorted by awk.h */ /* string functions exported by awk.h */
sse_char_t* sse_awk_strdup ( sse_char_t* sse_awk_strdup (
sse_awk_t* awk, const sse_char_t* str); sse_awk_t* awk, const sse_char_t* str);
sse_char_t* sse_awk_strxdup ( sse_char_t* sse_awk_strxdup (

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk_i.h,v 1.69 2006-10-22 11:34:52 bacon Exp $ * $Id: awk_i.h,v 1.70 2006-10-22 12:39:29 bacon Exp $
*/ */
#ifndef _SSE_AWK_AWKI_H_ #ifndef _SSE_AWK_AWKI_H_
@ -22,10 +22,10 @@ typedef struct sse_awk_tree_t sse_awk_tree_t;
#include <sse/awk/misc.h> #include <sse/awk/misc.h>
#ifdef NDEBUG #ifdef NDEBUG
#define sse_awk_assert(awk,esser) ((void)0) #define sse_awk_assert(awk,expr) ((void)0)
#else #else
#define sse_awk_assert(awk,esser) (void)((esser) || \ #define sse_awk_assert(awk,expr) (void)((expr) || \
(sse_awk_abort(awk, SSE_TEXT(#esser), SSE_TEXT(__FILE__), __LINE__), 0)) (sse_awk_abort(awk, SSE_TEXT(#expr), SSE_TEXT(__FILE__), __LINE__), 0))
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.43 2006-10-22 11:34:53 bacon Exp $ * $Id: err.c,v 1.44 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -42,24 +42,24 @@ const sse_char_t* sse_awk_geterrstr (int errnum)
SSE_T("invalid character"), SSE_T("invalid character"),
SSE_T("cannot unget character"), SSE_T("cannot unget character"),
SSE_T("unesseected end of source"), SSE_T("unexpected end of source"),
SSE_T("unesseected end of a comment"), SSE_T("unexpected end of a comment"),
SSE_T("unesseected end of a string"), SSE_T("unexpected end of a string"),
SSE_T("unesseected end of a regular esseression"), SSE_T("unexpected end of a regular expression"),
SSE_T("left brace esseected"), SSE_T("left brace expected"),
SSE_T("left parenthesis esseected"), SSE_T("left parenthesis expected"),
SSE_T("right parenthesis esseected"), SSE_T("right parenthesis expected"),
SSE_T("right bracket esseected"), SSE_T("right bracket expected"),
SSE_T("comma esseected"), SSE_T("comma expected"),
SSE_T("semicolon esseected"), SSE_T("semicolon expected"),
SSE_T("colon esseected"), SSE_T("colon expected"),
SSE_T("keyword 'in' esseected"), SSE_T("keyword 'in' expected"),
SSE_T("not a variable after 'in'"), SSE_T("not a variable after 'in'"),
SSE_T("esseression esseected"), SSE_T("expression expected"),
SSE_T("keyword 'while' esseected"), SSE_T("keyword 'while' expected"),
SSE_T("assignment statement esseected"), SSE_T("assignment statement expected"),
SSE_T("identifier esseected"), SSE_T("identifier expected"),
SSE_T("BEGIN requires an action block"), SSE_T("BEGIN requires an action block"),
SSE_T("END requires an action block"), SSE_T("END requires an action block"),
SSE_T("duplicate BEGIN"), SSE_T("duplicate BEGIN"),
@ -79,7 +79,7 @@ const sse_char_t* sse_awk_geterrstr (int errnum)
SSE_T("continue outside a loop"), SSE_T("continue outside a loop"),
SSE_T("next illegal in BEGIN or END block"), SSE_T("next illegal in BEGIN or END block"),
SSE_T("nextfile illegal in BEGIN or END block"), SSE_T("nextfile illegal in BEGIN or END block"),
SSE_T("getline esseected"), SSE_T("getline expected"),
SSE_T("divide by zero"), SSE_T("divide by zero"),
SSE_T("invalid operand"), SSE_T("invalid operand"),
@ -103,15 +103,15 @@ const sse_char_t* sse_awk_geterrstr (int errnum)
SSE_T("io handler has returned an error"), SSE_T("io handler has returned an error"),
SSE_T("internal error that should never have happened"), SSE_T("internal error that should never have happened"),
SSE_T("a right parenthesis is esseected in the regular esseression"), SSE_T("a right parenthesis is expected in the regular expression"),
SSE_T("a right bracket is esseected in the regular esseression"), SSE_T("a right bracket is expected in the regular expression"),
SSE_T("a right brace is esseected in the regular esseression"), SSE_T("a right brace is expected in the regular expression"),
SSE_T("a colon is esseected in the regular esseression"), SSE_T("a colon is expected in the regular expression"),
SSE_T("invalid character range in the regular esseression"), SSE_T("invalid character range in the regular expression"),
SSE_T("invalid character class in the regular esseression"), SSE_T("invalid character class in the regular expression"),
SSE_T("invalid boundary range in the regular esseression"), SSE_T("invalid boundary range in the regular expression"),
SSE_T("unesseected end of the regular esseression"), SSE_T("unexpected end of the regular expression"),
SSE_T("garbage after the regular esseression") SSE_T("garbage after the regular expression")
}; };
if (errnum >= 0 && errnum < sse_countof(__errstr)) if (errnum >= 0 && errnum < sse_countof(__errstr))

View File

@ -1,5 +1,5 @@
/* /*
* $Id: func.c,v 1.66 2006-10-22 11:34:53 bacon Exp $ * $Id: func.c,v 1.67 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -175,7 +175,7 @@ static int __bfn_close (sse_awk_run_t* run)
/* getline or print doesn't allow an emptry for the /* getline or print doesn't allow an emptry for the
* input or output file name. so close should not allow * input or output file name. so close should not allow
* it either. * it either.
* another reason for this is if close is called esselicitly * another reason for this is if close is called explicitly
* with an empty string, it may close the console that uses * with an empty string, it may close the console that uses
* an empty string for its identification because closeextio * an empty string for its identification because closeextio
* closes any extios that match the name given unlike * closes any extios that match the name given unlike

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.c,v 1.13 2006-10-22 11:40:51 bacon Exp $ * $Id: jni.c,v 1.14 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/jni.h> #include <sse/awk/jni.h>
@ -60,7 +60,7 @@ static void __awk_free (void* ptr, void* custom_data)
free (ptr); free (ptr);
} }
JNIESSEORT void JNICALL Java_sse_awk_Awk_open (JNIEnv* env, jobject obj) JNIEXPORT void JNICALL Java_sse_awk_Awk_open (JNIEnv* env, jobject obj)
{ {
jclass class; jclass class;
jfieldID fid; jfieldID fid;
@ -117,7 +117,7 @@ JNIESSEORT void JNICALL Java_sse_awk_Awk_open (JNIEnv* env, jobject obj)
(*env)->SetLongField (env, obj, fid, (jlong)awk); (*env)->SetLongField (env, obj, fid, (jlong)awk);
opt = SSE_AWK_ESSELICIT | SSE_AWK_UNIQUE | SSE_AWK_DBLSLASHES | opt = SSE_AWK_EXPLICIT | SSE_AWK_UNIQUE | SSE_AWK_DBLSLASHES |
SSE_AWK_SHADING | SSE_AWK_IMPLICIT | SSE_AWK_SHIFT | SSE_AWK_SHADING | SSE_AWK_IMPLICIT | SSE_AWK_SHIFT |
SSE_AWK_EXTIO | SSE_AWK_BLOCKLESS; SSE_AWK_EXTIO | SSE_AWK_BLOCKLESS;
sse_awk_setopt (awk, opt); sse_awk_setopt (awk, opt);
@ -125,7 +125,7 @@ JNIESSEORT void JNICALL Java_sse_awk_Awk_open (JNIEnv* env, jobject obj)
printf ("__awk(native) done => %u, 0x%X\n", awk, awk); printf ("__awk(native) done => %u, 0x%X\n", awk, awk);
} }
JNIESSEORT void JNICALL Java_sse_awk_Awk_close (JNIEnv* env, jobject obj) JNIEXPORT void JNICALL Java_sse_awk_Awk_close (JNIEnv* env, jobject obj)
{ {
jclass class; jclass class;
jfieldID fid; jfieldID fid;
@ -141,7 +141,7 @@ JNIESSEORT void JNICALL Java_sse_awk_Awk_close (JNIEnv* env, jobject obj)
printf ("close (native) done\n"); printf ("close (native) done\n");
} }
JNIESSEORT void JNICALL Java_sse_awk_Awk_parse (JNIEnv* env, jobject obj) JNIEXPORT void JNICALL Java_sse_awk_Awk_parse (JNIEnv* env, jobject obj)
{ {
jclass class; jclass class;
jfieldID fid; jfieldID fid;
@ -176,7 +176,7 @@ printf ("parse error -> line [%d] %S\n", sse_awk_getsrcline(awk), sse_awk_geterr
} }
} }
JNIESSEORT void JNICALL Java_sse_awk_Awk_run (JNIEnv* env, jobject obj) JNIEXPORT void JNICALL Java_sse_awk_Awk_run (JNIEnv* env, jobject obj)
{ {
jclass class; jclass class;
jfieldID fid; jfieldID fid;
@ -211,14 +211,14 @@ JNIESSEORT void JNICALL Java_sse_awk_Awk_run (JNIEnv* env, jobject obj)
} }
} }
JNIESSEORT void JNICALL Java_sse_awk_Awk_set_1extio ( JNIEXPORT void JNICALL Java_sse_awk_Awk_set_1extio (
JNIEnv* env, jobject obj, jlong extio, jobject handle) JNIEnv* env, jobject obj, jlong extio, jobject handle)
{ {
sse_awk_extio_t* epa = (sse_awk_extio_t*)extio; sse_awk_extio_t* epa = (sse_awk_extio_t*)extio;
epa->handle = (void*)handle; epa->handle = (void*)handle;
} }
JNIESSEORT jobject JNICALL Java_sse_awk_Awk_get_1extio ( JNIEXPORT jobject JNICALL Java_sse_awk_Awk_get_1extio (
JNIEnv* env, jobject obj, jlong extio) JNIEnv* env, jobject obj, jlong extio)
{ {
sse_awk_extio_t* epa = (sse_awk_extio_t*)extio; sse_awk_extio_t* epa = (sse_awk_extio_t*)extio;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.h,v 1.5 2006-10-22 11:40:51 bacon Exp $ * $Id: jni.h,v 1.6 2006-10-22 12:39:29 bacon Exp $
*/ */
#ifndef _SSE_AWK_JNI_H_ #ifndef _SSE_AWK_JNI_H_
@ -11,10 +11,10 @@
extern "C" { extern "C" {
#endif #endif
JNIESSEORT void JNICALL Java_sse_awk_Awk_open (JNIEnv*, jobject); JNIEXPORT void JNICALL Java_sse_awk_Awk_open (JNIEnv*, jobject);
JNIESSEORT void JNICALL Java_sse_awk_Awk_close (JNIEnv*, jobject); JNIEXPORT void JNICALL Java_sse_awk_Awk_close (JNIEnv*, jobject);
JNIESSEORT void JNICALL Java_sse_awk_Awk_parse (JNIEnv*, jobject); JNIEXPORT void JNICALL Java_sse_awk_Awk_parse (JNIEnv*, jobject);
JNIESSEORT void JNICALL Java_sse_awk_Awk_run (JNIEnv*, jobject); JNIEXPORT void JNICALL Java_sse_awk_Awk_run (JNIEnv*, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: misc.c,v 1.29 2006-10-22 11:34:53 bacon Exp $ * $Id: misc.c,v 1.30 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -135,16 +135,16 @@ sse_long_t sse_awk_strxtolong (
* notice appear in all copies. The University of California * notice appear in all copies. The University of California
* makes no representations about the suitability of this * makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without * software for any purpose. It is provided "as is" without
* esseress or implied warranty. * express or implied warranty.
*/ */
#define MAX_ESSEONENT 511 #define MAX_EXPONENT 511
sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str) sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str)
{ {
/* /*
* Table giving binary powers of 10. Entry is 10^2^i. * Table giving binary powers of 10. Entry is 10^2^i.
* Used to convert decimal esseonents into floating-point numbers. * Used to convert decimal exponents into floating-point numbers.
*/ */
static sse_real_t powers_of_10[] = static sse_real_t powers_of_10[] =
{ {
@ -152,25 +152,25 @@ sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str)
1.0e32, 1.0e64, 1.0e128, 1.0e256 1.0e32, 1.0e64, 1.0e128, 1.0e256
}; };
sse_real_t fraction, dbl_esse, * d; sse_real_t fraction, dbl_exp, * d;
const sse_char_t* p; const sse_char_t* p;
sse_cint_t c; sse_cint_t c;
int esse = 0; /* Esseonent read from "EX" field */ int exp = 0; /* Esseonent read from "EX" field */
/* /*
* Esseonent that derives from the fractional part. Under normal * Esseonent that derives from the fractional part. Under normal
* circumstatnces, it is the negative of the number of digits in F. * circumstatnces, it is the negative of the number of digits in F.
* However, if I is very long, the last digits of I get dropped * However, if I is very long, the last digits of I get dropped
* (otherwise a long I with a large negative esseonent could cause an * (otherwise a long I with a large negative exponent could cause an
* unnecessary overflow on I alone). In this case, frac_esse is * unnecessary overflow on I alone). In this case, frac_exp is
* incremented one for each dropped digit. * incremented one for each dropped digit.
*/ */
int frac_esse; int frac_exp;
int mant_size; /* Number of digits in mantissa. */ int mant_size; /* Number of digits in mantissa. */
int dec_pt; /* Number of mantissa digits BEFORE decimal point */ int dec_pt; /* Number of mantissa digits BEFORE decimal point */
const sse_char_t *pesse; /* Temporarily holds location of esseonent in string */ const sse_char_t *pexp; /* Temporarily holds location of exponent in string */
int negative = 0, esse_negative = 0; int negative = 0, exp_negative = 0;
p = str; p = str;
@ -209,7 +209,7 @@ sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str)
* If the mantissa has more than 18 digits, ignore the extras, since * If the mantissa has more than 18 digits, ignore the extras, since
* they can't affect the value anyway. * they can't affect the value anyway.
*/ */
pesse = p; pexp = p;
p -= mant_size; p -= mant_size;
if (dec_pt < 0) if (dec_pt < 0)
{ {
@ -222,19 +222,19 @@ sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str)
if (mant_size > 18) if (mant_size > 18)
{ {
frac_esse = dec_pt - 18; frac_exp = dec_pt - 18;
mant_size = 18; mant_size = 18;
} }
else else
{ {
frac_esse = dec_pt - mant_size; frac_exp = dec_pt - mant_size;
} }
if (mant_size == 0) if (mant_size == 0)
{ {
fraction = 0.0; fraction = 0.0;
/*p = str;*/ /*p = str;*/
p = pesse; p = pexp;
goto done; goto done;
} }
else else
@ -266,62 +266,62 @@ sse_real_t sse_awk_strtoreal (sse_awk_t* awk, const sse_char_t* str)
fraction = (1.0e9 * frac1) + frac2; fraction = (1.0e9 * frac1) + frac2;
} }
/* Skim off the esseonent */ /* Skim off the exponent */
p = pesse; p = pexp;
if ((*p == SSE_T('E')) || (*p == SSE_T('e'))) if ((*p == SSE_T('E')) || (*p == SSE_T('e')))
{ {
p++; p++;
if (*p == SSE_T('-')) if (*p == SSE_T('-'))
{ {
esse_negative = 1; exp_negative = 1;
p++; p++;
} }
else else
{ {
if (*p == SSE_T('+')) p++; if (*p == SSE_T('+')) p++;
esse_negative = 0; exp_negative = 0;
} }
if (!SSE_AWK_ISDIGIT (awk, *p)) if (!SSE_AWK_ISDIGIT (awk, *p))
{ {
/* p = pesse; */ /* p = pexp; */
/* goto done; */ /* goto done; */
goto no_esse; goto no_exp;
} }
while (SSE_AWK_ISDIGIT (awk, *p)) while (SSE_AWK_ISDIGIT (awk, *p))
{ {
esse = esse * 10 + (*p - SSE_T('0')); exp = exp * 10 + (*p - SSE_T('0'));
p++; p++;
} }
} }
no_esse: no_exp:
if (esse_negative) esse = frac_esse - esse; if (exp_negative) exp = frac_exp - exp;
else esse = frac_esse + esse; else exp = frac_exp + exp;
/* /*
* Generate a floating-point number that represents the esseonent. * Generate a floating-point number that represents the exponent.
* Do this by processing the esseonent one bit at a time to combine * Do this by processing the exponent one bit at a time to combine
* many powers of 2 of 10. Then combine the esseonent with the * many powers of 2 of 10. Then combine the exponent with the
* fraction. * fraction.
*/ */
if (esse < 0) if (exp < 0)
{ {
esse_negative = 1; exp_negative = 1;
esse = -esse; exp = -exp;
} }
else esse_negative = 0; else exp_negative = 0;
if (esse > MAX_ESSEONENT) esse = MAX_ESSEONENT; if (exp > MAX_EXPONENT) exp = MAX_EXPONENT;
dbl_esse = 1.0; dbl_exp = 1.0;
for (d = powers_of_10; esse != 0; esse >>= 1, d++) for (d = powers_of_10; exp != 0; exp >>= 1, d++)
{ {
if (esse & 01) dbl_esse *= *d; if (exp & 01) dbl_exp *= *d;
} }
if (esse_negative) fraction /= dbl_esse; if (exp_negative) fraction /= dbl_exp;
else fraction *= dbl_esse; else fraction *= dbl_exp;
done: done:
return (negative)? -fraction: fraction; return (negative)? -fraction: fraction;
@ -333,7 +333,7 @@ sse_real_t sse_awk_strxtoreal (
{ {
/* /*
* Table giving binary powers of 10. Entry is 10^2^i. * Table giving binary powers of 10. Entry is 10^2^i.
* Used to convert decimal esseonents into floating-point numbers. * Used to convert decimal exponents into floating-point numbers.
*/ */
static sse_real_t powers_of_10[] = static sse_real_t powers_of_10[] =
{ {
@ -341,25 +341,25 @@ sse_real_t sse_awk_strxtoreal (
1.0e32, 1.0e64, 1.0e128, 1.0e256 1.0e32, 1.0e64, 1.0e128, 1.0e256
}; };
sse_real_t fraction, dbl_esse, * d; sse_real_t fraction, dbl_exp, * d;
const sse_char_t* p, * end; const sse_char_t* p, * end;
sse_cint_t c; sse_cint_t c;
int esse = 0; /* Esseonent read from "EX" field */ int exp = 0; /* Esseonent read from "EX" field */
/* /*
* Esseonent that derives from the fractional part. Under normal * Esseonent that derives from the fractional part. Under normal
* circumstatnces, it is the negative of the number of digits in F. * circumstatnces, it is the negative of the number of digits in F.
* However, if I is very long, the last digits of I get dropped * However, if I is very long, the last digits of I get dropped
* (otherwise a long I with a large negative esseonent could cause an * (otherwise a long I with a large negative exponent could cause an
* unnecessary overflow on I alone). In this case, frac_esse is * unnecessary overflow on I alone). In this case, frac_exp is
* incremented one for each dropped digit. * incremented one for each dropped digit.
*/ */
int frac_esse; int frac_exp;
int mant_size; /* Number of digits in mantissa. */ int mant_size; /* Number of digits in mantissa. */
int dec_pt; /* Number of mantissa digits BEFORE decimal point */ int dec_pt; /* Number of mantissa digits BEFORE decimal point */
const sse_char_t *pesse; /* Temporarily holds location of esseonent in string */ const sse_char_t *pexp; /* Temporarily holds location of exponent in string */
int negative = 0, esse_negative = 0; int negative = 0, exp_negative = 0;
p = str; p = str;
end = str + len; end = str + len;
@ -400,7 +400,7 @@ sse_real_t sse_awk_strxtoreal (
* If the mantissa has more than 18 digits, ignore the extras, since * If the mantissa has more than 18 digits, ignore the extras, since
* they can't affect the value anyway. * they can't affect the value anyway.
*/ */
pesse = p; pexp = p;
p -= mant_size; p -= mant_size;
if (dec_pt < 0) if (dec_pt < 0)
{ {
@ -413,19 +413,19 @@ sse_real_t sse_awk_strxtoreal (
if (mant_size > 18) /* TODO: is 18 correct for sse_real_t??? */ if (mant_size > 18) /* TODO: is 18 correct for sse_real_t??? */
{ {
frac_esse = dec_pt - 18; frac_exp = dec_pt - 18;
mant_size = 18; mant_size = 18;
} }
else else
{ {
frac_esse = dec_pt - mant_size; frac_exp = dec_pt - mant_size;
} }
if (mant_size == 0) if (mant_size == 0)
{ {
fraction = 0.0; fraction = 0.0;
/*p = str;*/ /*p = str;*/
p = pesse; p = pexp;
goto done; goto done;
} }
else else
@ -458,8 +458,8 @@ sse_real_t sse_awk_strxtoreal (
fraction = (1.0e9 * frac1) + frac2; fraction = (1.0e9 * frac1) + frac2;
} }
/* Skim off the esseonent */ /* Skim off the exponent */
p = pesse; p = pexp;
if (p < end && (*p == SSE_T('E') || *p == SSE_T('e'))) if (p < end && (*p == SSE_T('E') || *p == SSE_T('e')))
{ {
p++; p++;
@ -468,59 +468,59 @@ sse_real_t sse_awk_strxtoreal (
{ {
if (*p == SSE_T('-')) if (*p == SSE_T('-'))
{ {
esse_negative = 1; exp_negative = 1;
p++; p++;
} }
else else
{ {
if (*p == SSE_T('+')) p++; if (*p == SSE_T('+')) p++;
esse_negative = 0; exp_negative = 0;
} }
} }
else esse_negative = 0; else exp_negative = 0;
if (!(p < end && SSE_AWK_ISDIGIT (awk, *p))) if (!(p < end && SSE_AWK_ISDIGIT (awk, *p)))
{ {
/*p = pesse;*/ /*p = pexp;*/
/*goto done;*/ /*goto done;*/
goto no_esse; goto no_exp;
} }
while (p < end && SSE_AWK_ISDIGIT (awk, *p)) while (p < end && SSE_AWK_ISDIGIT (awk, *p))
{ {
esse = esse * 10 + (*p - SSE_T('0')); exp = exp * 10 + (*p - SSE_T('0'));
p++; p++;
} }
} }
no_esse: no_exp:
if (esse_negative) esse = frac_esse - esse; if (exp_negative) exp = frac_exp - exp;
else esse = frac_esse + esse; else exp = frac_exp + exp;
/* /*
* Generate a floating-point number that represents the esseonent. * Generate a floating-point number that represents the exponent.
* Do this by processing the esseonent one bit at a time to combine * Do this by processing the exponent one bit at a time to combine
* many powers of 2 of 10. Then combine the esseonent with the * many powers of 2 of 10. Then combine the exponent with the
* fraction. * fraction.
*/ */
if (esse < 0) if (exp < 0)
{ {
esse_negative = 1; exp_negative = 1;
esse = -esse; exp = -exp;
} }
else esse_negative = 0; else exp_negative = 0;
if (esse > MAX_ESSEONENT) esse = MAX_ESSEONENT; if (exp > MAX_EXPONENT) exp = MAX_EXPONENT;
dbl_esse = 1.0; dbl_exp = 1.0;
for (d = powers_of_10; esse != 0; esse >>= 1, d++) for (d = powers_of_10; exp != 0; exp >>= 1, d++)
{ {
if (esse & 01) dbl_esse *= *d; if (exp & 01) dbl_exp *= *d;
} }
if (esse_negative) fraction /= dbl_esse; if (exp_negative) fraction /= dbl_exp;
else fraction *= dbl_esse; else fraction *= dbl_exp;
done: done:
if (endptr != SSE_NULL) *endptr = p; if (endptr != SSE_NULL) *endptr = p;
@ -1061,11 +1061,11 @@ exit_loop:
} }
int sse_awk_abort (sse_awk_t* awk, int sse_awk_abort (sse_awk_t* awk,
const sse_char_t* esser, const sse_char_t* file, int line) const sse_char_t* expr, const sse_char_t* file, int line)
{ {
awk->syscas.dprintf ( awk->syscas.dprintf (
SSE_T("ASSERTION FAILURE AT FILE %s, LINE %d\n%s\n"), SSE_T("ASSERTION FAILURE AT FILE %s, LINE %d\n%s\n"),
file, line, esser); file, line, expr);
awk->syscas.abort (); awk->syscas.abort ();
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: misc.h,v 1.4 2006-10-22 11:34:53 bacon Exp $ * $Id: misc.h,v 1.5 2006-10-22 12:39:29 bacon Exp $
*/ */
#ifndef _SSE_AWK_MISC_H_ #ifndef _SSE_AWK_MISC_H_
@ -39,7 +39,7 @@ sse_char_t* sse_awk_strxntokbyrex (
void* rex, sse_char_t** tok, sse_size_t* tok_len, int* errnum); void* rex, sse_char_t** tok, sse_size_t* tok_len, int* errnum);
int sse_awk_abort (sse_awk_t* awk, int sse_awk_abort (sse_awk_t* awk,
const sse_char_t* esser, const sse_char_t* file, int line); const sse_char_t* expr, const sse_char_t* file, int line);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.192 2006-10-22 11:34:53 bacon Exp $ * $Id: parse.c,v 1.193 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -17,7 +17,7 @@ enum
TOKEN_MUL_ASSIGN, TOKEN_MUL_ASSIGN,
TOKEN_DIV_ASSIGN, TOKEN_DIV_ASSIGN,
TOKEN_MOD_ASSIGN, TOKEN_MOD_ASSIGN,
TOKEN_ESSE_ASSIGN, TOKEN_EXP_ASSIGN,
TOKEN_EQ, TOKEN_EQ,
TOKEN_NE, TOKEN_NE,
@ -44,7 +44,7 @@ enum
TOKEN_RSHIFT, TOKEN_RSHIFT,
TOKEN_LSHIFT, TOKEN_LSHIFT,
TOKEN_IN, TOKEN_IN,
TOKEN_ESSE, TOKEN_EXP,
TOKEN_LPAREN, TOKEN_LPAREN,
TOKEN_RPAREN, TOKEN_RPAREN,
@ -136,11 +136,11 @@ static sse_awk_chain_t* __parse_pattern_block (
static sse_awk_nde_t* __parse_block (sse_awk_t* awk, sse_bool_t is_top); static sse_awk_nde_t* __parse_block (sse_awk_t* awk, sse_bool_t is_top);
static sse_awk_nde_t* __parse_statement (sse_awk_t* awk); static sse_awk_nde_t* __parse_statement (sse_awk_t* awk);
static sse_awk_nde_t* __parse_statement_nb (sse_awk_t* awk); static sse_awk_nde_t* __parse_statement_nb (sse_awk_t* awk);
static sse_awk_nde_t* __parse_esseression (sse_awk_t* awk); static sse_awk_nde_t* __parse_expression (sse_awk_t* awk);
static sse_awk_nde_t* __parse_basic_esser (sse_awk_t* awk); static sse_awk_nde_t* __parse_basic_expr (sse_awk_t* awk);
static sse_awk_nde_t* __parse_binary_esser ( static sse_awk_nde_t* __parse_binary_expr (
sse_awk_t* awk, const __binmap_t* binmap, sse_awk_t* awk, const __binmap_t* binmap,
sse_awk_nde_t*(*next_level_func)(sse_awk_t*)); sse_awk_nde_t*(*next_level_func)(sse_awk_t*));
@ -224,10 +224,10 @@ static struct __kwent __kwtab[] =
{ SSE_T("func"), 4, TOKEN_FUNCTION, 0 }, { SSE_T("func"), 4, TOKEN_FUNCTION, 0 },
/* keywords for variable declaration */ /* keywords for variable declaration */
{ SSE_T("local"), 5, TOKEN_LOCAL, SSE_AWK_ESSELICIT }, { SSE_T("local"), 5, TOKEN_LOCAL, SSE_AWK_EXPLICIT },
{ SSE_T("global"), 6, TOKEN_GLOBAL, SSE_AWK_ESSELICIT }, { SSE_T("global"), 6, TOKEN_GLOBAL, SSE_AWK_EXPLICIT },
/* keywords that start statements excluding esseression statements */ /* keywords that start statements excluding expression statements */
{ SSE_T("if"), 2, TOKEN_IF, 0 }, { SSE_T("if"), 2, TOKEN_IF, 0 },
{ SSE_T("else"), 4, TOKEN_ELSE, 0 }, { SSE_T("else"), 4, TOKEN_ELSE, 0 },
{ SSE_T("while"), 5, TOKEN_WHILE, 0 }, { SSE_T("while"), 5, TOKEN_WHILE, 0 },
@ -243,7 +243,7 @@ static struct __kwent __kwtab[] =
{ SSE_T("print"), 5, TOKEN_PRINT, SSE_AWK_EXTIO }, { SSE_T("print"), 5, TOKEN_PRINT, SSE_AWK_EXTIO },
{ SSE_T("printf"), 6, TOKEN_PRINTF, SSE_AWK_EXTIO }, { SSE_T("printf"), 6, TOKEN_PRINTF, SSE_AWK_EXTIO },
/* keywords that can start an esseression */ /* keywords that can start an expression */
{ SSE_T("getline"), 7, TOKEN_GETLINE, SSE_AWK_EXTIO }, { SSE_T("getline"), 7, TOKEN_GETLINE, SSE_AWK_EXTIO },
{ SSE_NULL, 0, 0 } { SSE_NULL, 0, 0 }
@ -409,7 +409,7 @@ static sse_awk_t* __parse_progunit (sse_awk_t* awk)
sse_awk_assert (awk, awk->parse.depth.loop == 0); sse_awk_assert (awk, awk->parse.depth.loop == 0);
if ((awk->option & SSE_AWK_ESSELICIT) && MATCH(awk,TOKEN_GLOBAL)) if ((awk->option & SSE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
{ {
sse_size_t nglobals; sse_size_t nglobals;
@ -477,8 +477,8 @@ static sse_awk_t* __parse_progunit (sse_awk_t* awk)
else else
{ {
/* /*
esseressions expressions
/regular esseression/ /regular expression/
pattern && pattern pattern && pattern
pattern || pattern pattern || pattern
!pattern !pattern
@ -489,7 +489,7 @@ static sse_awk_t* __parse_progunit (sse_awk_t* awk)
awk->parse.id.block = PARSE_PATTERN; awk->parse.id.block = PARSE_PATTERN;
ptn = __parse_esseression (awk); ptn = __parse_expression (awk);
if (ptn == SSE_NULL) return SSE_NULL; if (ptn == SSE_NULL) return SSE_NULL;
sse_awk_assert (awk, ptn->next == SSE_NULL); sse_awk_assert (awk, ptn->next == SSE_NULL);
@ -502,7 +502,7 @@ static sse_awk_t* __parse_progunit (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
ptn->next = __parse_esseression (awk); ptn->next = __parse_expression (awk);
if (ptn->next == SSE_NULL) if (ptn->next == SSE_NULL)
{ {
sse_awk_clrpt (awk, ptn); sse_awk_clrpt (awk, ptn);
@ -870,7 +870,7 @@ static sse_awk_nde_t* __parse_block (sse_awk_t* awk, sse_bool_t is_top)
nlocals_max = awk->parse.nlocals_max; nlocals_max = awk->parse.nlocals_max;
/* local variable declarations */ /* local variable declarations */
if (awk->option & SSE_AWK_ESSELICIT) if (awk->option & SSE_AWK_EXPLICIT)
{ {
while (1) while (1)
{ {
@ -1256,7 +1256,7 @@ awk->parse.nl_semicolon = 1;
} }
else else
{ {
nde = __parse_esseression(awk); nde = __parse_expression(awk);
} }
awk->parse.nl_semicolon = 0; awk->parse.nl_semicolon = 0;
@ -1279,13 +1279,13 @@ awk->parse.nl_semicolon = 0;
return nde; return nde;
} }
static sse_awk_nde_t* __parse_esseression (sse_awk_t* awk) static sse_awk_nde_t* __parse_expression (sse_awk_t* awk)
{ {
sse_awk_nde_t* x, * y; sse_awk_nde_t* x, * y;
sse_awk_nde_ass_t* nde; sse_awk_nde_ass_t* nde;
int opcode; int opcode;
x = __parse_basic_esser (awk); x = __parse_basic_expr (awk);
if (x == SSE_NULL) return SSE_NULL; if (x == SSE_NULL) return SSE_NULL;
opcode = __assign_to_opcode (awk); opcode = __assign_to_opcode (awk);
@ -1308,7 +1308,7 @@ static sse_awk_nde_t* __parse_esseression (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
y = __parse_basic_esser (awk); y = __parse_basic_expr (awk);
if (y == SSE_NULL) if (y == SSE_NULL)
{ {
sse_awk_clrpt (awk, x); sse_awk_clrpt (awk, x);
@ -1332,7 +1332,7 @@ static sse_awk_nde_t* __parse_esseression (sse_awk_t* awk)
return (sse_awk_nde_t*)nde; return (sse_awk_nde_t*)nde;
} }
static sse_awk_nde_t* __parse_basic_esser (sse_awk_t* awk) static sse_awk_nde_t* __parse_basic_expr (sse_awk_t* awk)
{ {
sse_awk_nde_t* nde, * n1, * n2; sse_awk_nde_t* nde, * n1, * n2;
@ -1345,7 +1345,7 @@ static sse_awk_nde_t* __parse_basic_esser (sse_awk_t* awk)
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
n1 = __parse_basic_esser (awk); n1 = __parse_basic_expr (awk);
if (n1 == SSE_NULL) if (n1 == SSE_NULL)
{ {
sse_awk_clrpt (awk, nde); sse_awk_clrpt (awk, nde);
@ -1355,7 +1355,7 @@ static sse_awk_nde_t* __parse_basic_esser (sse_awk_t* awk)
if (!MATCH(awk,TOKEN_COLON)) PANIC (awk, SSE_AWK_ECOLON); if (!MATCH(awk,TOKEN_COLON)) PANIC (awk, SSE_AWK_ECOLON);
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
n2 = __parse_basic_esser (awk); n2 = __parse_basic_expr (awk);
if (n2 == SSE_NULL) if (n2 == SSE_NULL)
{ {
sse_awk_clrpt (awk, nde); sse_awk_clrpt (awk, nde);
@ -1385,11 +1385,11 @@ static sse_awk_nde_t* __parse_basic_esser (sse_awk_t* awk)
return nde; return nde;
} }
static sse_awk_nde_t* __parse_binary_esser ( static sse_awk_nde_t* __parse_binary_expr (
sse_awk_t* awk, const __binmap_t* binmap, sse_awk_t* awk, const __binmap_t* binmap,
sse_awk_nde_t*(*next_level_func)(sse_awk_t*)) sse_awk_nde_t*(*next_level_func)(sse_awk_t*))
{ {
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
sse_awk_nde_t* left, * right; sse_awk_nde_t* left, * right;
int opcode; int opcode;
@ -1488,8 +1488,8 @@ static sse_awk_nde_t* __parse_binary_esser (
skip_constant_folding: skip_constant_folding:
#endif #endif
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC ( nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (
awk, sse_sizeof(sse_awk_nde_esse_t)); awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, right); sse_awk_clrpt (awk, right);
@ -1497,7 +1497,7 @@ static sse_awk_nde_t* __parse_binary_esser (
PANIC (awk, SSE_AWK_ENOMEM); PANIC (awk, SSE_AWK_ENOMEM);
} }
nde->type = SSE_AWK_NDE_ESSE_BIN; nde->type = SSE_AWK_NDE_EXP_BIN;
nde->next = SSE_NULL; nde->next = SSE_NULL;
nde->opcode = opcode; nde->opcode = opcode;
nde->left = left; nde->left = left;
@ -1517,7 +1517,7 @@ static sse_awk_nde_t* __parse_logical_or (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_logical_and); return __parse_binary_expr (awk, map, __parse_logical_and);
} }
static sse_awk_nde_t* __parse_logical_and (sse_awk_t* awk) static sse_awk_nde_t* __parse_logical_and (sse_awk_t* awk)
@ -1528,7 +1528,7 @@ static sse_awk_nde_t* __parse_logical_and (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_in); return __parse_binary_expr (awk, map, __parse_in);
} }
static sse_awk_nde_t* __parse_in (sse_awk_t* awk) static sse_awk_nde_t* __parse_in (sse_awk_t* awk)
@ -1540,10 +1540,10 @@ static sse_awk_nde_t* __parse_in (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_regex_match); return __parse_binary_expr (awk, map, __parse_regex_match);
*/ */
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
sse_awk_nde_t* left, * right; sse_awk_nde_t* left, * right;
left = __parse_regex_match (awk); left = __parse_regex_match (awk);
@ -1573,8 +1573,8 @@ static sse_awk_nde_t* __parse_in (sse_awk_t* awk)
PANIC (awk, SSE_AWK_ENOTVAR); PANIC (awk, SSE_AWK_ENOTVAR);
} }
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC ( nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (
awk, sse_sizeof(sse_awk_nde_esse_t)); awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, right); sse_awk_clrpt (awk, right);
@ -1582,7 +1582,7 @@ static sse_awk_nde_t* __parse_in (sse_awk_t* awk)
PANIC (awk, SSE_AWK_ENOMEM); PANIC (awk, SSE_AWK_ENOMEM);
} }
nde->type = SSE_AWK_NDE_ESSE_BIN; nde->type = SSE_AWK_NDE_EXP_BIN;
nde->next = SSE_NULL; nde->next = SSE_NULL;
nde->opcode = SSE_AWK_BINOP_IN; nde->opcode = SSE_AWK_BINOP_IN;
nde->left = left; nde->left = left;
@ -1603,7 +1603,7 @@ static sse_awk_nde_t* __parse_regex_match (sse_awk_t* awk)
{ TOKEN_EOF, 0 }, { TOKEN_EOF, 0 },
}; };
return __parse_binary_esser (awk, map, __parse_bitwise_or); return __parse_binary_expr (awk, map, __parse_bitwise_or);
} }
static sse_awk_nde_t* __parse_bitwise_or (sse_awk_t* awk) static sse_awk_nde_t* __parse_bitwise_or (sse_awk_t* awk)
@ -1620,7 +1620,7 @@ static sse_awk_nde_t* __parse_bitwise_or (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_bitwise_xor); return __parse_binary_expr (awk, map, __parse_bitwise_xor);
} }
} }
@ -1691,7 +1691,7 @@ static sse_awk_nde_t* __parse_bitwise_or_with_extio (sse_awk_t* awk)
} }
else else
{ {
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
if (in_type == SSE_AWK_IN_COPROC) if (in_type == SSE_AWK_IN_COPROC)
{ {
@ -1708,8 +1708,8 @@ static sse_awk_nde_t* __parse_bitwise_or_with_extio (sse_awk_t* awk)
/* TODO: do constant folding */ /* TODO: do constant folding */
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC ( nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (
awk, sse_sizeof(sse_awk_nde_esse_t)); awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, right); sse_awk_clrpt (awk, right);
@ -1717,7 +1717,7 @@ static sse_awk_nde_t* __parse_bitwise_or_with_extio (sse_awk_t* awk)
PANIC (awk, SSE_AWK_ENOMEM); PANIC (awk, SSE_AWK_ENOMEM);
} }
nde->type = SSE_AWK_NDE_ESSE_BIN; nde->type = SSE_AWK_NDE_EXP_BIN;
nde->next = SSE_NULL; nde->next = SSE_NULL;
nde->opcode = SSE_AWK_BINOP_BOR; nde->opcode = SSE_AWK_BINOP_BOR;
nde->left = left; nde->left = left;
@ -1738,7 +1738,7 @@ static sse_awk_nde_t* __parse_bitwise_xor (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_bitwise_and); return __parse_binary_expr (awk, map, __parse_bitwise_and);
} }
static sse_awk_nde_t* __parse_bitwise_and (sse_awk_t* awk) static sse_awk_nde_t* __parse_bitwise_and (sse_awk_t* awk)
@ -1749,7 +1749,7 @@ static sse_awk_nde_t* __parse_bitwise_and (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_equality); return __parse_binary_expr (awk, map, __parse_equality);
} }
static sse_awk_nde_t* __parse_equality (sse_awk_t* awk) static sse_awk_nde_t* __parse_equality (sse_awk_t* awk)
@ -1761,7 +1761,7 @@ static sse_awk_nde_t* __parse_equality (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_relational); return __parse_binary_expr (awk, map, __parse_relational);
} }
static sse_awk_nde_t* __parse_relational (sse_awk_t* awk) static sse_awk_nde_t* __parse_relational (sse_awk_t* awk)
@ -1775,7 +1775,7 @@ static sse_awk_nde_t* __parse_relational (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_shift); return __parse_binary_expr (awk, map, __parse_shift);
} }
static sse_awk_nde_t* __parse_shift (sse_awk_t* awk) static sse_awk_nde_t* __parse_shift (sse_awk_t* awk)
@ -1787,12 +1787,12 @@ static sse_awk_nde_t* __parse_shift (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_concat); return __parse_binary_expr (awk, map, __parse_concat);
} }
static sse_awk_nde_t* __parse_concat (sse_awk_t* awk) static sse_awk_nde_t* __parse_concat (sse_awk_t* awk)
{ {
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
sse_awk_nde_t* left, * right; sse_awk_nde_t* left, * right;
left = __parse_additive (awk); left = __parse_additive (awk);
@ -1811,8 +1811,8 @@ static sse_awk_nde_t* __parse_concat (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC ( nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (
awk, sse_sizeof(sse_awk_nde_esse_t)); awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, left); sse_awk_clrpt (awk, left);
@ -1820,7 +1820,7 @@ static sse_awk_nde_t* __parse_concat (sse_awk_t* awk)
PANIC (awk, SSE_AWK_ENOMEM); PANIC (awk, SSE_AWK_ENOMEM);
} }
nde->type = SSE_AWK_NDE_ESSE_BIN; nde->type = SSE_AWK_NDE_EXP_BIN;
nde->next = SSE_NULL; nde->next = SSE_NULL;
nde->opcode = SSE_AWK_BINOP_CONCAT; nde->opcode = SSE_AWK_BINOP_CONCAT;
nde->left = left; nde->left = left;
@ -1841,7 +1841,7 @@ static sse_awk_nde_t* __parse_additive (sse_awk_t* awk)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_multiplicative); return __parse_binary_expr (awk, map, __parse_multiplicative);
} }
static sse_awk_nde_t* __parse_multiplicative (sse_awk_t* awk) static sse_awk_nde_t* __parse_multiplicative (sse_awk_t* awk)
@ -1851,16 +1851,16 @@ static sse_awk_nde_t* __parse_multiplicative (sse_awk_t* awk)
{ TOKEN_MUL, SSE_AWK_BINOP_MUL }, { TOKEN_MUL, SSE_AWK_BINOP_MUL },
{ TOKEN_DIV, SSE_AWK_BINOP_DIV }, { TOKEN_DIV, SSE_AWK_BINOP_DIV },
{ TOKEN_MOD, SSE_AWK_BINOP_MOD }, { TOKEN_MOD, SSE_AWK_BINOP_MOD },
{ TOKEN_ESSE, SSE_AWK_BINOP_ESSE }, { TOKEN_EXP, SSE_AWK_BINOP_EXP },
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return __parse_binary_esser (awk, map, __parse_unary); return __parse_binary_expr (awk, map, __parse_unary);
} }
static sse_awk_nde_t* __parse_unary (sse_awk_t* awk) static sse_awk_nde_t* __parse_unary (sse_awk_t* awk)
{ {
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
sse_awk_nde_t* left; sse_awk_nde_t* left;
int opcode; int opcode;
@ -1876,14 +1876,14 @@ static sse_awk_nde_t* __parse_unary (sse_awk_t* awk)
left = __parse_unary (awk); left = __parse_unary (awk);
if (left == SSE_NULL) return SSE_NULL; if (left == SSE_NULL) return SSE_NULL;
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC (awk, sse_sizeof(sse_awk_nde_esse_t)); nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, left); sse_awk_clrpt (awk, left);
PANIC (awk, SSE_AWK_ENOMEM); PANIC (awk, SSE_AWK_ENOMEM);
} }
nde->type = SSE_AWK_NDE_ESSE_UNR; nde->type = SSE_AWK_NDE_EXP_UNR;
nde->next = SSE_NULL; nde->next = SSE_NULL;
nde->opcode = opcode; nde->opcode = opcode;
nde->left = left; nde->left = left;
@ -1894,7 +1894,7 @@ static sse_awk_nde_t* __parse_unary (sse_awk_t* awk)
static sse_awk_nde_t* __parse_increment (sse_awk_t* awk) static sse_awk_nde_t* __parse_increment (sse_awk_t* awk)
{ {
sse_awk_nde_esse_t* nde; sse_awk_nde_exp_t* nde;
sse_awk_nde_t* left; sse_awk_nde_t* left;
int type, opcode, opcode1, opcode2; int type, opcode, opcode1, opcode2;
@ -1923,18 +1923,18 @@ static sse_awk_nde_t* __parse_increment (sse_awk_t* awk)
} }
else if (opcode1 != -1) else if (opcode1 != -1)
{ {
type = SSE_AWK_NDE_ESSE_INCPRE; type = SSE_AWK_NDE_EXP_INCPRE;
opcode = opcode1; opcode = opcode1;
} }
else if (opcode2 != -1) else if (opcode2 != -1)
{ {
type = SSE_AWK_NDE_ESSE_INCPST; type = SSE_AWK_NDE_EXP_INCPST;
opcode = opcode2; opcode = opcode2;
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
} }
nde = (sse_awk_nde_esse_t*) SSE_AWK_MALLOC (awk, sse_sizeof(sse_awk_nde_esse_t)); nde = (sse_awk_nde_exp_t*) SSE_AWK_MALLOC (awk, sse_sizeof(sse_awk_nde_exp_t));
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
sse_awk_clrpt (awk, left); sse_awk_clrpt (awk, left);
@ -2061,7 +2061,7 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
sse_awk_nde_rex_t* nde; sse_awk_nde_rex_t* nde;
int errnum; int errnum;
/* the regular esseression is tokenized here because /* the regular expression is tokenized here because
* of the context-sensitivity of the slash symbol */ * of the context-sensitivity of the slash symbol */
SET_TOKEN_TYPE (awk, TOKEN_REX); SET_TOKEN_TYPE (awk, TOKEN_REX);
sse_awk_str_clear (&awk->token.name); sse_awk_str_clear (&awk->token.name);
@ -2140,11 +2140,11 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
/* eat up the left parenthesis */ /* eat up the left parenthesis */
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
/* parse the sub-esseression inside the parentheses */ /* parse the sub-expression inside the parentheses */
nde = __parse_esseression (awk); nde = __parse_expression (awk);
if (nde == SSE_NULL) return SSE_NULL; if (nde == SSE_NULL) return SSE_NULL;
/* parse subsequent esseressions separated by a comma, if any */ /* parse subsequent expressions separated by a comma, if any */
last = nde; last = nde;
sse_awk_assert (awk, last->next == SSE_NULL); sse_awk_assert (awk, last->next == SSE_NULL);
@ -2158,7 +2158,7 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
tmp = __parse_esseression (awk); tmp = __parse_expression (awk);
if (tmp == SSE_NULL) if (tmp == SSE_NULL)
{ {
sse_awk_clrpt (awk, nde); sse_awk_clrpt (awk, nde);
@ -2187,8 +2187,8 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
/* check if it is a chained node */ /* check if it is a chained node */
if (nde->next != SSE_NULL) if (nde->next != SSE_NULL)
{ {
/* if so, it is a esseression group */ /* if so, it is a expression group */
/* (esser1, esser2, esser2) */ /* (expr1, expr2, expr2) */
sse_awk_nde_grp_t* tmp; sse_awk_nde_grp_t* tmp;
@ -2242,7 +2242,7 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
} }
/* TODO: is this correct? */ /* TODO: is this correct? */
/*in = __parse_esseression (awk);*/ /*in = __parse_expression (awk);*/
in = __parse_primary (awk); in = __parse_primary (awk);
if (in == SSE_NULL) if (in == SSE_NULL)
{ {
@ -2270,8 +2270,8 @@ static sse_awk_nde_t* __parse_primary (sse_awk_t* awk)
return (sse_awk_nde_t*)nde; return (sse_awk_nde_t*)nde;
} }
/* valid esseression introducer is esseected */ /* valid expression introducer is expected */
PANIC (awk, SSE_AWK_EESSERESSION); PANIC (awk, SSE_AWK_EEXPRESSION);
} }
static sse_awk_nde_t* __parse_primary_ident (sse_awk_t* awk) static sse_awk_nde_t* __parse_primary_ident (sse_awk_t* awk)
@ -2428,7 +2428,7 @@ static sse_awk_nde_t* __parse_hashidx (
return SSE_NULL; return SSE_NULL;
} }
tmp = __parse_esseression (awk); tmp = __parse_expression (awk);
if (tmp == SSE_NULL) if (tmp == SSE_NULL)
{ {
if (idx != SSE_NULL) sse_awk_clrpt (awk, idx); if (idx != SSE_NULL) sse_awk_clrpt (awk, idx);
@ -2555,7 +2555,7 @@ static sse_awk_nde_t* __parse_fncall (
while (1) while (1)
{ {
nde = __parse_esseression (awk); nde = __parse_expression (awk);
if (nde == SSE_NULL) if (nde == SSE_NULL)
{ {
if (head != SSE_NULL) sse_awk_clrpt (awk, head); if (head != SSE_NULL) sse_awk_clrpt (awk, head);
@ -2640,7 +2640,7 @@ static sse_awk_nde_t* __parse_if (sse_awk_t* awk)
if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, SSE_AWK_ELPAREN); if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, SSE_AWK_ELPAREN);
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
test = __parse_esseression (awk); test = __parse_expression (awk);
if (test == SSE_NULL) return SSE_NULL; if (test == SSE_NULL) return SSE_NULL;
if (!MATCH(awk,TOKEN_RPAREN)) if (!MATCH(awk,TOKEN_RPAREN))
@ -2707,7 +2707,7 @@ static sse_awk_nde_t* __parse_while (sse_awk_t* awk)
if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, SSE_AWK_ELPAREN); if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, SSE_AWK_ELPAREN);
if (__get_token(awk) == -1) return SSE_NULL; if (__get_token(awk) == -1) return SSE_NULL;
test = __parse_esseression (awk); test = __parse_expression (awk);
if (test == SSE_NULL) return SSE_NULL; if (test == SSE_NULL) return SSE_NULL;
if (!MATCH(awk,TOKEN_RPAREN)) if (!MATCH(awk,TOKEN_RPAREN))
@ -2758,16 +2758,16 @@ static sse_awk_nde_t* __parse_for (sse_awk_t* awk)
else else
{ {
/* this line is very ugly. it checks the entire next /* this line is very ugly. it checks the entire next
* esseression or the first element in the esseression * expression or the first element in the expression
* is wrapped by a parenthesis */ * is wrapped by a parenthesis */
int no_foreach = MATCH(awk,TOKEN_LPAREN); int no_foreach = MATCH(awk,TOKEN_LPAREN);
init = __parse_esseression (awk); init = __parse_expression (awk);
if (init == SSE_NULL) return SSE_NULL; if (init == SSE_NULL) return SSE_NULL;
if (!no_foreach && init->type == SSE_AWK_NDE_ESSE_BIN && if (!no_foreach && init->type == SSE_AWK_NDE_EXP_BIN &&
((sse_awk_nde_esse_t*)init)->opcode == SSE_AWK_BINOP_IN && ((sse_awk_nde_exp_t*)init)->opcode == SSE_AWK_BINOP_IN &&
__is_plain_var(((sse_awk_nde_esse_t*)init)->left)) __is_plain_var(((sse_awk_nde_exp_t*)init)->left))
{ {
/* switch to foreach */ /* switch to foreach */
@ -2824,7 +2824,7 @@ static sse_awk_nde_t* __parse_for (sse_awk_t* awk)
if (MATCH(awk,TOKEN_SEMICOLON)) test = SSE_NULL; if (MATCH(awk,TOKEN_SEMICOLON)) test = SSE_NULL;
else else
{ {
test = __parse_esseression (awk); test = __parse_expression (awk);
if (test == SSE_NULL) if (test == SSE_NULL)
{ {
sse_awk_clrpt (awk, init); sse_awk_clrpt (awk, init);
@ -2849,7 +2849,7 @@ static sse_awk_nde_t* __parse_for (sse_awk_t* awk)
if (MATCH(awk,TOKEN_RPAREN)) incr = SSE_NULL; if (MATCH(awk,TOKEN_RPAREN)) incr = SSE_NULL;
else else
{ {
incr = __parse_esseression (awk); incr = __parse_expression (awk);
if (incr == SSE_NULL) if (incr == SSE_NULL)
{ {
sse_awk_clrpt (awk, init); sse_awk_clrpt (awk, init);
@ -2935,7 +2935,7 @@ static sse_awk_nde_t* __parse_dowhile (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
test = __parse_esseression (awk); test = __parse_expression (awk);
if (test == SSE_NULL) if (test == SSE_NULL)
{ {
sse_awk_clrpt (awk, body); sse_awk_clrpt (awk, body);
@ -3019,7 +3019,7 @@ static sse_awk_nde_t* __parse_return (sse_awk_t* awk)
} }
else else
{ {
val = __parse_esseression (awk); val = __parse_expression (awk);
if (val == SSE_NULL) if (val == SSE_NULL)
{ {
SSE_AWK_FREE (awk, nde); SSE_AWK_FREE (awk, nde);
@ -3048,7 +3048,7 @@ static sse_awk_nde_t* __parse_exit (sse_awk_t* awk)
} }
else else
{ {
val = __parse_esseression (awk); val = __parse_expression (awk);
if (val == SSE_NULL) if (val == SSE_NULL)
{ {
SSE_AWK_FREE (awk, nde); SSE_AWK_FREE (awk, nde);
@ -3072,7 +3072,7 @@ static sse_awk_nde_t* __parse_delete (sse_awk_t* awk)
if (!__is_var (var)) if (!__is_var (var))
{ {
/* a normal identifier is esseected */ /* a normal identifier is expected */
sse_awk_clrpt (awk, var); sse_awk_clrpt (awk, var);
PANIC (awk, SSE_AWK_EIDENT); PANIC (awk, SSE_AWK_EIDENT);
} }
@ -3103,7 +3103,7 @@ static sse_awk_nde_t* __parse_print (sse_awk_t* awk)
!MATCH(awk,TOKEN_BOR) && !MATCH(awk,TOKEN_BOR) &&
!MATCH(awk,TOKEN_BORAND)) !MATCH(awk,TOKEN_BORAND))
{ {
args = __parse_esseression (awk); args = __parse_expression (awk);
if (args == SSE_NULL) return SSE_NULL; if (args == SSE_NULL) return SSE_NULL;
args_tail = args; args_tail = args;
@ -3117,7 +3117,7 @@ static sse_awk_nde_t* __parse_print (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
args_tail->next = __parse_esseression (awk); args_tail->next = __parse_expression (awk);
if (args_tail->next == SSE_NULL) if (args_tail->next == SSE_NULL)
{ {
sse_awk_clrpt (awk, args); sse_awk_clrpt (awk, args);
@ -3131,9 +3131,9 @@ static sse_awk_nde_t* __parse_print (sse_awk_t* awk)
/* print 1 > 2 would print 1 to the file named 2. /* print 1 > 2 would print 1 to the file named 2.
* print (1 > 2) would print (1 > 2) in the console */ * print (1 > 2) would print (1 > 2) in the console */
if (awk->token.prev != TOKEN_RPAREN && if (awk->token.prev != TOKEN_RPAREN &&
args_tail->type == SSE_AWK_NDE_ESSE_BIN) args_tail->type == SSE_AWK_NDE_EXP_BIN)
{ {
sse_awk_nde_esse_t* ep = (sse_awk_nde_esse_t*)args_tail; sse_awk_nde_exp_t* ep = (sse_awk_nde_exp_t*)args_tail;
if (ep->opcode == SSE_AWK_BINOP_GT) if (ep->opcode == SSE_AWK_BINOP_GT)
{ {
sse_awk_nde_t* tmp = args_tail; sse_awk_nde_t* tmp = args_tail;
@ -3192,7 +3192,7 @@ static sse_awk_nde_t* __parse_print (sse_awk_t* awk)
return SSE_NULL; return SSE_NULL;
} }
out = __parse_esseression(awk); out = __parse_expression(awk);
if (out == SSE_NULL) if (out == SSE_NULL)
{ {
if (args != SSE_NULL) sse_awk_clrpt (awk, args); if (args != SSE_NULL) sse_awk_clrpt (awk, args);
@ -3527,13 +3527,13 @@ static int __get_token (sse_awk_t* awk)
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
if (c == SSE_T('=')) if (c == SSE_T('='))
{ {
SET_TOKEN_TYPE (awk, TOKEN_ESSE_ASSIGN); SET_TOKEN_TYPE (awk, TOKEN_EXP_ASSIGN);
ADD_TOKEN_CHAR (awk, c); ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
} }
else else
{ {
SET_TOKEN_TYPE (awk, TOKEN_ESSE); SET_TOKEN_TYPE (awk, TOKEN_EXP);
} }
} }
else else
@ -3653,7 +3653,7 @@ static int __get_token (sse_awk_t* awk)
return -1; return -1;
} }
/*sse_printf (SSE_T("token -> [%s]\n"), SSE_AWK_STR_BUF(&awk->token.name));*/ /*xp_printf (SSE_T("token -> [%s]\n"), SSE_AWK_STR_BUF(&awk->token.name));*/
return 0; return 0;
} }
@ -4101,11 +4101,11 @@ static int __assign_to_opcode (sse_awk_t* awk)
SSE_AWK_ASSOP_MUL, SSE_AWK_ASSOP_MUL,
SSE_AWK_ASSOP_DIV, SSE_AWK_ASSOP_DIV,
SSE_AWK_ASSOP_MOD, SSE_AWK_ASSOP_MOD,
SSE_AWK_ASSOP_ESSE SSE_AWK_ASSOP_EXP
}; };
if (awk->token.type >= TOKEN_ASSIGN && if (awk->token.type >= TOKEN_ASSIGN &&
awk->token.type <= TOKEN_ESSE_ASSIGN) awk->token.type <= TOKEN_EXP_ASSIGN)
{ {
return __assop[awk->token.type - TOKEN_ASSIGN]; return __assop[awk->token.type - TOKEN_ASSIGN];
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rex.c,v 1.37 2006-10-22 11:34:53 bacon Exp $ * $Id: rex.c,v 1.38 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -398,8 +398,8 @@ sse_bool_t sse_awk_isemptyrex (sse_awk_t* awk, void* code)
nb = *(sse_size_t*)p; p += sse_sizeof(nb); nb = *(sse_size_t*)p; p += sse_sizeof(nb);
el = *(sse_size_t*)p; p += sse_sizeof(el); el = *(sse_size_t*)p; p += sse_sizeof(el);
/* an empty regular esseression look like: /* an empty regular expression look like:
* | esseression | * | expression |
* | header | branch | * | header | branch |
* | | branch header | * | | branch header |
* | NB(1) | EL(16) | NA(1) | BL(8) | */ * | NB(1) | EL(16) | NA(1) | BL(8) | */
@ -720,7 +720,7 @@ static int __build_charset (__builder_t* builder, struct __code_t* cmd)
{ {
/* invalid range */ /* invalid range */
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__build_charset: invalid character set range\n")); xp_printf (SSE_T("__build_charset: invalid character set range\n"));
#endif #endif
builder->errnum = SSE_AWK_EREXCRANGE; builder->errnum = SSE_AWK_EREXCRANGE;
return -1; return -1;
@ -752,7 +752,7 @@ static int __build_cclass (__builder_t* builder, sse_char_t* cc)
{ {
/* wrong class name */ /* wrong class name */
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__build_cclass: wrong class name\n"));*/ xp_printf (SSE_T("__build_cclass: wrong class name\n"));*/
#endif #endif
builder->errnum = SSE_AWK_EREXCCLASS; builder->errnum = SSE_AWK_EREXCCLASS;
return -1; return -1;
@ -765,7 +765,7 @@ sse_printf (SSE_T("__build_cclass: wrong class name\n"));*/
builder->ptn.curc.value != SSE_T(':')) builder->ptn.curc.value != SSE_T(':'))
{ {
#ifdef BUILD_REX #ifdef BUILD_REX
sse_printf (SSE_T("__build_cclass: a colon(:) esseected\n")); xp_printf (SSE_T("__build_cclass: a colon(:) expected\n"));
#endif #endif
builder->errnum = SSE_AWK_EREXCOLON; builder->errnum = SSE_AWK_EREXCOLON;
return -1; return -1;
@ -778,7 +778,7 @@ sse_printf (SSE_T("__build_cclass: a colon(:) esseected\n"));
builder->ptn.curc.value != SSE_T(']')) builder->ptn.curc.value != SSE_T(']'))
{ {
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__build_cclass: ] esseected\n")); xp_printf (SSE_T("__build_cclass: ] expected\n"));
#endif #endif
builder->errnum = SSE_AWK_EREXRBRACKET; builder->errnum = SSE_AWK_EREXRBRACKET;
return -1; return -1;
@ -1025,7 +1025,7 @@ static const sse_byte_t* __match_pattern (
el = *(sse_size_t*)p; p += sse_sizeof(el); el = *(sse_size_t*)p; p += sse_sizeof(el);
#ifdef BUILD_REX #ifdef BUILD_REX
sse_printf (SSE_T("__match_pattern: NB = %u, EL = %u\n"), (unsigned)nb, (unsigned)el); xp_printf (SSE_T("__match_pattern: NB = %u, EL = %u\n"), (unsigned)nb, (unsigned)el);
#endif #endif
mat->matched = sse_false; mat->matched = sse_false;
mat->match_len = 0; mat->match_len = 0;
@ -1211,7 +1211,7 @@ static const sse_byte_t* __match_any_char (
} }
#ifdef BUILD_REX #ifdef BUILD_REX
sse_printf (SSE_T("__match_any_char: lbound = %u, ubound = %u\n"), xp_printf (SSE_T("__match_any_char: lbound = %u, ubound = %u\n"),
(unsigned int)lbound, (unsigned int)ubound); (unsigned int)lbound, (unsigned int)ubound);
#endif #endif
@ -1223,7 +1223,7 @@ sse_printf (SSE_T("__match_any_char: lbound = %u, ubound = %u\n"),
} }
#ifdef BUILD_REX #ifdef BUILD_REX
sse_printf (SSE_T("__match_any_char: max si = %d\n"), si); xp_printf (SSE_T("__match_any_char: max si = %d\n"), si);
#endif #endif
if (si >= lbound && si <= ubound) if (si >= lbound && si <= ubound)
{ {
@ -1281,7 +1281,7 @@ static const sse_byte_t* __match_ord_char (
} }
#ifdef BUILD_REX #ifdef BUILD_REX
sse_printf (SSE_T("__match_ord_char: lbound = %u, ubound = %u\n"), xp_printf (SSE_T("__match_ord_char: lbound = %u, ubound = %u\n"),
(unsigned int)lbound, (unsigned int)ubound);*/ (unsigned int)lbound, (unsigned int)ubound);*/
#endif #endif
@ -1309,7 +1309,7 @@ sse_printf (SSE_T("__match_ord_char: lbound = %u, ubound = %u\n"),
} }
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__match_ord_char: max si = %d, lbound = %u, ubound = %u\n"), si, lbound, ubound); xp_printf (SSE_T("__match_ord_char: max si = %d, lbound = %u, ubound = %u\n"), si, lbound, ubound);
#endif #endif
if (si >= lbound && si <= ubound) if (si >= lbound && si <= ubound)
@ -1466,7 +1466,7 @@ static const sse_byte_t* __match_group (
mat2.branch_end = mat->branch_end; mat2.branch_end = mat->branch_end;
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__match_group: GROUP si = %d [%s]\n"), si, mat->match_ptr); xp_printf (SSE_T("__match_group: GROUP si = %d [%s]\n"), si, mat->match_ptr);
#endif #endif
tmp = __match_branch_body (matcher, p, &mat2); tmp = __match_branch_body (matcher, p, &mat2);
if (tmp == SSE_NULL) if (tmp == SSE_NULL)
@ -1565,7 +1565,7 @@ static const sse_byte_t* __match_occurrences (
mat2.branch_end = mat->branch_end; mat2.branch_end = mat->branch_end;
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__match occurrences: si = %d [%s]\n"), si, mat->match_ptr); xp_printf (SSE_T("__match occurrences: si = %d [%s]\n"), si, mat->match_ptr);
#endif #endif
tmp = __match_branch_body (matcher, p, &mat2); tmp = __match_branch_body (matcher, p, &mat2);
@ -1699,7 +1699,7 @@ static sse_bool_t __cc_isxdigit (sse_awk_t* awk, sse_char_t c)
void sse_awk_printrex (void* rex) void sse_awk_printrex (void* rex)
{ {
__print_pattern (rex); __print_pattern (rex);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
} }
static const sse_byte_t* __print_pattern (const sse_byte_t* p) static const sse_byte_t* __print_pattern (const sse_byte_t* p)
@ -1709,12 +1709,12 @@ static const sse_byte_t* __print_pattern (const sse_byte_t* p)
nb = *(sse_size_t*)p; p += sse_sizeof(nb); nb = *(sse_size_t*)p; p += sse_sizeof(nb);
el = *(sse_size_t*)p; p += sse_sizeof(el); el = *(sse_size_t*)p; p += sse_sizeof(el);
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__print_pattern: NB = %u, EL = %u\n"), (unsigned int)nb, (unsigned int)el); xp_printf (SSE_T("__print_pattern: NB = %u, EL = %u\n"), (unsigned int)nb, (unsigned int)el);
#endif #endif
for (i = 0; i < nb; i++) for (i = 0; i < nb; i++)
{ {
if (i != 0) sse_printf (SSE_T("|")); if (i != 0) xp_printf (SSE_T("|"));
p = __print_branch (p); p = __print_branch (p);
} }
@ -1728,7 +1728,7 @@ static const sse_byte_t* __print_branch (const sse_byte_t* p)
na = *(sse_size_t*)p; p += sse_sizeof(na); na = *(sse_size_t*)p; p += sse_sizeof(na);
bl = *(sse_size_t*)p; p += sse_sizeof(bl); bl = *(sse_size_t*)p; p += sse_sizeof(bl);
#ifdef DEBUG_REX #ifdef DEBUG_REX
sse_printf (SSE_T("__print_branch: NA = %u, BL = %u\n"), (unsigned int) na, (unsigned int)bl); xp_printf (SSE_T("__print_branch: NA = %u, BL = %u\n"), (unsigned int) na, (unsigned int)bl);
#endif #endif
for (i = 0; i < na; i++) for (i = 0; i < na; i++)
@ -1745,23 +1745,23 @@ static const sse_byte_t* __print_atom (const sse_byte_t* p)
if (cp->cmd == CMD_BOL) if (cp->cmd == CMD_BOL)
{ {
sse_printf (SSE_T("^")); xp_printf (SSE_T("^"));
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
} }
else if (cp->cmd == CMD_EOL) else if (cp->cmd == CMD_EOL)
{ {
sse_printf (SSE_T("$")); xp_printf (SSE_T("$"));
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
} }
else if (cp->cmd == CMD_ANY_CHAR) else if (cp->cmd == CMD_ANY_CHAR)
{ {
sse_printf (SSE_T(".")); xp_printf (SSE_T("."));
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
} }
else if (cp->cmd == CMD_ORD_CHAR) else if (cp->cmd == CMD_ORD_CHAR)
{ {
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
sse_printf (SSE_T("%c"), *(sse_char_t*)p); xp_printf (SSE_T("%c"), *(sse_char_t*)p);
p += sse_sizeof(sse_char_t); p += sse_sizeof(sse_char_t);
} }
else if (cp->cmd == CMD_CHARSET) else if (cp->cmd == CMD_CHARSET)
@ -1769,8 +1769,8 @@ static const sse_byte_t* __print_atom (const sse_byte_t* p)
sse_size_t csc, csl, i; sse_size_t csc, csl, i;
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
sse_printf (SSE_T("[")); xp_printf (SSE_T("["));
if (cp->negate) sse_printf (SSE_T("^")); if (cp->negate) xp_printf (SSE_T("^"));
csc = *(sse_size_t*)p; p += sse_sizeof(csc); csc = *(sse_size_t*)p; p += sse_sizeof(csc);
csl = *(sse_size_t*)p; p += sse_sizeof(csl); csl = *(sse_size_t*)p; p += sse_sizeof(csl);
@ -1785,51 +1785,51 @@ static const sse_byte_t* __print_atom (const sse_byte_t* p)
if (c0 == CHARSET_ONE) if (c0 == CHARSET_ONE)
{ {
c1 = *(sse_char_t*)p; c1 = *(sse_char_t*)p;
sse_printf (SSE_T("%c"), c1); xp_printf (SSE_T("%c"), c1);
} }
else if (c0 == CHARSET_RANGE) else if (c0 == CHARSET_RANGE)
{ {
c1 = *(sse_char_t*)p; c1 = *(sse_char_t*)p;
p += sse_sizeof(c1); p += sse_sizeof(c1);
c2 = *(sse_char_t*)p; c2 = *(sse_char_t*)p;
sse_printf (SSE_T("%c-%c"), c1, c2); xp_printf (SSE_T("%c-%c"), c1, c2);
} }
else if (c0 == CHARSET_CLASS) else if (c0 == CHARSET_CLASS)
{ {
c1 = *(sse_char_t*)p; c1 = *(sse_char_t*)p;
sse_printf (SSE_T("[:%s:]"), __char_class[c1].name); xp_printf (SSE_T("[:%s:]"), __char_class[c1].name);
} }
else else
{ {
sse_printf ("should never happen - invalid charset code\n"); xp_printf ("should never happen - invalid charset code\n");
} }
p += sse_sizeof(c1); p += sse_sizeof(c1);
} }
sse_printf (SSE_T("]")); xp_printf (SSE_T("]"));
} }
else if (cp->cmd == CMD_GROUP) else if (cp->cmd == CMD_GROUP)
{ {
p += sse_sizeof(*cp); p += sse_sizeof(*cp);
sse_printf (SSE_T("(")); xp_printf (SSE_T("("));
p = __print_pattern (p); p = __print_pattern (p);
sse_printf (SSE_T(")")); xp_printf (SSE_T(")"));
} }
else else
{ {
sse_printf ("should never happen - invalid atom code\n"); xp_printf ("should never happen - invalid atom code\n");
} }
if (cp->lbound == 0 && cp->ubound == BOUND_MAX) if (cp->lbound == 0 && cp->ubound == BOUND_MAX)
sse_printf (SSE_T("*")); xp_printf (SSE_T("*"));
else if (cp->lbound == 1 && cp->ubound == BOUND_MAX) else if (cp->lbound == 1 && cp->ubound == BOUND_MAX)
sse_printf (SSE_T("+")); xp_printf (SSE_T("+"));
else if (cp->lbound == 0 && cp->ubound == 1) else if (cp->lbound == 0 && cp->ubound == 1)
sse_printf (SSE_T("?")); xp_printf (SSE_T("?"));
else if (cp->lbound != 1 || cp->ubound != 1) else if (cp->lbound != 1 || cp->ubound != 1)
{ {
sse_printf (SSE_T("{%lu,%lu}"), xp_printf (SSE_T("{%lu,%lu}"),
(unsigned long)cp->lbound, (unsigned long)cp->ubound); (unsigned long)cp->lbound, (unsigned long)cp->ubound);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rex.h,v 1.19 2006-10-22 11:34:53 bacon Exp $ * $Id: rex.h,v 1.20 2006-10-22 12:39:29 bacon Exp $
**/ **/
#ifndef _SSE_AWK_REX_H_ #ifndef _SSE_AWK_REX_H_
@ -11,26 +11,26 @@
/* /*
* Regular Esseression Syntax * Regular Esseression Syntax
* A regular esseression is zero or more branches, separated by '|'. * A regular expression is zero or more branches, separated by '|'.
* ...... * ......
* ...... * ......
* *
* Compiled form of a regular esseression: * Compiled form of a regular expression:
* *
* | esseression | * | expression |
* | header | branch | branch | branch | * | header | branch | branch | branch |
* | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd | * | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd |
* *
* nb: the number of branches * nb: the number of branches
* el: the length of a esseression including the length of nb and el * el: the length of a expression including the length of nb and el
* na: the number of atoms * na: the number of atoms
* bl: the length of a branch including the length of na and bl * bl: the length of a branch including the length of na and bl
* cmd: The command and repetition info encoded together. * cmd: The command and repetition info encoded together.
* Some commands require an argument to follow them but some other don't. * Some commands require an argument to follow them but some other don't.
* It is encoded as follows: * It is encoded as follows:
* *
* Subesseressions can be nested by having the command "GROUP" * Subexpressions can be nested by having the command "GROUP"
* and a subesseression as its argument. * and a subexpression as its argument.
* *
* Examples: * Examples:
* a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c| * a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c|

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.240 2006-10-22 11:34:53 bacon Exp $ * $Id: run.c,v 1.241 2006-10-22 12:39:29 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -84,8 +84,8 @@ static int __run_nextfile (sse_awk_run_t* run, sse_awk_nde_nextfile_t* nde);
static int __run_delete (sse_awk_run_t* run, sse_awk_nde_delete_t* nde); static int __run_delete (sse_awk_run_t* run, sse_awk_nde_delete_t* nde);
static int __run_print (sse_awk_run_t* run, sse_awk_nde_print_t* nde); static int __run_print (sse_awk_run_t* run, sse_awk_nde_print_t* nde);
static sse_awk_val_t* __eval_esseression (sse_awk_run_t* run, sse_awk_nde_t* nde); static sse_awk_val_t* __eval_expression (sse_awk_run_t* run, sse_awk_nde_t* nde);
static sse_awk_val_t* __eval_esseression0 (sse_awk_run_t* run, sse_awk_nde_t* nde); static sse_awk_val_t* __eval_expression0 (sse_awk_run_t* run, sse_awk_nde_t* nde);
static sse_awk_val_t* __eval_group (sse_awk_run_t* run, sse_awk_nde_t* nde); static sse_awk_val_t* __eval_group (sse_awk_run_t* run, sse_awk_nde_t* nde);
@ -140,7 +140,7 @@ static sse_awk_val_t* __eval_binop_div (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right); sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right);
static sse_awk_val_t* __eval_binop_mod ( static sse_awk_val_t* __eval_binop_mod (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right); sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right);
static sse_awk_val_t* __eval_binop_esse ( static sse_awk_val_t* __eval_binop_exp (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right); sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right);
static sse_awk_val_t* __eval_binop_concat ( static sse_awk_val_t* __eval_binop_concat (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right); sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right);
@ -198,14 +198,14 @@ static sse_char_t* __idxnde_to_str (
typedef sse_awk_val_t* (*binop_func_t) ( typedef sse_awk_val_t* (*binop_func_t) (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right); sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right);
typedef sse_awk_val_t* (*eval_esser_t) (sse_awk_run_t* run, sse_awk_nde_t* nde); typedef sse_awk_val_t* (*eval_expr_t) (sse_awk_run_t* run, sse_awk_nde_t* nde);
/* TODO: remove this function */ /* TODO: remove this function */
static int __printval (sse_awk_pair_t* pair, void* arg) static int __printval (sse_awk_pair_t* pair, void* arg)
{ {
sse_printf (SSE_T("%s = "), (const sse_char_t*)pair->key); xp_printf (SSE_T("%s = "), (const sse_char_t*)pair->key);
sse_awk_printval ((sse_awk_val_t*)pair->val); sse_awk_printval ((sse_awk_val_t*)pair->val);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
return 0; return 0;
} }
@ -269,8 +269,8 @@ int sse_awk_setglobal (sse_awk_run_t* run, sse_size_t idx, sse_awk_val_t* val)
} }
else else
{ {
/* due to the esseression evaluation rule, the /* due to the expression evaluation rule, the
* regular esseression can not be an assigned value */ * regular expression can not be an assigned value */
sse_awk_assert (run->awk, val->type != SSE_AWK_VAL_REX); sse_awk_assert (run->awk, val->type != SSE_AWK_VAL_REX);
fs_ptr = sse_awk_valtostr ( fs_ptr = sse_awk_valtostr (
@ -282,7 +282,7 @@ int sse_awk_setglobal (sse_awk_run_t* run, sse_size_t idx, sse_awk_val_t* val)
{ {
void* rex; void* rex;
/* compile the regular esseression */ /* compile the regular expression */
/* TODO: use safebuild */ /* TODO: use safebuild */
rex = sse_awk_buildrex ( rex = sse_awk_buildrex (
run->awk, fs_ptr, fs_len, &run->errnum); run->awk, fs_ptr, fs_len, &run->errnum);
@ -387,8 +387,8 @@ int sse_awk_setglobal (sse_awk_run_t* run, sse_size_t idx, sse_awk_val_t* val)
} }
else else
{ {
/* due to the esseression evaluation rule, the /* due to the expression evaluation rule, the
* regular esseression can not be an assigned value */ * regular expression can not be an assigned value */
sse_awk_assert (run->awk, val->type != SSE_AWK_VAL_REX); sse_awk_assert (run->awk, val->type != SSE_AWK_VAL_REX);
rs_ptr = sse_awk_valtostr ( rs_ptr = sse_awk_valtostr (
@ -400,7 +400,7 @@ int sse_awk_setglobal (sse_awk_run_t* run, sse_size_t idx, sse_awk_val_t* val)
{ {
void* rex; void* rex;
/* compile the regular esseression */ /* compile the regular expression */
/* TODO: use safebuild */ /* TODO: use safebuild */
rex = sse_awk_buildrex ( rex = sse_awk_buildrex (
run->awk, rs_ptr, rs_len, &run->errnum); run->awk, rs_ptr, rs_len, &run->errnum);
@ -1147,9 +1147,9 @@ static int __run_main (sse_awk_run_t* run, sse_awk_runarg_t* runarg)
} }
v = STACK_RETVAL(run); v = STACK_RETVAL(run);
sse_printf (SSE_T("Return Value - ")); xp_printf (SSE_T("Return Value - "));
sse_awk_printval (v); sse_awk_printval (v);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
/* the life of the global return value is over here /* the life of the global return value is over here
* unlike the return value of each function */ * unlike the return value of each function */
/*sse_awk_refdownval_nofree (awk, v);*/ /*sse_awk_refdownval_nofree (awk, v);*/
@ -1173,9 +1173,9 @@ sse_printf (SSE_T("\n"));
/* just reset the exit level */ /* just reset the exit level */
run->exit_level = EXIT_NONE; run->exit_level = EXIT_NONE;
sse_printf (SSE_T("-[VARIABLES]------------------------\n")); xp_printf (SSE_T("-[VARIABLES]------------------------\n"));
sse_awk_map_walk (&run->named, __printval, SSE_NULL); sse_awk_map_walk (&run->named, __printval, SSE_NULL);
sse_printf (SSE_T("-[END VARIABLES]--------------------------\n")); xp_printf (SSE_T("-[END VARIABLES]--------------------------\n"));
return n; return n;
} }
@ -1293,7 +1293,7 @@ static int __run_pattern_block (
/* pattern { ... } */ /* pattern { ... } */
sse_awk_val_t* v1; sse_awk_val_t* v1;
v1 = __eval_esseression (run, ptn); v1 = __eval_expression (run, ptn);
if (v1 == SSE_NULL) return -1; if (v1 == SSE_NULL) return -1;
sse_awk_refupval (v1); sse_awk_refupval (v1);
@ -1319,7 +1319,7 @@ static int __run_pattern_block (
{ {
sse_awk_val_t* v1; sse_awk_val_t* v1;
v1 = __eval_esseression (run, ptn); v1 = __eval_expression (run, ptn);
if (v1 == SSE_NULL) return -1; if (v1 == SSE_NULL) return -1;
sse_awk_refupval (v1); sse_awk_refupval (v1);
@ -1341,7 +1341,7 @@ static int __run_pattern_block (
{ {
sse_awk_val_t* v2; sse_awk_val_t* v2;
v2 = __eval_esseression (run, ptn->next); v2 = __eval_expression (run, ptn->next);
if (v2 == SSE_NULL) return -1; if (v2 == SSE_NULL) return -1;
sse_awk_refupval (v2); sse_awk_refupval (v2);
@ -1399,7 +1399,7 @@ static int __run_block (sse_awk_run_t* run, sse_awk_nde_blk_t* nde)
p = nde->body; p = nde->body;
nlocals = nde->nlocals; nlocals = nde->nlocals;
/*sse_printf (SSE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/ /*xp_printf (SSE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/
saved_stack_top = run->stack_top; saved_stack_top = run->stack_top;
/* secure space for local variables */ /* secure space for local variables */
@ -1416,10 +1416,10 @@ static int __run_block (sse_awk_run_t* run, sse_awk_nde_blk_t* nde)
/* refupval is not required for sse_awk_val_nil */ /* refupval is not required for sse_awk_val_nil */
} }
/*sse_printf (SSE_T("executing block statements\n"));*/ /*xp_printf (SSE_T("executing block statements\n"));*/
while (p != SSE_NULL && run->exit_level == EXIT_NONE) while (p != SSE_NULL && run->exit_level == EXIT_NONE)
{ {
/*sse_printf (SSE_T("running a statement\n"));*/ /*xp_printf (SSE_T("running a statement\n"));*/
if (__run_statement(run,p) == -1) if (__run_statement(run,p) == -1)
{ {
n = -1; n = -1;
@ -1428,7 +1428,7 @@ static int __run_block (sse_awk_run_t* run, sse_awk_nde_blk_t* nde)
p = p->next; p = p->next;
} }
/*sse_printf (SSE_T("popping off local variables\n"));*/ /*xp_printf (SSE_T("popping off local variables\n"));*/
/* pop off local variables */ /* pop off local variables */
nlocals = nde->nlocals; nlocals = nde->nlocals;
while (nlocals > 0) while (nlocals > 0)
@ -1546,7 +1546,7 @@ static int __run_statement (sse_awk_run_t* run, sse_awk_nde_t* nde)
default: default:
{ {
sse_awk_val_t* v; sse_awk_val_t* v;
v = __eval_esseression(run,nde); v = __eval_expression(run,nde);
if (v == SSE_NULL) return -1; if (v == SSE_NULL) return -1;
sse_awk_refupval (v); sse_awk_refupval (v);
@ -1564,12 +1564,12 @@ static int __run_if (sse_awk_run_t* run, sse_awk_nde_if_t* nde)
sse_awk_val_t* test; sse_awk_val_t* test;
int n = 0; int n = 0;
/* the test esseression for the if statement cannot have /* the test expression for the if statement cannot have
* chained esseressions. this should not be allowed by the * chained expressions. this should not be allowed by the
* parser first of all */ * parser first of all */
sse_awk_assert (run->awk, nde->test->next == SSE_NULL); sse_awk_assert (run->awk, nde->test->next == SSE_NULL);
test = __eval_esseression (run, nde->test); test = __eval_expression (run, nde->test);
if (test == SSE_NULL) return -1; if (test == SSE_NULL) return -1;
sse_awk_refupval (test); sse_awk_refupval (test);
@ -1592,14 +1592,14 @@ static int __run_while (sse_awk_run_t* run, sse_awk_nde_while_t* nde)
if (nde->type == SSE_AWK_NDE_WHILE) if (nde->type == SSE_AWK_NDE_WHILE)
{ {
/* no chained esseressions are allowed for the test /* no chained expressions are allowed for the test
* esseression of the while statement */ * expression of the while statement */
sse_awk_assert (run->awk, nde->test->next == SSE_NULL); sse_awk_assert (run->awk, nde->test->next == SSE_NULL);
/* TODO: handle run-time abortion... */ /* TODO: handle run-time abortion... */
while (1) while (1)
{ {
test = __eval_esseression (run, nde->test); test = __eval_expression (run, nde->test);
if (test == SSE_NULL) return -1; if (test == SSE_NULL) return -1;
sse_awk_refupval (test); sse_awk_refupval (test);
@ -1634,8 +1634,8 @@ static int __run_while (sse_awk_run_t* run, sse_awk_nde_while_t* nde)
} }
else if (nde->type == SSE_AWK_NDE_DOWHILE) else if (nde->type == SSE_AWK_NDE_DOWHILE)
{ {
/* no chained esseressions are allowed for the test /* no chained expressions are allowed for the test
* esseression of the while statement */ * expression of the while statement */
sse_awk_assert (run->awk, nde->test->next == SSE_NULL); sse_awk_assert (run->awk, nde->test->next == SSE_NULL);
/* TODO: handle run-time abortion... */ /* TODO: handle run-time abortion... */
@ -1654,7 +1654,7 @@ static int __run_while (sse_awk_run_t* run, sse_awk_nde_while_t* nde)
} }
else if (run->exit_level != EXIT_NONE) break; else if (run->exit_level != EXIT_NONE) break;
test = __eval_esseression (run, nde->test); test = __eval_expression (run, nde->test);
if (test == SSE_NULL) return -1; if (test == SSE_NULL) return -1;
sse_awk_refupval (test); sse_awk_refupval (test);
@ -1680,7 +1680,7 @@ static int __run_for (sse_awk_run_t* run, sse_awk_nde_for_t* nde)
if (nde->init != SSE_NULL) if (nde->init != SSE_NULL)
{ {
sse_awk_assert (run->awk, nde->init->next == SSE_NULL); sse_awk_assert (run->awk, nde->init->next == SSE_NULL);
val = __eval_esseression(run,nde->init); val = __eval_expression(run,nde->init);
if (val == SSE_NULL) return -1; if (val == SSE_NULL) return -1;
sse_awk_refupval (val); sse_awk_refupval (val);
@ -1693,11 +1693,11 @@ static int __run_for (sse_awk_run_t* run, sse_awk_nde_for_t* nde)
{ {
sse_awk_val_t* test; sse_awk_val_t* test;
/* no chained esseressions for the test esseression of /* no chained expressions for the test expression of
* the for statement are allowed */ * the for statement are allowed */
sse_awk_assert (run->awk, nde->test->next == SSE_NULL); sse_awk_assert (run->awk, nde->test->next == SSE_NULL);
test = __eval_esseression (run, nde->test); test = __eval_expression (run, nde->test);
if (test == SSE_NULL) return -1; if (test == SSE_NULL) return -1;
sse_awk_refupval (test); sse_awk_refupval (test);
@ -1739,7 +1739,7 @@ static int __run_for (sse_awk_run_t* run, sse_awk_nde_for_t* nde)
if (nde->incr != SSE_NULL) if (nde->incr != SSE_NULL)
{ {
sse_awk_assert (run->awk, nde->incr->next == SSE_NULL); sse_awk_assert (run->awk, nde->incr->next == SSE_NULL);
val = __eval_esseression(run,nde->incr); val = __eval_expression(run,nde->incr);
if (val == SSE_NULL) return -1; if (val == SSE_NULL) return -1;
sse_awk_refupval (val); sse_awk_refupval (val);
@ -1786,20 +1786,20 @@ static int __walk_foreach (sse_awk_pair_t* pair, void* arg)
static int __run_foreach (sse_awk_run_t* run, sse_awk_nde_foreach_t* nde) static int __run_foreach (sse_awk_run_t* run, sse_awk_nde_foreach_t* nde)
{ {
int n; int n;
sse_awk_nde_esse_t* test; sse_awk_nde_exp_t* test;
sse_awk_val_t* rv; sse_awk_val_t* rv;
sse_awk_map_t* map; sse_awk_map_t* map;
struct __foreach_walker_t walker; struct __foreach_walker_t walker;
test = (sse_awk_nde_esse_t*)nde->test; test = (sse_awk_nde_exp_t*)nde->test;
sse_awk_assert (run->awk, test->type == SSE_AWK_NDE_ESSE_BIN && sse_awk_assert (run->awk, test->type == SSE_AWK_NDE_EXP_BIN &&
test->opcode == SSE_AWK_BINOP_IN); test->opcode == SSE_AWK_BINOP_IN);
/* chained esseressions should not be allowed /* chained expressions should not be allowed
* by the parser first of all */ * by the parser first of all */
sse_awk_assert (run->awk, test->right->next == SSE_NULL); sse_awk_assert (run->awk, test->right->next == SSE_NULL);
rv = __eval_esseression (run, test->right); rv = __eval_expression (run, test->right);
if (rv == SSE_NULL) return -1; if (rv == SSE_NULL) return -1;
sse_awk_refupval (rv); sse_awk_refupval (rv);
@ -1837,18 +1837,18 @@ static int __run_return (sse_awk_run_t* run, sse_awk_nde_return_t* nde)
{ {
sse_awk_val_t* val; sse_awk_val_t* val;
/* chained esseressions should not be allowed /* chained expressions should not be allowed
* by the parser first of all */ * by the parser first of all */
sse_awk_assert (run->awk, nde->val->next == SSE_NULL); sse_awk_assert (run->awk, nde->val->next == SSE_NULL);
/*sse_printf (SSE_T("returning....\n"));*/ /*xp_printf (SSE_T("returning....\n"));*/
val = __eval_esseression (run, nde->val); val = __eval_expression (run, nde->val);
if (val == SSE_NULL) return -1; if (val == SSE_NULL) return -1;
sse_awk_refdownval (run, STACK_RETVAL(run)); sse_awk_refdownval (run, STACK_RETVAL(run));
STACK_RETVAL(run) = val; STACK_RETVAL(run) = val;
sse_awk_refupval (val); /* see __eval_call for the trick */ sse_awk_refupval (val); /* see __eval_call for the trick */
/*sse_printf (SSE_T("set return value....\n"));*/ /*xp_printf (SSE_T("set return value....\n"));*/
} }
run->exit_level = EXIT_FUNCTION; run->exit_level = EXIT_FUNCTION;
@ -1861,11 +1861,11 @@ static int __run_exit (sse_awk_run_t* run, sse_awk_nde_exit_t* nde)
{ {
sse_awk_val_t* val; sse_awk_val_t* val;
/* chained esseressions should not be allowed /* chained expressions should not be allowed
* by the parser first of all */ * by the parser first of all */
sse_awk_assert (run->awk, nde->val->next == SSE_NULL); sse_awk_assert (run->awk, nde->val->next == SSE_NULL);
val = __eval_esseression (run, nde->val); val = __eval_expression (run, nde->val);
if (val == SSE_NULL) return -1; if (val == SSE_NULL) return -1;
sse_awk_refdownval (run, STACK_RETVAL_GLOBAL(run)); sse_awk_refdownval (run, STACK_RETVAL_GLOBAL(run));
@ -1882,7 +1882,7 @@ static int __run_next (sse_awk_run_t* run, sse_awk_nde_next_t* nde)
{ {
/* the parser checks if next has been called in the begin/end /* the parser checks if next has been called in the begin/end
* block or whereever inappropriate. so the runtime doesn't * block or whereever inappropriate. so the runtime doesn't
* check that esselicitly */ * check that explicitly */
if (run->active_block == (sse_awk_nde_blk_t*)run->awk->tree.begin || if (run->active_block == (sse_awk_nde_blk_t*)run->awk->tree.begin ||
run->active_block == (sse_awk_nde_blk_t*)run->awk->tree.end) run->active_block == (sse_awk_nde_blk_t*)run->awk->tree.end)
@ -1988,7 +1988,7 @@ static int __run_delete (sse_awk_run_t* run, sse_awk_nde_delete_t* nde)
sse_awk_assert (run->awk, var->idx != SSE_NULL); sse_awk_assert (run->awk, var->idx != SSE_NULL);
idx = __eval_esseression (run, var->idx); idx = __eval_expression (run, var->idx);
if (idx == SSE_NULL) return -1; if (idx == SSE_NULL) return -1;
sse_awk_refupval (idx); sse_awk_refupval (idx);
@ -2079,7 +2079,7 @@ static int __run_delete (sse_awk_run_t* run, sse_awk_nde_delete_t* nde)
sse_awk_assert (run->awk, var->idx != SSE_NULL); sse_awk_assert (run->awk, var->idx != SSE_NULL);
idx = __eval_esseression (run, var->idx); idx = __eval_expression (run, var->idx);
if (idx == SSE_NULL) return -1; if (idx == SSE_NULL) return -1;
sse_awk_refupval (idx); sse_awk_refupval (idx);
@ -2127,7 +2127,7 @@ static int __run_print (sse_awk_run_t* run, sse_awk_nde_print_t* nde)
{ {
sse_size_t len; sse_size_t len;
v = __eval_esseression (run, p->out); v = __eval_expression (run, p->out);
if (v == SSE_NULL) return -1; if (v == SSE_NULL) return -1;
sse_awk_refupval (v); sse_awk_refupval (v);
@ -2213,7 +2213,7 @@ static int __run_print (sse_awk_run_t* run, sse_awk_nde_print_t* nde)
} }
} }
v = __eval_esseression (run, np); v = __eval_expression (run, np);
if (v == SSE_NULL) if (v == SSE_NULL)
{ {
if (out != SSE_NULL) SSE_AWK_FREE (run->awk, out); if (out != SSE_NULL) SSE_AWK_FREE (run->awk, out);
@ -2255,12 +2255,12 @@ skip_write:
return 0; return 0;
} }
static sse_awk_val_t* __eval_esseression (sse_awk_run_t* run, sse_awk_nde_t* nde) static sse_awk_val_t* __eval_expression (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
sse_awk_val_t* v; sse_awk_val_t* v;
int n, errnum; int n, errnum;
v = __eval_esseression0 (run, nde); v = __eval_expression0 (run, nde);
if (v == SSE_NULL) return SSE_NULL; if (v == SSE_NULL) return SSE_NULL;
if (v->type == SSE_AWK_VAL_REX) if (v->type == SSE_AWK_VAL_REX)
@ -2302,9 +2302,9 @@ static sse_awk_val_t* __eval_esseression (sse_awk_run_t* run, sse_awk_nde_t* nde
return v; return v;
} }
static sse_awk_val_t* __eval_esseression0 (sse_awk_run_t* run, sse_awk_nde_t* nde) static sse_awk_val_t* __eval_expression0 (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
static eval_esser_t __eval_func[] = static eval_expr_t __eval_func[] =
{ {
/* 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 */
@ -2356,7 +2356,7 @@ static sse_awk_val_t* __eval_assignment (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_awk_assert (run->awk, ass->left != SSE_NULL && ass->right != SSE_NULL); sse_awk_assert (run->awk, ass->left != SSE_NULL && ass->right != SSE_NULL);
sse_awk_assert (run->awk, ass->right->next == SSE_NULL); sse_awk_assert (run->awk, ass->right->next == SSE_NULL);
val = __eval_esseression (run, ass->right); val = __eval_expression (run, ass->right);
if (val == SSE_NULL) return SSE_NULL; if (val == SSE_NULL) return SSE_NULL;
sse_awk_refupval (val); sse_awk_refupval (val);
@ -2366,7 +2366,7 @@ static sse_awk_val_t* __eval_assignment (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_awk_val_t* val2, * tmp; sse_awk_val_t* val2, * tmp;
sse_awk_assert (run->awk, ass->left->next == SSE_NULL); sse_awk_assert (run->awk, ass->left->next == SSE_NULL);
val2 = __eval_esseression (run, ass->left); val2 = __eval_expression (run, ass->left);
if (val2 == SSE_NULL) if (val2 == SSE_NULL)
{ {
sse_awk_refdownval (run, val); sse_awk_refdownval (run, val);
@ -2395,9 +2395,9 @@ static sse_awk_val_t* __eval_assignment (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
tmp = __eval_binop_mod (run, val2, val); tmp = __eval_binop_mod (run, val2, val);
} }
else if (ass->opcode == SSE_AWK_ASSOP_ESSE) else if (ass->opcode == SSE_AWK_ASSOP_EXP)
{ {
tmp = __eval_binop_esse (run, val2, val); tmp = __eval_binop_exp (run, val2, val);
} }
else else
{ {
@ -2620,7 +2620,7 @@ static sse_awk_val_t* __do_assignment_map (
if (str == SSE_NULL) return SSE_NULL; if (str == SSE_NULL) return SSE_NULL;
/* /*
sse_printf (SSE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type); xp_printf (SSE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type);
*/ */
n = sse_awk_map_putx (map->map, str, len, val, SSE_NULL); n = sse_awk_map_putx (map->map, str, len, val, SSE_NULL);
if (n < 0) if (n < 0)
@ -2644,7 +2644,7 @@ static sse_awk_val_t* __do_assignment_pos (
sse_size_t len; sse_size_t len;
int n; int n;
v = __eval_esseression (run, pos->val); v = __eval_expression (run, pos->val);
if (v == SSE_NULL) return SSE_NULL; if (v == SSE_NULL) return SSE_NULL;
sse_awk_refupval (v); sse_awk_refupval (v);
@ -2704,49 +2704,49 @@ static sse_awk_val_t* __eval_binary (sse_awk_run_t* run, sse_awk_nde_t* nde)
__eval_binop_mul, __eval_binop_mul,
__eval_binop_div, __eval_binop_div,
__eval_binop_mod, __eval_binop_mod,
__eval_binop_esse, __eval_binop_exp,
__eval_binop_concat, __eval_binop_concat,
SSE_NULL, /* __eval_binop_ma */ SSE_NULL, /* __eval_binop_ma */
SSE_NULL /* __eval_binop_nm */ SSE_NULL /* __eval_binop_nm */
}; };
sse_awk_nde_esse_t* esse = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* exp = (sse_awk_nde_exp_t*)nde;
sse_awk_val_t* left, * right, * res; sse_awk_val_t* left, * right, * res;
sse_awk_assert (run->awk, esse->type == SSE_AWK_NDE_ESSE_BIN); sse_awk_assert (run->awk, exp->type == SSE_AWK_NDE_EXP_BIN);
if (esse->opcode == SSE_AWK_BINOP_LAND) if (exp->opcode == SSE_AWK_BINOP_LAND)
{ {
res = __eval_binop_land (run, esse->left, esse->right); res = __eval_binop_land (run, exp->left, exp->right);
} }
else if (esse->opcode == SSE_AWK_BINOP_LOR) else if (exp->opcode == SSE_AWK_BINOP_LOR)
{ {
res = __eval_binop_lor (run, esse->left, esse->right); res = __eval_binop_lor (run, exp->left, exp->right);
} }
else if (esse->opcode == SSE_AWK_BINOP_IN) else if (exp->opcode == SSE_AWK_BINOP_IN)
{ {
/* treat the in operator specially */ /* treat the in operator specially */
res = __eval_binop_in (run, esse->left, esse->right); res = __eval_binop_in (run, exp->left, exp->right);
} }
else if (esse->opcode == SSE_AWK_BINOP_NM) else if (exp->opcode == SSE_AWK_BINOP_NM)
{ {
res = __eval_binop_nm (run, esse->left, esse->right); res = __eval_binop_nm (run, exp->left, exp->right);
} }
else if (esse->opcode == SSE_AWK_BINOP_MA) else if (exp->opcode == SSE_AWK_BINOP_MA)
{ {
res = __eval_binop_ma (run, esse->left, esse->right); res = __eval_binop_ma (run, exp->left, exp->right);
} }
else else
{ {
sse_awk_assert (run->awk, esse->left->next == SSE_NULL); sse_awk_assert (run->awk, exp->left->next == SSE_NULL);
left = __eval_esseression (run, esse->left); left = __eval_expression (run, exp->left);
if (left == SSE_NULL) return SSE_NULL; if (left == SSE_NULL) return SSE_NULL;
sse_awk_refupval (left); sse_awk_refupval (left);
sse_awk_assert (run->awk, esse->right->next == SSE_NULL); sse_awk_assert (run->awk, exp->right->next == SSE_NULL);
right = __eval_esseression (run, esse->right); right = __eval_expression (run, exp->right);
if (right == SSE_NULL) if (right == SSE_NULL)
{ {
sse_awk_refdownval (run, left); sse_awk_refdownval (run, left);
@ -2755,11 +2755,11 @@ static sse_awk_val_t* __eval_binary (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_awk_refupval (right); sse_awk_refupval (right);
sse_awk_assert (run->awk, esse->opcode >= 0 && sse_awk_assert (run->awk, exp->opcode >= 0 &&
esse->opcode < sse_countof(__binop_func)); exp->opcode < sse_countof(__binop_func));
sse_awk_assert (run->awk, __binop_func[esse->opcode] != SSE_NULL); sse_awk_assert (run->awk, __binop_func[exp->opcode] != SSE_NULL);
res = __binop_func[esse->opcode] (run, left, right); res = __binop_func[exp->opcode] (run, left, right);
sse_awk_refdownval (run, left); sse_awk_refdownval (run, left);
sse_awk_refdownval (run, right); sse_awk_refdownval (run, right);
@ -2785,7 +2785,7 @@ static sse_awk_val_t* __eval_binop_lor (
sse_awk_val_t* lv, * rv, * res; sse_awk_val_t* lv, * rv, * res;
sse_awk_assert (run->awk, left->next == SSE_NULL); sse_awk_assert (run->awk, left->next == SSE_NULL);
lv = __eval_esseression (run, left); lv = __eval_expression (run, left);
if (lv == SSE_NULL) return SSE_NULL; if (lv == SSE_NULL) return SSE_NULL;
sse_awk_refupval (lv); sse_awk_refupval (lv);
@ -2797,7 +2797,7 @@ static sse_awk_val_t* __eval_binop_lor (
else else
{ {
sse_awk_assert (run->awk, right->next == SSE_NULL); sse_awk_assert (run->awk, right->next == SSE_NULL);
rv = __eval_esseression (run, right); rv = __eval_expression (run, right);
if (rv == SSE_NULL) if (rv == SSE_NULL)
{ {
sse_awk_refdownval (run, lv); sse_awk_refdownval (run, lv);
@ -2833,7 +2833,7 @@ static sse_awk_val_t* __eval_binop_land (
sse_awk_val_t* lv, * rv, * res; sse_awk_val_t* lv, * rv, * res;
sse_awk_assert (run->awk, left->next == SSE_NULL); sse_awk_assert (run->awk, left->next == SSE_NULL);
lv = __eval_esseression (run, left); lv = __eval_expression (run, left);
if (lv == SSE_NULL) return SSE_NULL; if (lv == SSE_NULL) return SSE_NULL;
sse_awk_refupval (lv); sse_awk_refupval (lv);
@ -2845,7 +2845,7 @@ static sse_awk_val_t* __eval_binop_land (
else else
{ {
sse_awk_assert (run->awk, right->next == SSE_NULL); sse_awk_assert (run->awk, right->next == SSE_NULL);
rv = __eval_esseression (run, right); rv = __eval_expression (run, right);
if (rv == SSE_NULL) if (rv == SSE_NULL)
{ {
sse_awk_refdownval (run, lv); sse_awk_refdownval (run, lv);
@ -2890,7 +2890,7 @@ static sse_awk_val_t* __eval_binop_in (
/* evaluate the right-hand side of the operator */ /* evaluate the right-hand side of the operator */
sse_awk_assert (run->awk, right->next == SSE_NULL); sse_awk_assert (run->awk, right->next == SSE_NULL);
rv = __eval_esseression (run, right); rv = __eval_expression (run, right);
if (rv == SSE_NULL) if (rv == SSE_NULL)
{ {
SSE_AWK_FREE (run->awk, str); SSE_AWK_FREE (run->awk, str);
@ -3500,7 +3500,7 @@ static sse_awk_val_t* __eval_binop_mod (
return res; return res;
} }
static sse_awk_val_t* __eval_binop_esse ( static sse_awk_val_t* __eval_binop_exp (
sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right) sse_awk_run_t* run, sse_awk_val_t* left, sse_awk_val_t* right)
{ {
int n1, n2, n3; int n1, n2, n3;
@ -3585,7 +3585,7 @@ static sse_awk_val_t* __eval_binop_ma (
sse_awk_assert (run->awk, left->next == SSE_NULL); sse_awk_assert (run->awk, left->next == SSE_NULL);
sse_awk_assert (run->awk, right->next == SSE_NULL); sse_awk_assert (run->awk, right->next == SSE_NULL);
lv = __eval_esseression (run, left); lv = __eval_expression (run, left);
if (lv == SSE_NULL) if (lv == SSE_NULL)
{ {
return SSE_NULL; return SSE_NULL;
@ -3593,7 +3593,7 @@ static sse_awk_val_t* __eval_binop_ma (
sse_awk_refupval (lv); sse_awk_refupval (lv);
rv = __eval_esseression0 (run, right); rv = __eval_expression0 (run, right);
if (rv == SSE_NULL) if (rv == SSE_NULL)
{ {
sse_awk_refdownval (run, lv); sse_awk_refdownval (run, lv);
@ -3618,12 +3618,12 @@ static sse_awk_val_t* __eval_binop_nm (
sse_awk_assert (run->awk, left->next == SSE_NULL); sse_awk_assert (run->awk, left->next == SSE_NULL);
sse_awk_assert (run->awk, right->next == SSE_NULL); sse_awk_assert (run->awk, right->next == SSE_NULL);
lv = __eval_esseression (run, left); lv = __eval_expression (run, left);
if (lv == SSE_NULL) return SSE_NULL; if (lv == SSE_NULL) return SSE_NULL;
sse_awk_refupval (lv); sse_awk_refupval (lv);
rv = __eval_esseression0 (run, right); rv = __eval_expression0 (run, right);
if (rv == SSE_NULL) if (rv == SSE_NULL)
{ {
sse_awk_refdownval (run, lv); sse_awk_refdownval (run, lv);
@ -3743,18 +3743,18 @@ static sse_awk_val_t* __eval_binop_match0 (
static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde) static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
sse_awk_val_t* left, * res = SSE_NULL; sse_awk_val_t* left, * res = SSE_NULL;
sse_awk_nde_esse_t* esse = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* exp = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (run->awk, esse->type == SSE_AWK_NDE_ESSE_UNR); sse_awk_assert (run->awk, exp->type == SSE_AWK_NDE_EXP_UNR);
sse_awk_assert (run->awk, esse->left != SSE_NULL && esse->right == SSE_NULL); sse_awk_assert (run->awk, exp->left != SSE_NULL && exp->right == SSE_NULL);
sse_awk_assert (run->awk, esse->left->next == SSE_NULL); sse_awk_assert (run->awk, exp->left->next == SSE_NULL);
left = __eval_esseression (run, esse->left); left = __eval_expression (run, exp->left);
if (left == SSE_NULL) return SSE_NULL; if (left == SSE_NULL) return SSE_NULL;
sse_awk_refupval (left); sse_awk_refupval (left);
if (esse->opcode == SSE_AWK_UNROP_PLUS) if (exp->opcode == SSE_AWK_UNROP_PLUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3772,7 +3772,7 @@ static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde)
PANIC (run, SSE_AWK_EOPERAND); PANIC (run, SSE_AWK_EOPERAND);
} }
} }
else if (esse->opcode == SSE_AWK_UNROP_MINUS) else if (exp->opcode == SSE_AWK_UNROP_MINUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3790,7 +3790,7 @@ static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde)
PANIC (run, SSE_AWK_EOPERAND); PANIC (run, SSE_AWK_EOPERAND);
} }
} }
else if (esse->opcode == SSE_AWK_UNROP_NOT) else if (exp->opcode == SSE_AWK_UNROP_NOT)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3808,7 +3808,7 @@ static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde)
PANIC (run, SSE_AWK_EOPERAND); PANIC (run, SSE_AWK_EOPERAND);
} }
} }
else if (esse->opcode == SSE_AWK_UNROP_BNOT) else if (exp->opcode == SSE_AWK_UNROP_BNOT)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3835,27 +3835,27 @@ static sse_awk_val_t* __eval_unary (sse_awk_run_t* run, sse_awk_nde_t* nde)
static sse_awk_val_t* __eval_incpre (sse_awk_run_t* run, sse_awk_nde_t* nde) static sse_awk_val_t* __eval_incpre (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
sse_awk_val_t* left, * res; sse_awk_val_t* left, * res;
sse_awk_nde_esse_t* esse = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* exp = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (run->awk, esse->type == SSE_AWK_NDE_ESSE_INCPRE); sse_awk_assert (run->awk, exp->type == SSE_AWK_NDE_EXP_INCPRE);
sse_awk_assert (run->awk, esse->left != SSE_NULL && esse->right == SSE_NULL); sse_awk_assert (run->awk, exp->left != SSE_NULL && exp->right == SSE_NULL);
/* this way of checking if the l-value is assignable is /* this way of checking if the l-value is assignable is
* ugly as it is dependent of the values defined in tree.h. * ugly as it is dependent of the values defined in tree.h.
* but let's keep going this way for the time being. */ * but let's keep going this way for the time being. */
if (esse->left->type < SSE_AWK_NDE_NAMED || if (exp->left->type < SSE_AWK_NDE_NAMED ||
esse->left->type > SSE_AWK_NDE_ARGIDX) exp->left->type > SSE_AWK_NDE_ARGIDX)
{ {
PANIC (run, SSE_AWK_EOPERAND); PANIC (run, SSE_AWK_EOPERAND);
} }
sse_awk_assert (run->awk, esse->left->next == SSE_NULL); sse_awk_assert (run->awk, exp->left->next == SSE_NULL);
left = __eval_esseression (run, esse->left); left = __eval_expression (run, exp->left);
if (left == SSE_NULL) return SSE_NULL; if (left == SSE_NULL) return SSE_NULL;
sse_awk_refupval (left); sse_awk_refupval (left);
if (esse->opcode == SSE_AWK_INCOP_PLUS) if (exp->opcode == SSE_AWK_INCOP_PLUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3907,7 +3907,7 @@ static sse_awk_val_t* __eval_incpre (sse_awk_run_t* run, sse_awk_nde_t* nde)
} }
} }
} }
else if (esse->opcode == SSE_AWK_INCOP_MINUS) else if (exp->opcode == SSE_AWK_INCOP_MINUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -3966,7 +3966,7 @@ static sse_awk_val_t* __eval_incpre (sse_awk_run_t* run, sse_awk_nde_t* nde)
PANIC (run, SSE_AWK_EINTERNAL); PANIC (run, SSE_AWK_EINTERNAL);
} }
if (__do_assignment (run, esse->left, res) == SSE_NULL) if (__do_assignment (run, exp->left, res) == SSE_NULL)
{ {
sse_awk_refdownval (run, left); sse_awk_refdownval (run, left);
return SSE_NULL; return SSE_NULL;
@ -3979,27 +3979,27 @@ static sse_awk_val_t* __eval_incpre (sse_awk_run_t* run, sse_awk_nde_t* nde)
static sse_awk_val_t* __eval_incpst (sse_awk_run_t* run, sse_awk_nde_t* nde) static sse_awk_val_t* __eval_incpst (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
sse_awk_val_t* left, * res, * res2; sse_awk_val_t* left, * res, * res2;
sse_awk_nde_esse_t* esse = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* exp = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (run->awk, esse->type == SSE_AWK_NDE_ESSE_INCPST); sse_awk_assert (run->awk, exp->type == SSE_AWK_NDE_EXP_INCPST);
sse_awk_assert (run->awk, esse->left != SSE_NULL && esse->right == SSE_NULL); sse_awk_assert (run->awk, exp->left != SSE_NULL && exp->right == SSE_NULL);
/* this way of checking if the l-value is assignable is /* this way of checking if the l-value is assignable is
* ugly as it is dependent of the values defined in tree.h. * ugly as it is dependent of the values defined in tree.h.
* but let's keep going this way for the time being. */ * but let's keep going this way for the time being. */
if (esse->left->type < SSE_AWK_NDE_NAMED || if (exp->left->type < SSE_AWK_NDE_NAMED ||
esse->left->type > SSE_AWK_NDE_ARGIDX) exp->left->type > SSE_AWK_NDE_ARGIDX)
{ {
PANIC (run, SSE_AWK_EOPERAND); PANIC (run, SSE_AWK_EOPERAND);
} }
sse_awk_assert (run->awk, esse->left->next == SSE_NULL); sse_awk_assert (run->awk, exp->left->next == SSE_NULL);
left = __eval_esseression (run, esse->left); left = __eval_expression (run, exp->left);
if (left == SSE_NULL) return SSE_NULL; if (left == SSE_NULL) return SSE_NULL;
sse_awk_refupval (left); sse_awk_refupval (left);
if (esse->opcode == SSE_AWK_INCOP_PLUS) if (exp->opcode == SSE_AWK_INCOP_PLUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -4087,7 +4087,7 @@ static sse_awk_val_t* __eval_incpst (sse_awk_run_t* run, sse_awk_nde_t* nde)
} }
} }
} }
else if (esse->opcode == SSE_AWK_INCOP_MINUS) else if (exp->opcode == SSE_AWK_INCOP_MINUS)
{ {
if (left->type == SSE_AWK_VAL_INT) if (left->type == SSE_AWK_VAL_INT)
{ {
@ -4182,7 +4182,7 @@ static sse_awk_val_t* __eval_incpst (sse_awk_run_t* run, sse_awk_nde_t* nde)
PANIC (run, SSE_AWK_EINTERNAL); PANIC (run, SSE_AWK_EINTERNAL);
} }
if (__do_assignment (run, esse->left, res2) == SSE_NULL) if (__do_assignment (run, exp->left, res2) == SSE_NULL)
{ {
sse_awk_refdownval (run, left); sse_awk_refdownval (run, left);
return SSE_NULL; return SSE_NULL;
@ -4198,7 +4198,7 @@ static sse_awk_val_t* __eval_cnd (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_awk_nde_cnd_t* cnd = (sse_awk_nde_cnd_t*)nde; sse_awk_nde_cnd_t* cnd = (sse_awk_nde_cnd_t*)nde;
sse_awk_assert (run->awk, cnd->test->next == SSE_NULL); sse_awk_assert (run->awk, cnd->test->next == SSE_NULL);
tv = __eval_esseression (run, cnd->test); tv = __eval_expression (run, cnd->test);
if (tv == SSE_NULL) return SSE_NULL; if (tv == SSE_NULL) return SSE_NULL;
sse_awk_refupval (tv); sse_awk_refupval (tv);
@ -4206,8 +4206,8 @@ static sse_awk_val_t* __eval_cnd (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_awk_assert (run->awk, cnd->left->next == SSE_NULL && sse_awk_assert (run->awk, cnd->left->next == SSE_NULL &&
cnd->right->next == SSE_NULL); cnd->right->next == SSE_NULL);
v = (sse_awk_valtobool (run, tv))? v = (sse_awk_valtobool (run, tv))?
__eval_esseression (run, cnd->left): __eval_expression (run, cnd->left):
__eval_esseression (run, cnd->right); __eval_expression (run, cnd->right);
sse_awk_refdownval (run, tv); sse_awk_refdownval (run, tv);
return v; return v;
@ -4327,7 +4327,7 @@ static sse_awk_val_t* __eval_call (
saved_stack_top = run->stack_top; saved_stack_top = run->stack_top;
/*sse_printf (SSE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */ /*xp_printf (SSE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */
if (__raw_push(run,(void*)run->stack_base) == -1) if (__raw_push(run,(void*)run->stack_base) == -1)
{ {
PANIC (run, SSE_AWK_ENOMEM); PANIC (run, SSE_AWK_ENOMEM);
@ -4383,13 +4383,13 @@ static sse_awk_val_t* __eval_call (
else if (bfn_arg_spec != SSE_NULL && else if (bfn_arg_spec != SSE_NULL &&
bfn_arg_spec[nargs] == SSE_T('x')) bfn_arg_spec[nargs] == SSE_T('x'))
{ {
/* a regular esseression is passed to /* a regular expression is passed to
* the function as it is */ * the function as it is */
v = __eval_esseression0 (run, p); v = __eval_expression0 (run, p);
} }
else else
{ {
v = __eval_esseression (run, p); v = __eval_expression (run, p);
} }
if (v == SSE_NULL) if (v == SSE_NULL)
{ {
@ -4475,7 +4475,7 @@ static sse_awk_val_t* __eval_call (
run->stack_base = saved_stack_top; run->stack_base = saved_stack_top;
STACK_NARGS(run) = (void*)nargs; STACK_NARGS(run) = (void*)nargs;
/*sse_printf (SSE_T("running function body\n")); */ /*xp_printf (SSE_T("running function body\n")); */
if (afn != SSE_NULL) if (afn != SSE_NULL)
{ {
@ -4495,16 +4495,16 @@ static sse_awk_val_t* __eval_call (
n = call->what.bfn.handler (run); n = call->what.bfn.handler (run);
} }
/*sse_printf (SSE_T("block run complete\n")); */ /*xp_printf (SSE_T("block run complete\n")); */
/* refdown args in the run.stack */ /* refdown args in the run.stack */
nargs = (sse_size_t)STACK_NARGS(run); nargs = (sse_size_t)STACK_NARGS(run);
/*sse_printf (SSE_T("block run complete nargs = %d\n"), (int)nargs); */ /*xp_printf (SSE_T("block run complete nargs = %d\n"), (int)nargs); */
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
sse_awk_refdownval (run, STACK_ARG(run,i)); sse_awk_refdownval (run, STACK_ARG(run,i));
} }
/*sse_printf (SSE_T("got return value\n")); */ /*xp_printf (SSE_T("got return value\n")); */
/* this trick has been mentioned in __run_return. /* this trick has been mentioned in __run_return.
* adjust the reference count of the return value. * adjust the reference count of the return value.
@ -4519,7 +4519,7 @@ static sse_awk_val_t* __eval_call (
if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE; if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE;
/*sse_printf (SSE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */ /*xp_printf (SSE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */
return (n == -1)? SSE_NULL: v; return (n == -1)? SSE_NULL: v;
} }
@ -4623,7 +4623,7 @@ static int __get_reference (
/* the position number is returned for the positional /* the position number is returned for the positional
* variable unlike other reference types. */ * variable unlike other reference types. */
v = __eval_esseression (run, ((sse_awk_nde_pos_t*)nde)->val); v = __eval_expression (run, ((sse_awk_nde_pos_t*)nde)->val);
if (v == SSE_NULL) return -1; if (v == SSE_NULL) return -1;
sse_awk_refupval (v); sse_awk_refupval (v);
@ -4843,7 +4843,7 @@ static sse_awk_val_t* __eval_pos (sse_awk_run_t* run, sse_awk_nde_t* nde)
sse_real_t rv; sse_real_t rv;
int n; int n;
v = __eval_esseression (run, pos->val); v = __eval_expression (run, pos->val);
if (v == SSE_NULL) return SSE_NULL; if (v == SSE_NULL) return SSE_NULL;
sse_awk_refupval (v); sse_awk_refupval (v);
@ -4882,7 +4882,7 @@ static sse_awk_val_t* __eval_getline (sse_awk_run_t* run, sse_awk_nde_t* nde)
{ {
sse_size_t len; sse_size_t len;
v = __eval_esseression (run, p->in); v = __eval_expression (run, p->in);
if (v == SSE_NULL) return SSE_NULL; if (v == SSE_NULL) return SSE_NULL;
/* TODO: distinction between v->type == SSE_AWK_VAL_STR /* TODO: distinction between v->type == SSE_AWK_VAL_STR
@ -5055,7 +5055,7 @@ static int __read_record (sse_awk_run_t* run)
return -1; return -1;
} }
/* /*
sse_printf (SSE_T("len = %d str=[%s]\n"), xp_printf (SSE_T("len = %d str=[%s]\n"),
(int)SSE_AWK_STR_LEN(&run->inrec.line), (int)SSE_AWK_STR_LEN(&run->inrec.line),
SSE_AWK_STR_BUF(&run->inrec.line)); SSE_AWK_STR_BUF(&run->inrec.line));
*/ */
@ -5175,7 +5175,7 @@ static sse_char_t* __idxnde_to_str (
if (nde->next == SSE_NULL) if (nde->next == SSE_NULL)
{ {
/* single node index */ /* single node index */
idx = __eval_esseression (run, nde); idx = __eval_expression (run, nde);
if (idx == SSE_NULL) return SSE_NULL; if (idx == SSE_NULL) return SSE_NULL;
sse_awk_refupval (idx); sse_awk_refupval (idx);
@ -5203,7 +5203,7 @@ static sse_char_t* __idxnde_to_str (
while (nde != SSE_NULL) while (nde != SSE_NULL)
{ {
idx = __eval_esseression (run, nde); idx = __eval_expression (run, nde);
if (idx == SSE_NULL) if (idx == SSE_NULL)
{ {
sse_awk_str_close (&idxstr); sse_awk_str_close (&idxstr);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.h,v 1.19 2006-10-22 11:34:53 bacon Exp $ * $Id: run.h,v 1.20 2006-10-22 12:39:30 bacon Exp $
*/ */
#ifndef _SSE_AWK_RUN_H_ #ifndef _SSE_AWK_RUN_H_
@ -18,7 +18,7 @@ enum
SSE_AWK_ASSOP_MUL, SSE_AWK_ASSOP_MUL,
SSE_AWK_ASSOP_DIV, SSE_AWK_ASSOP_DIV,
SSE_AWK_ASSOP_MOD, SSE_AWK_ASSOP_MOD,
SSE_AWK_ASSOP_ESSE SSE_AWK_ASSOP_EXP
}; };
enum enum
@ -48,7 +48,7 @@ enum
SSE_AWK_BINOP_MUL, SSE_AWK_BINOP_MUL,
SSE_AWK_BINOP_DIV, SSE_AWK_BINOP_DIV,
SSE_AWK_BINOP_MOD, SSE_AWK_BINOP_MOD,
SSE_AWK_BINOP_ESSE, SSE_AWK_BINOP_EXP,
SSE_AWK_BINOP_CONCAT, SSE_AWK_BINOP_CONCAT,
SSE_AWK_BINOP_MA, SSE_AWK_BINOP_MA,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.81 2006-10-22 11:34:53 bacon Exp $ * $Id: tree.c,v 1.82 2006-10-22 12:39:30 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -89,18 +89,18 @@ static const sse_char_t* __print_outop_str[] =
#define PRINT_TABS(awk,depth) \ #define PRINT_TABS(awk,depth) \
do { if (__print_tabs(awk,depth) == -1) return -1; } while (0) do { if (__print_tabs(awk,depth) == -1) return -1; } while (0)
#define PRINT_ESSERESSION(awk,nde) \ #define PRINT_EXPRESSION(awk,nde) \
do { if (__print_esseression(awk,nde) == -1) return -1; } while (0) do { if (__print_expression(awk,nde) == -1) return -1; } while (0)
#define PRINT_ESSERESSION_LIST(awk,nde) \ #define PRINT_EXPRESSION_LIST(awk,nde) \
do { if (__print_esseression_list(awk,nde) == -1) return -1; } while (0) do { if (__print_expression_list(awk,nde) == -1) return -1; } while (0)
#define PRINT_STATEMENTS(awk,nde,depth) \ #define PRINT_STATEMENTS(awk,nde,depth) \
do { if (__print_statements(awk,nde,depth) == -1) return -1; } while (0) do { if (__print_statements(awk,nde,depth) == -1) return -1; } while (0)
static int __print_tabs (sse_awk_t* awk, int depth); static int __print_tabs (sse_awk_t* awk, int depth);
static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde); static int __print_expression (sse_awk_t* awk, sse_awk_nde_t* nde);
static int __print_esseression_list (sse_awk_t* awk, sse_awk_nde_t* tree); static int __print_expression_list (sse_awk_t* awk, sse_awk_nde_t* tree);
static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth); static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth);
static int __print_tabs (sse_awk_t* awk, int depth) static int __print_tabs (sse_awk_t* awk, int depth)
@ -114,7 +114,7 @@ static int __print_tabs (sse_awk_t* awk, int depth)
return 0; return 0;
} }
static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde) static int __print_expression (sse_awk_t* awk, sse_awk_nde_t* nde)
{ {
switch (nde->type) switch (nde->type)
{ {
@ -125,7 +125,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
while (p != SSE_NULL) while (p != SSE_NULL)
{ {
PRINT_ESSERESSION (awk, p); PRINT_EXPRESSION (awk, p);
if (p->next != SSE_NULL) if (p->next != SSE_NULL)
PUT_SRCSTR (awk, SSE_T(",")); PUT_SRCSTR (awk, SSE_T(","));
p = p->next; p = p->next;
@ -138,22 +138,22 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
{ {
sse_awk_nde_ass_t* px = (sse_awk_nde_ass_t*)nde; sse_awk_nde_ass_t* px = (sse_awk_nde_ass_t*)nde;
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PUT_SRCSTR (awk, __assop_str[px->opcode]); PUT_SRCSTR (awk, __assop_str[px->opcode]);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PRINT_ESSERESSION (awk, px->right); PRINT_EXPRESSION (awk, px->right);
sse_awk_assert (awk, px->right->next == SSE_NULL); sse_awk_assert (awk, px->right->next == SSE_NULL);
break; break;
} }
case SSE_AWK_NDE_ESSE_BIN: case SSE_AWK_NDE_EXP_BIN:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)nde;
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
sse_awk_assert (awk, px->left->next == SSE_NULL); sse_awk_assert (awk, px->left->next == SSE_NULL);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
@ -162,7 +162,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
if (px->right->type == SSE_AWK_NDE_ASS) if (px->right->type == SSE_AWK_NDE_ASS)
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->right); PRINT_EXPRESSION (awk, px->right);
if (px->right->type == SSE_AWK_NDE_ASS) if (px->right->type == SSE_AWK_NDE_ASS)
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
sse_awk_assert (awk, px->right->next == SSE_NULL); sse_awk_assert (awk, px->right->next == SSE_NULL);
@ -170,37 +170,37 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
break; break;
} }
case SSE_AWK_NDE_ESSE_UNR: case SSE_AWK_NDE_EXP_UNR:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (awk, px->right == SSE_NULL); sse_awk_assert (awk, px->right == SSE_NULL);
PUT_SRCSTR (awk, __unrop_str[px->opcode]); PUT_SRCSTR (awk, __unrop_str[px->opcode]);
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
break; break;
} }
case SSE_AWK_NDE_ESSE_INCPRE: case SSE_AWK_NDE_EXP_INCPRE:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (awk, px->right == SSE_NULL); sse_awk_assert (awk, px->right == SSE_NULL);
PUT_SRCSTR (awk, __incop_str[px->opcode]); PUT_SRCSTR (awk, __incop_str[px->opcode]);
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
break; break;
} }
case SSE_AWK_NDE_ESSE_INCPST: case SSE_AWK_NDE_EXP_INCPST:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)nde; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)nde;
sse_awk_assert (awk, px->right == SSE_NULL); sse_awk_assert (awk, px->right == SSE_NULL);
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
PUT_SRCSTR (awk, __incop_str[px->opcode]); PUT_SRCSTR (awk, __incop_str[px->opcode]);
break; break;
@ -211,12 +211,12 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
sse_awk_nde_cnd_t* px = (sse_awk_nde_cnd_t*)nde; sse_awk_nde_cnd_t* px = (sse_awk_nde_cnd_t*)nde;
PUT_SRCSTR (awk, SSE_T("(")); PUT_SRCSTR (awk, SSE_T("("));
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
PUT_SRCSTR (awk, SSE_T(")?")); PUT_SRCSTR (awk, SSE_T(")?"));
PRINT_ESSERESSION (awk, px->left); PRINT_EXPRESSION (awk, px->left);
PUT_SRCSTR (awk, SSE_T(":")); PUT_SRCSTR (awk, SSE_T(":"));
PRINT_ESSERESSION (awk, px->right); PRINT_EXPRESSION (awk, px->right);
break; break;
} }
@ -321,7 +321,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
px->id.idxa, 10, SSE_NULL, tmp, sse_countof(tmp)); px->id.idxa, 10, SSE_NULL, tmp, sse_countof(tmp));
PUT_SRCSTRX (awk, tmp, n); PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, SSE_T("[")); PUT_SRCSTR (awk, SSE_T("["));
PRINT_ESSERESSION_LIST (awk, px->idx); PRINT_EXPRESSION_LIST (awk, px->idx);
PUT_SRCSTR (awk, SSE_T("]")); PUT_SRCSTR (awk, SSE_T("]"));
break; break;
} }
@ -344,7 +344,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTRX (awk, px->id.name, px->id.name_len); PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
PUT_SRCSTR (awk, SSE_T("[")); PUT_SRCSTR (awk, SSE_T("["));
PRINT_ESSERESSION_LIST (awk, px->idx); PRINT_EXPRESSION_LIST (awk, px->idx);
PUT_SRCSTR (awk, SSE_T("]")); PUT_SRCSTR (awk, SSE_T("]"));
break; break;
} }
@ -392,7 +392,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTR (awk, SSE_T("[")); PUT_SRCSTR (awk, SSE_T("["));
} }
sse_awk_assert (awk, px->idx != SSE_NULL); sse_awk_assert (awk, px->idx != SSE_NULL);
PRINT_ESSERESSION_LIST (awk, px->idx); PRINT_EXPRESSION_LIST (awk, px->idx);
PUT_SRCSTR (awk, SSE_T("]")); PUT_SRCSTR (awk, SSE_T("]"));
break; break;
} }
@ -440,7 +440,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTR (awk, SSE_T("[")); PUT_SRCSTR (awk, SSE_T("["));
} }
sse_awk_assert (awk, px->idx != SSE_NULL); sse_awk_assert (awk, px->idx != SSE_NULL);
PRINT_ESSERESSION_LIST (awk, px->idx); PRINT_EXPRESSION_LIST (awk, px->idx);
PUT_SRCSTR (awk, SSE_T("]")); PUT_SRCSTR (awk, SSE_T("]"));
break; break;
} }
@ -448,7 +448,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
case SSE_AWK_NDE_POS: case SSE_AWK_NDE_POS:
{ {
PUT_SRCSTR (awk, SSE_T("$")); PUT_SRCSTR (awk, SSE_T("$"));
PRINT_ESSERESSION (awk, ((sse_awk_nde_pos_t*)nde)->val); PRINT_EXPRESSION (awk, ((sse_awk_nde_pos_t*)nde)->val);
break; break;
} }
@ -458,7 +458,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTRX (awk, PUT_SRCSTRX (awk,
px->what.bfn.name, px->what.bfn.name_len); px->what.bfn.name, px->what.bfn.name_len);
PUT_SRCSTR (awk, SSE_T(" (")); PUT_SRCSTR (awk, SSE_T(" ("));
PRINT_ESSERESSION_LIST (awk, px->args); PRINT_EXPRESSION_LIST (awk, px->args);
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
break; break;
} }
@ -470,7 +470,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTRX (awk, PUT_SRCSTRX (awk,
px->what.afn.name, px->what.afn.name_len); px->what.afn.name, px->what.afn.name_len);
PUT_SRCSTR (awk, SSE_T(" (")); PUT_SRCSTR (awk, SSE_T(" ("));
PRINT_ESSERESSION_LIST (awk, px->args); PRINT_EXPRESSION_LIST (awk, px->args);
PUT_SRCSTR (awk, SSE_T(")")); PUT_SRCSTR (awk, SSE_T(")"));
break; break;
} }
@ -482,7 +482,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
(px->in_type == SSE_AWK_IN_PIPE || (px->in_type == SSE_AWK_IN_PIPE ||
px->in_type == SSE_AWK_IN_COPROC)) px->in_type == SSE_AWK_IN_COPROC))
{ {
PRINT_ESSERESSION (awk, px->in); PRINT_EXPRESSION (awk, px->in);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PUT_SRCSTR (awk, __getline_inop_str[px->in_type]); PUT_SRCSTR (awk, __getline_inop_str[px->in_type]);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
@ -492,7 +492,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
if (px->var != SSE_NULL) if (px->var != SSE_NULL)
{ {
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PRINT_ESSERESSION (awk, px->var); PRINT_EXPRESSION (awk, px->var);
} }
if (px->in != SSE_NULL && if (px->in != SSE_NULL &&
@ -501,7 +501,7 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PUT_SRCSTR (awk, __getline_inop_str[px->in_type]); PUT_SRCSTR (awk, __getline_inop_str[px->in_type]);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PRINT_ESSERESSION (awk, px->in); PRINT_EXPRESSION (awk, px->in);
} }
break; break;
} }
@ -515,13 +515,13 @@ static int __print_esseression (sse_awk_t* awk, sse_awk_nde_t* nde)
return 0; return 0;
} }
static int __print_esseression_list (sse_awk_t* awk, sse_awk_nde_t* tree) static int __print_expression_list (sse_awk_t* awk, sse_awk_nde_t* tree)
{ {
sse_awk_nde_t* p = tree; sse_awk_nde_t* p = tree;
while (p != SSE_NULL) while (p != SSE_NULL)
{ {
PRINT_ESSERESSION (awk, p); PRINT_EXPRESSION (awk, p);
p = p->next; p = p->next;
if (p != SSE_NULL) PUT_SRCSTR (awk, SSE_T(",")); if (p != SSE_NULL) PUT_SRCSTR (awk, SSE_T(","));
} }
@ -588,7 +588,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PUT_SRCSTR (awk, SSE_T("if (")); PUT_SRCSTR (awk, SSE_T("if ("));
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
PUT_SRCSTR (awk, SSE_T(")\n")); PUT_SRCSTR (awk, SSE_T(")\n"));
sse_awk_assert (awk, px->then_part != SSE_NULL); sse_awk_assert (awk, px->then_part != SSE_NULL);
@ -615,7 +615,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PUT_SRCSTR (awk, SSE_T("while (")); PUT_SRCSTR (awk, SSE_T("while ("));
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
PUT_SRCSTR (awk, SSE_T(")\n")); PUT_SRCSTR (awk, SSE_T(")\n"));
if (px->body->type == SSE_AWK_NDE_BLK) if (px->body->type == SSE_AWK_NDE_BLK)
{ {
@ -645,7 +645,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PUT_SRCSTR (awk, SSE_T("while (")); PUT_SRCSTR (awk, SSE_T("while ("));
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
PUT_SRCSTR (awk, SSE_T(");\n")); PUT_SRCSTR (awk, SSE_T(");\n"));
break; break;
} }
@ -658,17 +658,17 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PUT_SRCSTR (awk, SSE_T("for (")); PUT_SRCSTR (awk, SSE_T("for ("));
if (px->init != SSE_NULL) if (px->init != SSE_NULL)
{ {
PRINT_ESSERESSION (awk, px->init); PRINT_EXPRESSION (awk, px->init);
} }
PUT_SRCSTR (awk, SSE_T("; ")); PUT_SRCSTR (awk, SSE_T("; "));
if (px->test != SSE_NULL) if (px->test != SSE_NULL)
{ {
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
} }
PUT_SRCSTR (awk, SSE_T("; ")); PUT_SRCSTR (awk, SSE_T("; "));
if (px->incr != SSE_NULL) if (px->incr != SSE_NULL)
{ {
PRINT_ESSERESSION (awk, px->incr); PRINT_EXPRESSION (awk, px->incr);
} }
PUT_SRCSTR (awk, SSE_T(")\n")); PUT_SRCSTR (awk, SSE_T(")\n"));
@ -689,7 +689,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PUT_SRCSTR (awk, SSE_T("for ")); PUT_SRCSTR (awk, SSE_T("for "));
PRINT_ESSERESSION (awk, px->test); PRINT_EXPRESSION (awk, px->test);
PUT_SRCSTR (awk, SSE_T("\n")); PUT_SRCSTR (awk, SSE_T("\n"));
if (px->body->type == SSE_AWK_NDE_BLK) if (px->body->type == SSE_AWK_NDE_BLK)
{ {
@ -728,7 +728,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PUT_SRCSTR (awk, SSE_T("return ")); PUT_SRCSTR (awk, SSE_T("return "));
sse_awk_assert (awk, ((sse_awk_nde_return_t*)p)->val->next == SSE_NULL); sse_awk_assert (awk, ((sse_awk_nde_return_t*)p)->val->next == SSE_NULL);
PRINT_ESSERESSION (awk, ((sse_awk_nde_return_t*)p)->val); PRINT_EXPRESSION (awk, ((sse_awk_nde_return_t*)p)->val);
PUT_SRCSTR (awk, SSE_T(";\n")); PUT_SRCSTR (awk, SSE_T(";\n"));
} }
break; break;
@ -747,7 +747,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
{ {
PUT_SRCSTR (awk, SSE_T("exit ")); PUT_SRCSTR (awk, SSE_T("exit "));
sse_awk_assert (awk, px->val->next == SSE_NULL); sse_awk_assert (awk, px->val->next == SSE_NULL);
PRINT_ESSERESSION (awk, px->val); PRINT_EXPRESSION (awk, px->val);
PUT_SRCSTR (awk, SSE_T(";\n")); PUT_SRCSTR (awk, SSE_T(";\n"));
} }
break; break;
@ -771,7 +771,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
{ {
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PUT_SRCSTR (awk, SSE_T("delete ")); PUT_SRCSTR (awk, SSE_T("delete "));
/* TODO: can't use __print_esseression??? */ /* TODO: can't use __print_expression??? */
sse_awk_prnpt (awk, ((sse_awk_nde_delete_t*)p)->var); sse_awk_prnpt (awk, ((sse_awk_nde_delete_t*)p)->var);
break; break;
} }
@ -786,7 +786,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
if (px->args != SSE_NULL) if (px->args != SSE_NULL)
{ {
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PRINT_ESSERESSION_LIST (awk, px->args); PRINT_EXPRESSION_LIST (awk, px->args);
} }
if (px->out != SSE_NULL) if (px->out != SSE_NULL)
@ -794,7 +794,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PUT_SRCSTR (awk, __print_outop_str[px->out_type]); PUT_SRCSTR (awk, __print_outop_str[px->out_type]);
PUT_SRCSTR (awk, SSE_T(" ")); PUT_SRCSTR (awk, SSE_T(" "));
PRINT_ESSERESSION (awk, px->out); PRINT_EXPRESSION (awk, px->out);
} }
PUT_SRCSTR (awk, SSE_T(";\n")); PUT_SRCSTR (awk, SSE_T(";\n"));
@ -804,7 +804,7 @@ static int __print_statements (sse_awk_t* awk, sse_awk_nde_t* tree, int depth)
default: default:
{ {
PRINT_TABS (awk, depth); PRINT_TABS (awk, depth);
PRINT_ESSERESSION (awk, p); PRINT_EXPRESSION (awk, p);
PUT_SRCSTR (awk, SSE_T(";\n")); PUT_SRCSTR (awk, SSE_T(";\n"));
} }
} }
@ -826,7 +826,7 @@ int sse_awk_prnptnpt (sse_awk_t* awk, sse_awk_nde_t* tree)
while (nde != SSE_NULL) while (nde != SSE_NULL)
{ {
if (__print_esseression (awk, nde) == -1) return -1; if (__print_expression (awk, nde) == -1) return -1;
if (nde->next == SSE_NULL) break; if (nde->next == SSE_NULL) break;
PUT_SRCSTR (awk, SSE_T(",")); PUT_SRCSTR (awk, SSE_T(","));
@ -975,9 +975,9 @@ void sse_awk_clrpt (sse_awk_t* awk, sse_awk_nde_t* tree)
break; break;
} }
case SSE_AWK_NDE_ESSE_BIN: case SSE_AWK_NDE_EXP_BIN:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)p; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)p;
sse_awk_assert (awk, px->left->next == SSE_NULL); sse_awk_assert (awk, px->left->next == SSE_NULL);
sse_awk_assert (awk, px->right->next == SSE_NULL); sse_awk_assert (awk, px->right->next == SSE_NULL);
@ -987,11 +987,11 @@ void sse_awk_clrpt (sse_awk_t* awk, sse_awk_nde_t* tree)
break; break;
} }
case SSE_AWK_NDE_ESSE_UNR: case SSE_AWK_NDE_EXP_UNR:
case SSE_AWK_NDE_ESSE_INCPRE: case SSE_AWK_NDE_EXP_INCPRE:
case SSE_AWK_NDE_ESSE_INCPST: case SSE_AWK_NDE_EXP_INCPST:
{ {
sse_awk_nde_esse_t* px = (sse_awk_nde_esse_t*)p; sse_awk_nde_exp_t* px = (sse_awk_nde_exp_t*)p;
sse_awk_assert (awk, px->right == SSE_NULL); sse_awk_assert (awk, px->right == SSE_NULL);
sse_awk_clrpt (awk, px->left); sse_awk_clrpt (awk, px->left);
SSE_AWK_FREE (awk, p); SSE_AWK_FREE (awk, p);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.h,v 1.75 2006-10-22 11:34:53 bacon Exp $ * $Id: tree.h,v 1.76 2006-10-22 12:39:30 bacon Exp $
*/ */
#ifndef _SSE_AWK_TREE_H_ #ifndef _SSE_AWK_TREE_H_
@ -29,16 +29,16 @@ enum
SSE_AWK_NDE_DELETE, SSE_AWK_NDE_DELETE,
SSE_AWK_NDE_PRINT, SSE_AWK_NDE_PRINT,
/* esseression */ /* expression */
/* if you change the following values including their order, /* if you change the following values including their order,
* you should change __eval_func of __eval_esseression * you should change __eval_func of __eval_expression
* in run.c accordingly */ * in run.c accordingly */
SSE_AWK_NDE_GRP, SSE_AWK_NDE_GRP,
SSE_AWK_NDE_ASS, SSE_AWK_NDE_ASS,
SSE_AWK_NDE_ESSE_BIN, SSE_AWK_NDE_EXP_BIN,
SSE_AWK_NDE_ESSE_UNR, SSE_AWK_NDE_EXP_UNR,
SSE_AWK_NDE_ESSE_INCPRE, SSE_AWK_NDE_EXP_INCPRE,
SSE_AWK_NDE_ESSE_INCPST, SSE_AWK_NDE_EXP_INCPST,
SSE_AWK_NDE_CND, SSE_AWK_NDE_CND,
SSE_AWK_NDE_BFN, SSE_AWK_NDE_BFN,
SSE_AWK_NDE_AFN, SSE_AWK_NDE_AFN,
@ -95,7 +95,7 @@ typedef struct sse_awk_nde_t sse_awk_nde_t;
typedef struct sse_awk_nde_blk_t sse_awk_nde_blk_t; typedef struct sse_awk_nde_blk_t sse_awk_nde_blk_t;
typedef struct sse_awk_nde_grp_t sse_awk_nde_grp_t; typedef struct sse_awk_nde_grp_t sse_awk_nde_grp_t;
typedef struct sse_awk_nde_ass_t sse_awk_nde_ass_t; typedef struct sse_awk_nde_ass_t sse_awk_nde_ass_t;
typedef struct sse_awk_nde_esse_t sse_awk_nde_esse_t; typedef struct sse_awk_nde_exp_t sse_awk_nde_exp_t;
typedef struct sse_awk_nde_cnd_t sse_awk_nde_cnd_t; typedef struct sse_awk_nde_cnd_t sse_awk_nde_cnd_t;
typedef struct sse_awk_nde_pos_t sse_awk_nde_pos_t; typedef struct sse_awk_nde_pos_t sse_awk_nde_pos_t;
typedef struct sse_awk_nde_int_t sse_awk_nde_int_t; typedef struct sse_awk_nde_int_t sse_awk_nde_int_t;
@ -144,7 +144,7 @@ struct sse_awk_nde_blk_t
sse_awk_nde_t* body; sse_awk_nde_t* body;
}; };
/* SSE_AWK_NDE_GRP - esseression group */ /* SSE_AWK_NDE_GRP - expression group */
struct sse_awk_nde_grp_t struct sse_awk_nde_grp_t
{ {
SSE_AWK_NDE_HDR; SSE_AWK_NDE_HDR;
@ -160,9 +160,9 @@ struct sse_awk_nde_ass_t
sse_awk_nde_t* right; sse_awk_nde_t* right;
}; };
/* SSE_AWK_NDE_ESSE_BIN, SSE_AWK_NDE_ESSE_UNR, /* SSE_AWK_NDE_EXP_BIN, SSE_AWK_NDE_EXP_UNR,
* SSE_AWK_NDE_ESSE_INCPRE, SSE_AW_NDE_ESSE_INCPST */ * SSE_AWK_NDE_EXP_INCPRE, SSE_AW_NDE_EXP_INCPST */
struct sse_awk_nde_esse_t struct sse_awk_nde_exp_t
{ {
SSE_AWK_NDE_HDR; SSE_AWK_NDE_HDR;
int opcode; int opcode;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.74 2006-10-22 11:34:53 bacon Exp $ * $Id: val.c,v 1.75 2006-10-22 12:39:30 bacon Exp $
*/ */
#include <sse/awk/awk_i.h> #include <sse/awk/awk_i.h>
@ -64,7 +64,7 @@ sse_awk_val_t* sse_awk_makeintval (sse_awk_run_t* run, sse_long_t v)
val->val = v; val->val = v;
val->nde = SSE_NULL; val->nde = SSE_NULL;
/*sse_printf (SSE_T("makeintval => %p\n"), val);*/ /*xp_printf (SSE_T("makeintval => %p\n"), val);*/
return (sse_awk_val_t*)val; return (sse_awk_val_t*)val;
} }
@ -88,7 +88,7 @@ sse_awk_val_t* sse_awk_makerealval (sse_awk_run_t* run, sse_real_t v)
val->val = v; val->val = v;
val->nde = SSE_NULL; val->nde = SSE_NULL;
/*sse_printf (SSE_T("makerealval => %p\n"), val);*/ /*xp_printf (SSE_T("makerealval => %p\n"), val);*/
return (sse_awk_val_t*)val; return (sse_awk_val_t*)val;
} }
@ -116,7 +116,7 @@ sse_awk_val_t* sse_awk_makestrval (
return SSE_NULL; return SSE_NULL;
} }
/*sse_printf (SSE_T("makestrval => %p\n"), val);*/ /*xp_printf (SSE_T("makestrval => %p\n"), val);*/
return (sse_awk_val_t*)val; return (sse_awk_val_t*)val;
} }
@ -141,7 +141,7 @@ sse_awk_val_t* sse_awk_makestrval2 (
return SSE_NULL; return SSE_NULL;
} }
/*sse_printf (SSE_T("makestrval2 => %p\n"), val);*/ /*xp_printf (SSE_T("makestrval2 => %p\n"), val);*/
return (sse_awk_val_t*)val; return (sse_awk_val_t*)val;
} }
@ -179,9 +179,9 @@ sse_awk_val_t* sse_awk_makerexval (
static void __free_map_val (void* run, void* v) static void __free_map_val (void* run, void* v)
{ {
/* /*
sse_printf (SSE_T("refdown in map free...")); xp_printf (SSE_T("refdown in map free..."));
sse_awk_printval (v); sse_awk_printval (v);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
*/ */
sse_awk_refdownval (run, v); sse_awk_refdownval (run, v);
} }
@ -243,9 +243,9 @@ void sse_awk_freeval (sse_awk_run_t* run, sse_awk_val_t* val, sse_bool_t cache)
{ {
if (sse_awk_isbuiltinval(val)) return; if (sse_awk_isbuiltinval(val)) return;
/*sse_printf (SSE_T("freeing [cache=%d] ... "), cache); /*xp_printf (SSE_T("freeing [cache=%d] ... "), cache);
sse_awk_printval (val); sse_awk_printval (val);
sse_printf (SSE_T("\n"));*/ xp_printf (SSE_T("\n"));*/
if (val->type == SSE_AWK_VAL_NIL) if (val->type == SSE_AWK_VAL_NIL)
{ {
SSE_AWK_FREE (run->awk, val); SSE_AWK_FREE (run->awk, val);
@ -307,9 +307,9 @@ void sse_awk_refupval (sse_awk_val_t* val)
{ {
if (sse_awk_isbuiltinval(val)) return; if (sse_awk_isbuiltinval(val)) return;
/* /*
sse_printf (SSE_T("ref up ")); xp_printf (SSE_T("ref up "));
sse_awk_printval (val); sse_awk_printval (val);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
*/ */
val->ref++; val->ref++;
} }
@ -319,10 +319,10 @@ void sse_awk_refdownval (sse_awk_run_t* run, sse_awk_val_t* val)
if (sse_awk_isbuiltinval(val)) return; if (sse_awk_isbuiltinval(val)) return;
/* /*
sse_printf (SSE_T("%p, %p, %p\n"), sse_awk_val_nil, &__awk_nil, val); xp_printf (SSE_T("%p, %p, %p\n"), sse_awk_val_nil, &__awk_nil, val);
sse_printf (SSE_T("ref down [count=>%d]\n"), (int)val->ref); xp_printf (SSE_T("ref down [count=>%d]\n"), (int)val->ref);
sse_awk_printval (val); sse_awk_printval (val);
sse_printf (SSE_T("\n")); xp_printf (SSE_T("\n"));
*/ */
sse_awk_assert (run->awk, val->ref > 0); sse_awk_assert (run->awk, val->ref > 0);
@ -330,9 +330,9 @@ sse_printf (SSE_T("\n"));
if (val->ref <= 0) if (val->ref <= 0)
{ {
/* /*
sse_printf (SSE_T("**FREEING [")); xp_printf (SSE_T("**FREEING ["));
sse_awk_printval (val); sse_awk_printval (val);
sse_printf (SSE_T("]\n")); xp_printf (SSE_T("]\n"));
*/ */
sse_awk_freeval(run, val, sse_true); sse_awk_freeval(run, val, sse_true);
} }
@ -426,7 +426,7 @@ sse_char_t* sse_awk_valtostr (
/* TODO: process more value types */ /* TODO: process more value types */
sse_printf (SSE_T("*** ERROR: WRONG VALUE TYPE [%d] in sse_awk_valtostr v=> %p***\n"), v->type, v); xp_printf (SSE_T("*** ERROR: WRONG VALUE TYPE [%d] in sse_awk_valtostr v=> %p***\n"), v->type, v);
run->errnum = SSE_AWK_EVALTYPE; run->errnum = SSE_AWK_EVALTYPE;
return SSE_NULL; return SSE_NULL;
} }
@ -643,16 +643,16 @@ int sse_awk_valtonum (
return 0; /* long */ return 0; /* long */
} }
sse_printf (SSE_T("*** ERROR: WRONG VALUE TYPE [%d] in sse_awk_valtonum v=> %p***\n"), v->type, v); xp_printf (SSE_T("*** ERROR: WRONG VALUE TYPE [%d] in sse_awk_valtonum v=> %p***\n"), v->type, v);
run->errnum = SSE_AWK_EVALTYPE; run->errnum = SSE_AWK_EVALTYPE;
return -1; /* error */ return -1; /* error */
} }
static int __print_pair (sse_awk_pair_t* pair, void* arg) static int __print_pair (sse_awk_pair_t* pair, void* arg)
{ {
sse_printf (SSE_T(" %s=>"), pair->key); xp_printf (SSE_T(" %s=>"), pair->key);
sse_awk_printval (pair->val); sse_awk_printval (pair->val);
sse_printf (SSE_T(" ")); xp_printf (SSE_T(" "));
return 0; return 0;
} }
@ -662,51 +662,51 @@ void sse_awk_printval (sse_awk_val_t* val)
switch (val->type) switch (val->type)
{ {
case SSE_AWK_VAL_NIL: case SSE_AWK_VAL_NIL:
sse_printf (SSE_T("nil")); xp_printf (SSE_T("nil"));
break; break;
case SSE_AWK_VAL_INT: case SSE_AWK_VAL_INT:
#if defined(__LCC__) #if defined(__LCC__)
sse_printf (SSE_T("%lld"), xp_printf (SSE_T("%lld"),
(long long)((sse_awk_val_int_t*)val)->val); (long long)((sse_awk_val_int_t*)val)->val);
#elif defined(__BORLANDC__) || defined(_MSC_VER) #elif defined(__BORLANDC__) || defined(_MSC_VER)
sse_printf (SSE_T("%I64d"), xp_printf (SSE_T("%I64d"),
(__int64)((sse_awk_nde_int_t*)val)->val); (__int64)((sse_awk_nde_int_t*)val)->val);
#elif defined(vax) || defined(__vax) || defined(_SCO_DS) #elif defined(vax) || defined(__vax) || defined(_SCO_DS)
sse_printf (SSE_T("%ld"), xp_printf (SSE_T("%ld"),
(long)((sse_awk_val_int_t*)val)->val); (long)((sse_awk_val_int_t*)val)->val);
#else #else
sse_printf (SSE_T("%lld"), xp_printf (SSE_T("%lld"),
(long long)((sse_awk_val_int_t*)val)->val); (long long)((sse_awk_val_int_t*)val)->val);
#endif #endif
break; break;
case SSE_AWK_VAL_REAL: case SSE_AWK_VAL_REAL:
sse_printf (SSE_T("%Lf"), xp_printf (SSE_T("%Lf"),
(long double)((sse_awk_val_real_t*)val)->val); (long double)((sse_awk_val_real_t*)val)->val);
break; break;
case SSE_AWK_VAL_STR: case SSE_AWK_VAL_STR:
sse_printf (SSE_T("%s"), ((sse_awk_val_str_t*)val)->buf); xp_printf (SSE_T("%s"), ((sse_awk_val_str_t*)val)->buf);
break; break;
case SSE_AWK_VAL_REX: case SSE_AWK_VAL_REX:
sse_printf (SSE_T("REX[%s]"), ((sse_awk_val_rex_t*)val)->buf); xp_printf (SSE_T("REX[%s]"), ((sse_awk_val_rex_t*)val)->buf);
break; break;
case SSE_AWK_VAL_MAP: case SSE_AWK_VAL_MAP:
sse_printf (SSE_T("MAP[")); xp_printf (SSE_T("MAP["));
sse_awk_map_walk (((sse_awk_val_map_t*)val)->map, __print_pair, SSE_NULL); sse_awk_map_walk (((sse_awk_val_map_t*)val)->map, __print_pair, SSE_NULL);
sse_printf (SSE_T("]")); xp_printf (SSE_T("]"));
break; break;
case SSE_AWK_VAL_REF: case SSE_AWK_VAL_REF:
sse_printf (SSE_T("REF[id=%d,val="), ((sse_awk_val_ref_t*)val)->id); xp_printf (SSE_T("REF[id=%d,val="), ((sse_awk_val_ref_t*)val)->id);
sse_awk_printval (*((sse_awk_val_ref_t*)val)->adr); sse_awk_printval (*((sse_awk_val_ref_t*)val)->adr);
sse_printf (SSE_T("]")); xp_printf (SSE_T("]"));
break; break;
default: default:
sse_printf (SSE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n")); xp_printf (SSE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
} }
} }

5
ase/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.ac Revision: 1.66 . # From configure.ac Revision: 1.67 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for sse deb-0.1.0. # Generated by GNU Autoconf 2.59 for sse deb-0.1.0.
# #
@ -12938,7 +12938,7 @@ then
CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE" CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"
fi fi
ac_config_files="$ac_config_files makefile awk/makefile" ac_config_files="$ac_config_files makefile awk/makefile test/awk/makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -13466,6 +13466,7 @@ do
# Handling of arguments. # Handling of arguments.
"makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;; "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;;
"awk/makefile" ) CONFIG_FILES="$CONFIG_FILES awk/makefile" ;; "awk/makefile" ) CONFIG_FILES="$CONFIG_FILES awk/makefile" ;;
"test/awk/makefile" ) CONFIG_FILES="$CONFIG_FILES test/awk/makefile" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;} echo "$as_me: error: invalid argument: $ac_config_target" >&2;}

View File

@ -1,6 +1,6 @@
AC_PREREQ(2.53) AC_PREREQ(2.53)
AC_INIT([sse], [deb-0.1.0]) AC_INIT([sse], [deb-0.1.0])
AC_REVISION([$Revision: 1.67 $]) AC_REVISION([$Revision: 1.68 $])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
# Checks for programs. # Checks for programs.
@ -123,5 +123,5 @@ then
[CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"] [CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"]
fi fi
AC_CONFIG_FILES([makefile awk/makefile]) AC_CONFIG_FILES([makefile awk/makefile test/awk/makefile])
AC_OUTPUT AC_OUTPUT

View File

@ -1,14 +1,14 @@
/* /*
* $Id: awk.c,v 1.100 2006-10-16 14:39:21 bacon Exp $ * $Id: awk.c,v 1.101 2006-10-22 12:39:30 bacon Exp $
*/ */
#include <xp/awk/awk.h> #include <sse/awk/awk.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef XP_CHAR_IS_WCHAR #ifdef SSE_CHAR_IS_WCHAR
#include <wchar.h> #include <wchar.h>
#include <wctype.h> #include <wctype.h>
#endif #endif
@ -25,9 +25,9 @@
#include <xp/bas/stdio.h> #include <xp/bas/stdio.h>
#include <limits.h> #include <limits.h>
#ifndef PATH_MAX #ifndef PATH_MAX
#define XP_PATH_MAX 4096 #define SSE_PATH_MAX 4096
#else #else
#define XP_PATH_MAX PATH_MAX #define SSE_PATH_MAX PATH_MAX
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -66,7 +66,7 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode)
#ifdef _WIN32 #ifdef _WIN32
return _tfopen (path, mode); return _tfopen (path, mode);
#else #else
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
const xp_mchar_t* path_mb; const xp_mchar_t* path_mb;
const xp_mchar_t* mode_mb; const xp_mchar_t* mode_mb;
#else #else
@ -74,14 +74,14 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode)
xp_mchar_t mode_mb[32]; xp_mchar_t mode_mb[32];
#endif #endif
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
path_mb = path; path_mb = path;
mode_mb = mode; mode_mb = mode;
#else #else
if (xp_wcstomcs_strict ( if (xp_wcstomcs_strict (
path, path_mb, xp_countof(path_mb)) == -1) return XP_NULL; path, path_mb, xp_countof(path_mb)) == -1) return SSE_NULL;
if (xp_wcstomcs_strict ( if (xp_wcstomcs_strict (
mode, mode_mb, xp_countof(mode_mb)) == -1) return XP_NULL; mode, mode_mb, xp_countof(mode_mb)) == -1) return SSE_NULL;
#endif #endif
return fopen (path_mb, mode_mb); return fopen (path_mb, mode_mb);
@ -100,9 +100,9 @@ static int __dprintf (const xp_char_t* fmt, ...)
#ifdef _WIN32 #ifdef _WIN32
n = xp_vsprintf (buf, xp_countof(buf), fmt, ap); n = xp_vsprintf (buf, xp_countof(buf), fmt, ap);
#if defined(_MSC_VER) && (_MSC_VER>=1400) #if defined(_MSC_VER) && (_MSC_VER>=1400)
MessageBox (NULL, buf, XP_T("\uD655\uC778\uC2E4\uD328 Assertion Failure"), MB_OK | MB_ICONERROR); MessageBox (NULL, buf, SSE_T("\uD655\uC778\uC2E4\uD328 Assertion Failure"), MB_OK | MB_ICONERROR);
#else #else
MessageBox (NULL, buf, XP_T("Assertion Failure"), MB_OK | MB_ICONERROR); MessageBox (NULL, buf, SSE_T("Assertion Failure"), MB_OK | MB_ICONERROR);
#endif #endif
#else #else
@ -117,7 +117,7 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
#ifdef _WIN32 #ifdef _WIN32
return _tpopen (cmd, mode); return _tpopen (cmd, mode);
#else #else
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
const xp_mchar_t* cmd_mb; const xp_mchar_t* cmd_mb;
const xp_mchar_t* mode_mb; const xp_mchar_t* mode_mb;
#else #else
@ -125,14 +125,14 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
xp_mchar_t mode_mb[32]; xp_mchar_t mode_mb[32];
#endif #endif
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
cmd_mb = cmd; cmd_mb = cmd;
mode_mb = mode; mode_mb = mode;
#else #else
if (xp_wcstomcs_strict ( if (xp_wcstomcs_strict (
cmd, cmd_mb, xp_countof(cmd_mb)) == -1) return XP_NULL; cmd, cmd_mb, xp_countof(cmd_mb)) == -1) return SSE_NULL;
if (xp_wcstomcs_strict ( if (xp_wcstomcs_strict (
mode, mode_mb, xp_countof(mode_mb)) == -1) return XP_NULL; mode, mode_mb, xp_countof(mode_mb)) == -1) return SSE_NULL;
#endif #endif
return popen (cmd_mb, mode_mb); return popen (cmd_mb, mode_mb);
@ -143,7 +143,7 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
#define fgets_t _fgetts #define fgets_t _fgetts
#define fputs_t _fputts #define fputs_t _fputts
#else #else
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
#define fgets_t fgets #define fgets_t fgets
#define fputs_t fputs #define fputs_t fputs
#else #else
@ -158,28 +158,28 @@ static xp_ssize_t process_source (
struct src_io* src_io = (struct src_io*)arg; struct src_io* src_io = (struct src_io*)arg;
xp_char_t c; xp_char_t c;
if (cmd == XP_AWK_IO_OPEN) if (cmd == SSE_AWK_IO_OPEN)
{ {
if (src_io->input_file == XP_NULL) return 0; if (src_io->input_file == SSE_NULL) return 0;
src_io->input_handle = fopen_t (src_io->input_file, XP_T("r")); src_io->input_handle = fopen_t (src_io->input_file, SSE_T("r"));
if (src_io->input_handle == NULL) return -1; if (src_io->input_handle == NULL) return -1;
return 1; return 1;
} }
else if (cmd == XP_AWK_IO_CLOSE) else if (cmd == SSE_AWK_IO_CLOSE)
{ {
if (src_io->input_file == XP_NULL) return 0; if (src_io->input_file == SSE_NULL) return 0;
fclose ((FILE*)src_io->input_handle); fclose ((FILE*)src_io->input_handle);
return 0; return 0;
} }
else if (cmd == XP_AWK_IO_READ) else if (cmd == SSE_AWK_IO_READ)
{ {
if (size <= 0) return -1; if (size <= 0) return -1;
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
c = fgetc ((FILE*)src_io->input_handle); c = fgetc ((FILE*)src_io->input_handle);
#else #else
c = fgetwc ((FILE*)src_io->input_handle); c = fgetwc ((FILE*)src_io->input_handle);
#endif #endif
if (c == XP_CHAR_EOF) return 0; if (c == SSE_CHAR_EOF) return 0;
*data = c; *data = c;
return 1; return 1;
} }
@ -192,14 +192,14 @@ static xp_ssize_t dump_source (
{ {
/*struct src_io* src_io = (struct src_io*)arg;*/ /*struct src_io* src_io = (struct src_io*)arg;*/
if (cmd == XP_AWK_IO_OPEN) return 1; if (cmd == SSE_AWK_IO_OPEN) return 1;
else if (cmd == XP_AWK_IO_CLOSE) return 0; else if (cmd == SSE_AWK_IO_CLOSE) return 0;
else if (cmd == XP_AWK_IO_WRITE) else if (cmd == SSE_AWK_IO_WRITE)
{ {
xp_size_t i; xp_size_t i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
fputc (data[i], stdout); fputc (data[i], stdout);
#else #else
fputwc (data[i], stdout); fputwc (data[i], stdout);
@ -214,56 +214,56 @@ static xp_ssize_t dump_source (
static xp_ssize_t process_extio_pipe ( static xp_ssize_t process_extio_pipe (
int cmd, void* arg, xp_char_t* data, xp_size_t size) int cmd, void* arg, xp_char_t* data, xp_size_t size)
{ {
xp_awk_extio_t* epa = (xp_awk_extio_t*)arg; sse_awk_extio_t* epa = (sse_awk_extio_t*)arg;
switch (cmd) switch (cmd)
{ {
case XP_AWK_IO_OPEN: case SSE_AWK_IO_OPEN:
{ {
FILE* handle; FILE* handle;
const xp_char_t* mode; const xp_char_t* mode;
if (epa->mode == XP_AWK_IO_PIPE_READ) if (epa->mode == SSE_AWK_IO_PIPE_READ)
mode = XP_T("r"); mode = SSE_T("r");
else if (epa->mode == XP_AWK_IO_PIPE_WRITE) else if (epa->mode == SSE_AWK_IO_PIPE_WRITE)
mode = XP_T("w"); mode = SSE_T("w");
else return -1; /* TODO: any way to set the error number? */ else return -1; /* TODO: any way to set the error number? */
xp_printf (XP_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type); xp_printf (SSE_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type);
handle = popen_t (epa->name, mode); handle = popen_t (epa->name, mode);
if (handle == NULL) return -1; if (handle == NULL) return -1;
epa->handle = (void*)handle; epa->handle = (void*)handle;
return 1; return 1;
} }
case XP_AWK_IO_CLOSE: case SSE_AWK_IO_CLOSE:
{ {
xp_printf (XP_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type); xp_printf (SSE_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type);
fclose ((FILE*)epa->handle); fclose ((FILE*)epa->handle);
epa->handle = NULL; epa->handle = NULL;
return 0; return 0;
} }
case XP_AWK_IO_READ: case SSE_AWK_IO_READ:
{ {
if (fgets_t (data, size, (FILE*)epa->handle) == XP_NULL) if (fgets_t (data, size, (FILE*)epa->handle) == SSE_NULL)
return 0; return 0;
return xp_awk_strlen(data); return sse_awk_strlen(data);
} }
case XP_AWK_IO_WRITE: case SSE_AWK_IO_WRITE:
{ {
/* TODO: size... */ /* TODO: size... */
fputs_t (data, (FILE*)epa->handle); fputs_t (data, (FILE*)epa->handle);
return size; return size;
} }
case XP_AWK_IO_FLUSH: case SSE_AWK_IO_FLUSH:
{ {
if (epa->mode == XP_AWK_IO_PIPE_READ) return -1; if (epa->mode == SSE_AWK_IO_PIPE_READ) return -1;
else return 0; else return 0;
} }
case XP_AWK_IO_NEXT: case SSE_AWK_IO_NEXT:
{ {
return -1; return -1;
} }
@ -275,24 +275,24 @@ xp_printf (XP_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type);
static xp_ssize_t process_extio_file ( static xp_ssize_t process_extio_file (
int cmd, void* arg, xp_char_t* data, xp_size_t size) int cmd, void* arg, xp_char_t* data, xp_size_t size)
{ {
xp_awk_extio_t* epa = (xp_awk_extio_t*)arg; sse_awk_extio_t* epa = (sse_awk_extio_t*)arg;
switch (cmd) switch (cmd)
{ {
case XP_AWK_IO_OPEN: case SSE_AWK_IO_OPEN:
{ {
FILE* handle; FILE* handle;
const xp_char_t* mode; const xp_char_t* mode;
if (epa->mode == XP_AWK_IO_FILE_READ) if (epa->mode == SSE_AWK_IO_FILE_READ)
mode = XP_T("r"); mode = SSE_T("r");
else if (epa->mode == XP_AWK_IO_FILE_WRITE) else if (epa->mode == SSE_AWK_IO_FILE_WRITE)
mode = XP_T("w"); mode = SSE_T("w");
else if (epa->mode == XP_AWK_IO_FILE_APPEND) else if (epa->mode == SSE_AWK_IO_FILE_APPEND)
mode = XP_T("a"); mode = SSE_T("a");
else return -1; /* TODO: any way to set the error number? */ else return -1; /* TODO: any way to set the error number? */
xp_printf (XP_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type); xp_printf (SSE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type);
handle = fopen_t (epa->name, mode); handle = fopen_t (epa->name, mode);
if (handle == NULL) return -1; if (handle == NULL) return -1;
@ -300,35 +300,35 @@ xp_printf (XP_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type);
return 1; return 1;
} }
case XP_AWK_IO_CLOSE: case SSE_AWK_IO_CLOSE:
{ {
xp_printf (XP_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type); xp_printf (SSE_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type);
fclose ((FILE*)epa->handle); fclose ((FILE*)epa->handle);
epa->handle = NULL; epa->handle = NULL;
return 0; return 0;
} }
case XP_AWK_IO_READ: case SSE_AWK_IO_READ:
{ {
if (fgets_t (data, size, (FILE*)epa->handle) == XP_NULL) if (fgets_t (data, size, (FILE*)epa->handle) == SSE_NULL)
return 0; return 0;
return xp_awk_strlen(data); return sse_awk_strlen(data);
} }
case XP_AWK_IO_WRITE: case SSE_AWK_IO_WRITE:
{ {
/* TODO: how to return error or 0 */ /* TODO: how to return error or 0 */
fputs_t (data, /*size,*/ (FILE*)epa->handle); fputs_t (data, /*size,*/ (FILE*)epa->handle);
return size; return size;
} }
case XP_AWK_IO_FLUSH: case SSE_AWK_IO_FLUSH:
{ {
if (fflush ((FILE*)epa->handle) == EOF) return -1; if (fflush ((FILE*)epa->handle) == EOF) return -1;
return 0; return 0;
} }
case XP_AWK_IO_NEXT: case SSE_AWK_IO_NEXT:
{ {
return -1; return -1;
} }
@ -338,56 +338,56 @@ xp_printf (XP_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type);
return -1; return -1;
} }
static int open_extio_console (xp_awk_extio_t* epa); static int open_extio_console (sse_awk_extio_t* epa);
static int close_extio_console (xp_awk_extio_t* epa); static int close_extio_console (sse_awk_extio_t* epa);
static int next_extio_console (xp_awk_extio_t* epa); static int next_extio_console (sse_awk_extio_t* epa);
static xp_size_t infile_no = 0; static xp_size_t infile_no = 0;
static const xp_char_t* infiles[10000] = static const xp_char_t* infiles[10000] =
{ {
XP_T(""), SSE_T(""),
XP_NULL SSE_NULL
}; };
static xp_ssize_t process_extio_console ( static xp_ssize_t process_extio_console (
int cmd, void* arg, xp_char_t* data, xp_size_t size) int cmd, void* arg, xp_char_t* data, xp_size_t size)
{ {
xp_awk_extio_t* epa = (xp_awk_extio_t*)arg; sse_awk_extio_t* epa = (sse_awk_extio_t*)arg;
if (cmd == XP_AWK_IO_OPEN) if (cmd == SSE_AWK_IO_OPEN)
{ {
return open_extio_console (epa); return open_extio_console (epa);
} }
else if (cmd == XP_AWK_IO_CLOSE) else if (cmd == SSE_AWK_IO_CLOSE)
{ {
return close_extio_console (epa); return close_extio_console (epa);
} }
else if (cmd == XP_AWK_IO_READ) else if (cmd == SSE_AWK_IO_READ)
{ {
while (fgets_t (data, size, epa->handle) == XP_NULL) while (fgets_t (data, size, epa->handle) == SSE_NULL)
{ {
/* it has reached the end of the current file. /* it has reached the end of the current file.
* open the next file if available */ * open the next file if available */
if (infiles[infile_no] == XP_NULL) if (infiles[infile_no] == SSE_NULL)
{ {
/* no more input console */ /* no more input console */
/* is this correct??? */ /* is this correct??? */
/* /*
if (epa->handle != XP_NULL && if (epa->handle != SSE_NULL &&
epa->handle != stdin && epa->handle != stdin &&
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) fclose (epa->handle); epa->handle != stderr) fclose (epa->handle);
epa->handle = XP_NULL; epa->handle = SSE_NULL;
*/ */
return 0; return 0;
} }
if (infiles[infile_no][0] == XP_T('\0')) if (infiles[infile_no][0] == SSE_T('\0'))
{ {
if (epa->handle != XP_NULL && if (epa->handle != SSE_NULL &&
epa->handle != stdin && epa->handle != stdin &&
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) fclose (epa->handle); epa->handle != stderr) fclose (epa->handle);
@ -395,40 +395,40 @@ static xp_ssize_t process_extio_console (
} }
else else
{ {
FILE* fp = fopen_t (infiles[infile_no], XP_T("r")); FILE* fp = fopen_t (infiles[infile_no], SSE_T("r"));
if (fp == XP_NULL) if (fp == SSE_NULL)
{ {
xp_printf (XP_TEXT("failed to open the next console of type %x - fopen failure\n"), epa->type); xp_printf (SSE_TEXT("failed to open the next console of type %x - fopen failure\n"), epa->type);
return -1; return -1;
} }
if (epa->handle != XP_NULL && if (epa->handle != SSE_NULL &&
epa->handle != stdin && epa->handle != stdin &&
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) fclose (epa->handle); epa->handle != stderr) fclose (epa->handle);
xp_printf (XP_TEXT("open the next console [%s]\n"), infiles[infile_no]); xp_printf (SSE_TEXT("open the next console [%s]\n"), infiles[infile_no]);
epa->handle = fp; epa->handle = fp;
} }
infile_no++; infile_no++;
} }
return xp_awk_strlen(data); return sse_awk_strlen(data);
} }
else if (cmd == XP_AWK_IO_WRITE) else if (cmd == SSE_AWK_IO_WRITE)
{ {
/* TODO: how to return error or 0 */ /* TODO: how to return error or 0 */
fputs_t (data, /*size,*/ (FILE*)epa->handle); fputs_t (data, /*size,*/ (FILE*)epa->handle);
/*MessageBox (NULL, data, data, MB_OK);*/ /*MessageBox (NULL, data, data, MB_OK);*/
return size; return size;
} }
else if (cmd == XP_AWK_IO_FLUSH) else if (cmd == SSE_AWK_IO_FLUSH)
{ {
if (fflush ((FILE*)epa->handle) == EOF) return -1; if (fflush ((FILE*)epa->handle) == EOF) return -1;
return 0; return 0;
} }
else if (cmd == XP_AWK_IO_NEXT) else if (cmd == SSE_AWK_IO_NEXT)
{ {
return next_extio_console (epa); return next_extio_console (epa);
} }
@ -436,44 +436,44 @@ xp_printf (XP_TEXT("open the next console [%s]\n"), infiles[infile_no]);
return -1; return -1;
} }
static int open_extio_console (xp_awk_extio_t* epa) static int open_extio_console (sse_awk_extio_t* epa)
{ {
/* TODO: OpenConsole in GUI APPLICATION */ /* TODO: OpenConsole in GUI APPLICATION */
/* epa->name is always empty for console */ /* epa->name is always empty for console */
xp_assert (epa->name[0] == XP_T('\0')); xp_assert (epa->name[0] == SSE_T('\0'));
xp_printf (XP_TEXT("opening console[%s] of type %x\n"), epa->name, epa->type); xp_printf (SSE_TEXT("opening console[%s] of type %x\n"), epa->name, epa->type);
if (epa->mode == XP_AWK_IO_CONSOLE_READ) if (epa->mode == SSE_AWK_IO_CONSOLE_READ)
{ {
if (infiles[infile_no] == XP_NULL) if (infiles[infile_no] == SSE_NULL)
{ {
/* no more input file */ /* no more input file */
xp_printf (XP_TEXT("console - no more file\n"));; xp_printf (SSE_TEXT("console - no more file\n"));;
return 0; return 0;
} }
if (infiles[infile_no][0] == XP_T('\0')) if (infiles[infile_no][0] == SSE_T('\0'))
{ {
xp_printf (XP_T(" console(r) - <standard input>\n")); xp_printf (SSE_T(" console(r) - <standard input>\n"));
epa->handle = stdin; epa->handle = stdin;
} }
else else
{ {
/* a temporary variable fp is used here not to change /* a temporary variable fp is used here not to change
* any fields of epa when the open operation fails */ * any fields of epa when the open operation fails */
FILE* fp = fopen_t (infiles[infile_no], XP_T("r")); FILE* fp = fopen_t (infiles[infile_no], SSE_T("r"));
if (fp == XP_NULL) if (fp == SSE_NULL)
{ {
xp_printf (XP_TEXT("failed to open console of type %x - fopen failure\n"), epa->type); xp_printf (SSE_TEXT("failed to open console of type %x - fopen failure\n"), epa->type);
return -1; return -1;
} }
xp_printf (XP_T(" console(r) - %s\n"), infiles[infile_no]); xp_printf (SSE_T(" console(r) - %s\n"), infiles[infile_no]);
if (xp_awk_setconsolename ( if (sse_awk_setconsolename (
epa->run, infiles[infile_no], epa->run, infiles[infile_no],
xp_awk_strlen(infiles[infile_no])) == -1) sse_awk_strlen(infiles[infile_no])) == -1)
{ {
fclose (fp); fclose (fp);
return -1; return -1;
@ -485,11 +485,11 @@ xp_printf (XP_T(" console(r) - %s\n"), infiles[infile_no]);
infile_no++; infile_no++;
return 1; return 1;
} }
else if (epa->mode == XP_AWK_IO_CONSOLE_WRITE) else if (epa->mode == SSE_AWK_IO_CONSOLE_WRITE)
{ {
xp_printf (XP_T(" console(w) - <standard output>\n")); xp_printf (SSE_T(" console(w) - <standard output>\n"));
/* TODO: does output console has a name??? */ /* TODO: does output console has a name??? */
/*xp_awk_setconsolename (XP_T(""));*/ /*sse_awk_setconsolename (SSE_T(""));*/
epa->handle = stdout; epa->handle = stdout;
return 1; return 1;
} }
@ -497,11 +497,11 @@ xp_printf (XP_T(" console(w) - <standard output>\n"));
return -1; return -1;
} }
static int close_extio_console (xp_awk_extio_t* epa) static int close_extio_console (sse_awk_extio_t* epa)
{ {
xp_printf (XP_TEXT("closing console of type %x\n"), epa->type); xp_printf (SSE_TEXT("closing console of type %x\n"), epa->type);
if (epa->handle != XP_NULL && if (epa->handle != SSE_NULL &&
epa->handle != stdin && epa->handle != stdin &&
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) epa->handle != stderr)
@ -513,11 +513,11 @@ xp_printf (XP_TEXT("closing console of type %x\n"), epa->type);
return 0; return 0;
} }
static int next_extio_console (xp_awk_extio_t* epa) static int next_extio_console (sse_awk_extio_t* epa)
{ {
int n; int n;
FILE* fp = epa->handle; FILE* fp = epa->handle;
xp_printf (XP_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type); xp_printf (SSE_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type);
n = open_extio_console(epa); n = open_extio_console(epa);
if (n == -1) return -1; if (n == -1) return -1;
@ -528,14 +528,14 @@ xp_printf (XP_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type);
return 0; return 0;
} }
if (fp != XP_NULL && fp != stdin && if (fp != SSE_NULL && fp != stdin &&
fp != stdout && fp != stderr) fclose (fp); fp != stdout && fp != stderr) fclose (fp);
return n; return n;
} }
xp_awk_t* app_awk = NULL; sse_awk_t* app_awk = NULL;
void* app_run = NULL; void* app_run = NULL;
#ifdef _WIN32 #ifdef _WIN32
@ -544,7 +544,7 @@ static BOOL WINAPI __stop_run (DWORD ctrl_type)
if (ctrl_type == CTRL_C_EVENT || if (ctrl_type == CTRL_C_EVENT ||
ctrl_type == CTRL_CLOSE_EVENT) ctrl_type == CTRL_CLOSE_EVENT)
{ {
xp_awk_stop (app_awk, app_run); sse_awk_stop (app_awk, app_run);
return TRUE; return TRUE;
} }
@ -554,27 +554,27 @@ static BOOL WINAPI __stop_run (DWORD ctrl_type)
static void __stop_run (int sig) static void __stop_run (int sig)
{ {
signal (SIGINT, SIG_IGN); signal (SIGINT, SIG_IGN);
xp_awk_stop (app_awk, app_run); sse_awk_stop (app_awk, app_run);
//xp_awk_stoprun (awk, handle); //sse_awk_stoprun (awk, handle);
/*xp_awk_stopallruns (awk); */ /*sse_awk_stopallruns (awk); */
signal (SIGINT, __stop_run); signal (SIGINT, __stop_run);
} }
#endif #endif
static void __on_run_start (xp_awk_t* awk, void* handle, void* arg) static void __on_run_start (sse_awk_t* awk, void* handle, void* arg)
{ {
app_awk = awk; app_awk = awk;
app_run = handle; app_run = handle;
xp_printf (XP_T("AWK PRORAM ABOUT TO START...\n")); xp_printf (SSE_T("AWK PRORAM ABOUT TO START...\n"));
} }
static void __on_run_end (xp_awk_t* awk, void* handle, int errnum, void* arg) static void __on_run_end (sse_awk_t* awk, void* handle, int errnum, void* arg)
{ {
if (errnum != XP_AWK_ENOERR) if (errnum != SSE_AWK_ENOERR)
{ {
xp_printf (XP_T("AWK PRORAM ABOUT TO END WITH AN ERROR - %d - %s\n"), errnum, xp_awk_geterrstr (errnum)); xp_printf (SSE_T("AWK PRORAM ABOUT TO END WITH AN ERROR - %d - %s\n"), errnum, sse_awk_geterrstr (errnum));
} }
else xp_printf (XP_T("AWK PRORAM ENDED SUCCESSFULLY\n")); else xp_printf (SSE_T("AWK PRORAM ENDED SUCCESSFULLY\n"));
app_awk = NULL; app_awk = NULL;
app_run = NULL; app_run = NULL;
@ -625,27 +625,27 @@ static int __main (int argc, char* argv[])
static int __main (int argc, xp_char_t* argv[]) static int __main (int argc, xp_char_t* argv[])
#endif #endif
{ {
xp_awk_t* awk; sse_awk_t* awk;
xp_awk_srcios_t srcios; sse_awk_srcios_t srcios;
xp_awk_runcbs_t runcbs; sse_awk_runcbs_t runcbs;
xp_awk_runios_t runios; sse_awk_runios_t runios;
xp_awk_runarg_t runarg[10]; sse_awk_runarg_t runarg[10];
xp_awk_syscas_t syscas; sse_awk_syscas_t syscas;
struct src_io src_io = { NULL, NULL }; struct src_io src_io = { NULL, NULL };
int opt, i, file_count = 0; int opt, i, file_count = 0;
#ifdef _WIN32 #ifdef _WIN32
syscas_data_t syscas_data; syscas_data_t syscas_data;
#endif #endif
opt = XP_AWK_EXPLICIT | XP_AWK_UNIQUE | XP_AWK_HASHSIGN | opt = SSE_AWK_EXPLICIT | SSE_AWK_UNIQUE | SSE_AWK_HASHSIGN |
/*XP_AWK_DBLSLASHES |*/ /*SSE_AWK_DBLSLASHES |*/
XP_AWK_SHADING | XP_AWK_IMPLICIT | XP_AWK_SHIFT | SSE_AWK_SHADING | SSE_AWK_IMPLICIT | SSE_AWK_SHIFT |
XP_AWK_EXTIO | XP_AWK_BLOCKLESS | XP_AWK_STRINDEXONE | SSE_AWK_EXTIO | SSE_AWK_BLOCKLESS | SSE_AWK_STRINDEXONE |
XP_AWK_STRIPSPACES | XP_AWK_NEWLINE; SSE_AWK_STRIPSPACES | SSE_AWK_NEWLINE;
if (argc <= 1) if (argc <= 1)
{ {
xp_printf (XP_T("Usage: %s [-m] source_file [data_file ...]\n"), argv[0]); xp_printf (SSE_T("Usage: %s [-m] source_file [data_file ...]\n"), argv[0]);
return -1; return -1;
} }
@ -654,10 +654,10 @@ static int __main (int argc, xp_char_t* argv[])
#if defined(__STAND_ALONE) && !defined(_WIN32) #if defined(__STAND_ALONE) && !defined(_WIN32)
if (strcmp(argv[i], "-m") == 0) if (strcmp(argv[i], "-m") == 0)
#else #else
if (xp_awk_strcmp(argv[i], XP_T("-m")) == 0) if (sse_awk_strcmp(argv[i], SSE_T("-m")) == 0)
#endif #endif
{ {
opt |= XP_AWK_RUNMAIN; opt |= SSE_AWK_RUNMAIN;
} }
else if (file_count == 0) else if (file_count == 0)
{ {
@ -667,12 +667,12 @@ static int __main (int argc, xp_char_t* argv[])
else if (file_count >= 1 && file_count < xp_countof(infiles)-1) else if (file_count >= 1 && file_count < xp_countof(infiles)-1)
{ {
infiles[file_count-1] = argv[i]; infiles[file_count-1] = argv[i];
infiles[file_count] = XP_NULL; infiles[file_count] = SSE_NULL;
file_count++; file_count++;
} }
else else
{ {
xp_printf (XP_T("Usage: %s [-m] [-f source_file] [data_file ...]\n"), argv[0]); xp_printf (SSE_T("Usage: %s [-m] [-f source_file] [data_file ...]\n"), argv[0]);
return -1; return -1;
} }
} }
@ -685,7 +685,7 @@ static int __main (int argc, xp_char_t* argv[])
syscas.lock = NULL; syscas.lock = NULL;
syscas.unlock = NULL; syscas.unlock = NULL;
#ifdef XP_CHAR_IS_MCHAR #ifdef SSE_CHAR_IS_MCHAR
syscas.is_upper = isupper; syscas.is_upper = isupper;
syscas.is_lower = islower; syscas.is_lower = islower;
syscas.is_alpha = isalpha; syscas.is_alpha = isalpha;
@ -724,43 +724,43 @@ static int __main (int argc, xp_char_t* argv[])
syscas_data.heap = HeapCreate (0, 1000000, 1000000); syscas_data.heap = HeapCreate (0, 1000000, 1000000);
if (syscas_data.heap == NULL) if (syscas_data.heap == NULL)
{ {
xp_printf (XP_T("Error: cannot create an awk heap\n")); xp_printf (SSE_T("Error: cannot create an awk heap\n"));
return -1; return -1;
} }
syscas.custom_data = &syscas_data; syscas.custom_data = &syscas_data;
#endif #endif
if ((awk = xp_awk_open(&syscas)) == XP_NULL) if ((awk = sse_awk_open(&syscas)) == SSE_NULL)
{ {
#ifdef _WIN32 #ifdef _WIN32
HeapDestroy (syscas_data.heap); HeapDestroy (syscas_data.heap);
#endif #endif
xp_printf (XP_T("Error: cannot open awk\n")); xp_printf (SSE_T("Error: cannot open awk\n"));
return -1; return -1;
} }
xp_awk_setopt (awk, opt); sse_awk_setopt (awk, opt);
srcios.in = process_source; srcios.in = process_source;
srcios.out = dump_source; srcios.out = dump_source;
srcios.custom_data = &src_io; srcios.custom_data = &src_io;
if (xp_awk_parse (awk, &srcios) == -1) if (sse_awk_parse (awk, &srcios) == -1)
{ {
int errnum = xp_awk_geterrnum(awk); int errnum = sse_awk_geterrnum(awk);
#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR) #if defined(__STAND_ALONE) && !defined(_WIN32) && defined(SSE_CHAR_IS_WCHAR)
xp_printf ( xp_printf (
XP_T("ERROR: cannot parse program - line %u [%d] %ls\n"), SSE_T("ERROR: cannot parse program - line %u [%d] %ls\n"),
(unsigned int)xp_awk_getsrcline(awk), (unsigned int)sse_awk_getsrcline(awk),
errnum, xp_awk_geterrstr(errnum)); errnum, sse_awk_geterrstr(errnum));
#else #else
xp_printf ( xp_printf (
XP_T("ERROR: cannot parse program - line %u [%d] %s\n"), SSE_T("ERROR: cannot parse program - line %u [%d] %s\n"),
(unsigned int)xp_awk_getsrcline(awk), (unsigned int)sse_awk_getsrcline(awk),
errnum, xp_awk_geterrstr(errnum)); errnum, sse_awk_geterrstr(errnum));
#endif #endif
xp_awk_close (awk); sse_awk_close (awk);
return -1; return -1;
} }
@ -771,41 +771,41 @@ static int __main (int argc, xp_char_t* argv[])
#endif #endif
runios.pipe = process_extio_pipe; runios.pipe = process_extio_pipe;
runios.coproc = XP_NULL; runios.coproc = SSE_NULL;
runios.file = process_extio_file; runios.file = process_extio_file;
runios.console = process_extio_console; runios.console = process_extio_console;
runcbs.on_start = __on_run_start; runcbs.on_start = __on_run_start;
runcbs.on_end = __on_run_end; runcbs.on_end = __on_run_end;
runcbs.custom_data = XP_NULL; runcbs.custom_data = SSE_NULL;
runarg[0].ptr = XP_T("argument 0"); runarg[0].ptr = SSE_T("argument 0");
runarg[0].len = xp_awk_strlen(runarg[0].ptr); runarg[0].len = sse_awk_strlen(runarg[0].ptr);
runarg[1].ptr = XP_T("argumetn 1"); runarg[1].ptr = SSE_T("argumetn 1");
runarg[1].len = xp_awk_strlen(runarg[1].ptr); runarg[1].len = sse_awk_strlen(runarg[1].ptr);
runarg[2].ptr = XP_T("argumetn 2"); runarg[2].ptr = SSE_T("argumetn 2");
runarg[2].len = xp_awk_strlen(runarg[2].ptr); runarg[2].len = sse_awk_strlen(runarg[2].ptr);
runarg[3].ptr = XP_NULL; runarg[3].ptr = SSE_NULL;
runarg[3].len = 0; runarg[3].len = 0;
if (xp_awk_run (awk, &runios, &runcbs, runarg) == -1) if (sse_awk_run (awk, &runios, &runcbs, runarg) == -1)
{ {
int errnum = xp_awk_geterrnum(awk); int errnum = sse_awk_geterrnum(awk);
#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR) #if defined(__STAND_ALONE) && !defined(_WIN32) && defined(SSE_CHAR_IS_WCHAR)
xp_printf ( xp_printf (
XP_T("error: cannot run program - [%d] %ls\n"), SSE_T("error: cannot run program - [%d] %ls\n"),
errnum, xp_awk_geterrstr(errnum)); errnum, sse_awk_geterrstr(errnum));
#else #else
xp_printf ( xp_printf (
XP_T("error: cannot run program - [%d] %s\n"), SSE_T("error: cannot run program - [%d] %s\n"),
errnum, xp_awk_geterrstr(errnum)); errnum, sse_awk_geterrstr(errnum));
#endif #endif
xp_awk_close (awk); sse_awk_close (awk);
return -1; return -1;
} }
xp_awk_close (awk); sse_awk_close (awk);
#ifdef _WIN32 #ifdef _WIN32
HeapDestroy (syscas_data.heap); HeapDestroy (syscas_data.heap);
#endif #endif
@ -994,25 +994,25 @@ int xp_main (int argc, xp_char_t* argv[])
{ {
xp_char_t buf[xp_sizeof(xp_long_t)*8+2+2]; xp_char_t buf[xp_sizeof(xp_long_t)*8+2+2];
xp_size_t n; xp_size_t n;
n = xp_awk_longtostr (-0x7FFFFFFFFFFFFFFFi64, 16, XP_T("0x"), buf, xp_countof(buf)); n = sse_awk_longtostr (-0x7FFFFFFFFFFFFFFFi64, 16, SSE_T("0x"), buf, xp_countof(buf));
if (n == (xp_size_t)-1) if (n == (xp_size_t)-1)
{ {
xp_printf (XP_T("cannot convert...\n")); xp_printf (SSE_T("cannot convert...\n"));
} }
else xp_printf (XP_T("%d, %s\n"), n, buf); else xp_printf (SSE_T("%d, %s\n"), n, buf);
} }
if (IsDebuggerPresent ()) if (IsDebuggerPresent ())
{ {
xp_printf (XP_T("Running application in a debugger....\n")); xp_printf (SSE_T("Running application in a debugger....\n"));
} }
if (is_debugger_present ()) if (is_debugger_present ())
{ {
xp_printf (XP_T("Running application in a debugger by is_debugger_present...\n")); xp_printf (SSE_T("Running application in a debugger by is_debugger_present...\n"));
} }
if (is_debugger_present2 ()) if (is_debugger_present2 ())
{ {
xp_printf (XP_T("Running application in a debugger by is_debugger_present2...\n")); xp_printf (SSE_T("Running application in a debugger by is_debugger_present2...\n"));
} }
#endif #endif

View File

@ -2,9 +2,9 @@ SRCS = awk.c
OUTS = $(SRCS:.c=.x) OUTS = $(SRCS:.c=.x)
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@ CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. -I$(XPKIT)
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/awk LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/awk -L$(XPKIT)/xp/bas
LIBS = @LIBS@ -lxpawk -lxpbas -lm LIBS = @LIBS@ -lsseawk -lxpbas -lm
all: $(OUTS) all: $(OUTS)