From 6515dc2036cbef344b810645336d73cb65a8a7ac Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 18 Feb 2007 11:12:18 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 7 ++++--- ase/awk/parse.c | 39 ++++++++++++++++++++++++++------------- ase/awk/val.h | 6 +++--- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index a76f070a..dadfe3ae 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.189 2007-02-11 14:07:28 bacon Exp $ + * $Id: awk.h,v 1.190 2007-02-18 11:12:18 bacon Exp $ * * {License} */ @@ -160,10 +160,11 @@ enum /* various options */ enum { - /* allow undeclared variables */ + /* allow undeclared variables and implicit concatenation */ ASE_AWK_IMPLICIT = (1 << 0), - /* allow explicit variable declarations */ + /* allow explicit variable declaration and the concatenation + * operator, a period. */ ASE_AWK_EXPLICIT = (1 << 1), /* a function name should not coincide to be a variable name */ diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 2e42d070..5e63ecd1 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.241 2007-02-03 10:47:41 bacon Exp $ + * $Id: parse.c,v 1.242 2007-02-18 11:12:18 bacon Exp $ * * {License} */ @@ -2286,12 +2286,22 @@ static ase_awk_nde_t* __parse_concat (ase_awk_t* awk, ase_size_t line) left = __parse_additive (awk, line); if (left == ASE_NULL) return ASE_NULL; - /* TODO: write a better code to do this.... - * first of all, is the following check sufficient? */ - while (MATCH(awk,TOKEN_LPAREN) || - MATCH(awk,TOKEN_DOLLAR) || - awk->token.type >= TOKEN_GETLINE) + while (1) { + if (MATCH(awk,TOKEN_PERIOD)) + { + if ((awk->option & ASE_AWK_EXPLICIT) == 0) break; + if (__get_token(awk) == -1) return ASE_NULL; + } + else if (MATCH(awk,TOKEN_LPAREN) || + MATCH(awk,TOKEN_DOLLAR) || + awk->token.type >= TOKEN_GETLINE) + { + /* TODO: is the check above sufficient? */ + if ((awk->option & ASE_AWK_IMPLICIT) == 0) break; + } + else break; + right = __parse_additive (awk, awk->token.line); if (right == ASE_NULL) { @@ -4195,16 +4205,25 @@ static int __get_token (ase_awk_t* awk) if (ASE_AWK_ISDIGIT (awk, c)) { + awk->src.lex.curc = ASE_T('.'); if (__unget_char (awk, c) == -1) return -1; if (__get_number (awk) == -1) return -1; + } - else + else /*if (ASE_AWK_ISSPACE (awk, c) || c == ASE_CHAR_EOF)*/ + { + SET_TOKEN_TYPE (awk, TOKEN_PERIOD); + ADD_TOKEN_CHAR (awk, ASE_T('.')); + } + /* + else { ase_awk_seterror ( awk, ASE_AWK_ELXCHR, awk->token.line, ASE_T("floating point not followed by any valid digits")); return -1; } + */ } else if (ASE_AWK_ISALPHA (awk, c) || c == ASE_T('_')) { @@ -4561,12 +4580,6 @@ static int __get_token (ase_awk_t* awk) ADD_TOKEN_CHAR (awk, c); GET_CHAR (awk); } - else if (c == ASE_T('.')) - { - SET_TOKEN_TYPE (awk, TOKEN_PERIOD); - ADD_TOKEN_CHAR (awk, c); - GET_CHAR (awk); - } else if (c == ASE_T(';')) { SET_TOKEN_TYPE (awk, TOKEN_SEMICOLON); diff --git a/ase/awk/val.h b/ase/awk/val.h index c856843f..0d7928d9 100644 --- a/ase/awk/val.h +++ b/ase/awk/val.h @@ -1,5 +1,5 @@ /* - * $Id: val.h,v 1.60 2007-02-03 10:47:42 bacon Exp $ + * $Id: val.h,v 1.61 2007-02-18 11:12:18 bacon Exp $ * * {License} */ @@ -70,12 +70,12 @@ typedef struct ase_awk_val_ref_t ase_awk_val_ref_t; #ifndef ASE_AWK_NDE_INT_DEFINED #define ASE_AWK_NDE_INT_DEFINED -typedef struct ase_awk_nde_int_t ase_awk_nde_int_t; +typedef struct ase_awk_nde_int_t ase_awk_nde_int_t; #endif #ifndef ASE_AWK_NDE_REAL_DEFINED #define ASE_AWK_NDE_REAL_DEFINED -typedef struct ase_awk_nde_real_t ase_awk_nde_real_t; +typedef struct ase_awk_nde_real_t ase_awk_nde_real_t; #endif