This commit is contained in:
hyung-hwan 2008-07-23 07:12:56 +00:00
parent aca2acab75
commit 2b99c1efad
6 changed files with 25 additions and 79 deletions

View File

@ -1,7 +1,9 @@
[0.3.4] [0.3.4]
* enhanced the AWK interpreter to be more compatible to AWK * enhanced the AWK interpreter to be more compatible to AWK
- no more semicolon needed to terminate a statement with ASE_AWK_NEWLINE on - no more semicolon needed to terminate a statement with ASE_AWK_NEWLINE on.
* removed the ASE_AWK_STRCONCAT option.
* added the ASE_AWK_BXOR option.
[0.3.3] [0.3.3]

View File

@ -642,9 +642,9 @@ static struct
{ {
{ ASE_T("implicit"), TestAwk::OPT_IMPLICIT }, { ASE_T("implicit"), TestAwk::OPT_IMPLICIT },
{ ASE_T("explicit"), TestAwk::OPT_EXPLICIT }, { ASE_T("explicit"), TestAwk::OPT_EXPLICIT },
{ ASE_T("bxor"), TestAwk::OPT_BXOR },
{ ASE_T("shift"), TestAwk::OPT_SHIFT }, { ASE_T("shift"), TestAwk::OPT_SHIFT },
{ ASE_T("idiv"), TestAwk::OPT_IDIV }, { ASE_T("idiv"), TestAwk::OPT_IDIV },
{ ASE_T("strconcat"), TestAwk::OPT_STRCONCAT },
{ ASE_T("extio"), TestAwk::OPT_EXTIO }, { ASE_T("extio"), TestAwk::OPT_EXTIO },
{ ASE_T("newline"), TestAwk::OPT_NEWLINE }, { ASE_T("newline"), TestAwk::OPT_NEWLINE },
{ ASE_T("baseone"), TestAwk::OPT_BASEONE }, { ASE_T("baseone"), TestAwk::OPT_BASEONE },

View File

@ -797,9 +797,9 @@ static struct
{ {
{ ASE_T("implicit"), ASE_AWK_IMPLICIT }, { ASE_T("implicit"), ASE_AWK_IMPLICIT },
{ ASE_T("explicit"), ASE_AWK_EXPLICIT }, { ASE_T("explicit"), ASE_AWK_EXPLICIT },
{ ASE_T("bxor"), ASE_AWK_BXOR },
{ ASE_T("shift"), ASE_AWK_SHIFT }, { ASE_T("shift"), ASE_AWK_SHIFT },
{ ASE_T("idiv"), ASE_AWK_IDIV }, { ASE_T("idiv"), ASE_AWK_IDIV },
{ ASE_T("strconcat"), ASE_AWK_STRCONCAT },
{ ASE_T("extio"), ASE_AWK_EXTIO }, { ASE_T("extio"), ASE_AWK_EXTIO },
{ ASE_T("newline"), ASE_AWK_NEWLINE }, { ASE_T("newline"), ASE_AWK_NEWLINE },
{ ASE_T("baseone"), ASE_AWK_BASEONE }, { ASE_T("baseone"), ASE_AWK_BASEONE },

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp 279 2008-07-21 05:27:34Z baconevi $ * $Id: Awk.hpp 283 2008-07-22 13:12:56Z baconevi $
* *
* {License} * {License}
*/ */
@ -540,9 +540,9 @@ public:
{ {
OPT_IMPLICIT = ASE_AWK_IMPLICIT, OPT_IMPLICIT = ASE_AWK_IMPLICIT,
OPT_EXPLICIT = ASE_AWK_EXPLICIT, OPT_EXPLICIT = ASE_AWK_EXPLICIT,
OPT_BXOR = ASE_AWK_BXOR,
OPT_SHIFT = ASE_AWK_SHIFT, OPT_SHIFT = ASE_AWK_SHIFT,
OPT_IDIV = ASE_AWK_IDIV, OPT_IDIV = ASE_AWK_IDIV,
OPT_STRCONCAT = ASE_AWK_STRCONCAT,
OPT_EXTIO = ASE_AWK_EXTIO, OPT_EXTIO = ASE_AWK_EXTIO,
OPT_COPROC = ASE_AWK_COPROC, OPT_COPROC = ASE_AWK_COPROC,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 282 2008-07-22 13:01:49Z baconevi $ * $Id: awk.h 283 2008-07-22 13:12:56Z baconevi $
* *
* {License} * {License}
*/ */
@ -150,15 +150,8 @@ enum ase_awk_option_t
* operator(.), and a parse-time function check. */ * operator(.), and a parse-time function check. */
ASE_AWK_EXPLICIT = (1 << 1), ASE_AWK_EXPLICIT = (1 << 1),
#if 0
/* a function name should not coincide to be a variable name */
/*ASE_AWK_UNIQUEFN = (1 << 2),*/
/* allow variable shading */
/*ASE_AWK_SHADING = (1 << 3),*/
#endif
/* change ^ from exponentation to bitwise xor */ /* change ^ from exponentation to bitwise xor */
ASE_AWK_BXOR = (1 << 3), ASE_AWK_BXOR = (1 << 3),
/* support shift operators */ /* support shift operators */
ASE_AWK_SHIFT = (1 << 4), ASE_AWK_SHIFT = (1 << 4),
@ -166,13 +159,6 @@ enum ase_awk_option_t
/* enable the idiv operator (double slashes) */ /* enable the idiv operator (double slashes) */
ASE_AWK_IDIV = (1 << 5), ASE_AWK_IDIV = (1 << 5),
/* support string concatenation in tokenization.
* this option can change the behavior of a certain construct.
* getline < "abc" ".def" is treated as if it is getline < "abc.def"
* when this option is on. If this option is off, the same expression
* is treated as if it is (getline < "abc") ".def". */
ASE_AWK_STRCONCAT = (1 << 6),
/* support getline and print */ /* support getline and print */
ASE_AWK_EXTIO = (1 << 7), ASE_AWK_EXTIO = (1 << 7),
@ -209,7 +195,7 @@ enum ase_awk_option_t
/* pass the arguments to the main function */ /* pass the arguments to the main function */
ASE_AWK_ARGSTOMAIN = (1 << 14), ASE_AWK_ARGSTOMAIN = (1 << 14),
/* enable the non-standard keyworkd reset */ /* enable the non-standard keyword reset */
ASE_AWK_RESET = (1 << 15), ASE_AWK_RESET = (1 << 15),
/* allows the assignment of a map value to a variable */ /* allows the assignment of a map value to a variable */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c 282 2008-07-22 13:01:49Z baconevi $ * $Id: parse.c 283 2008-07-22 13:12:56Z baconevi $
* *
* {License} * {License}
*/ */
@ -853,22 +853,15 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
return ASE_NULL; return ASE_NULL;
} }
#if 0 /* check if it coincides to be a global variable name */
if (awk->option & ASE_AWK_UNIQUEFN) g = find_global (awk, name, name_len);
if (g != (ase_size_t)-1)
{ {
#endif SETERRARG (
/* check if it coincides to be a global variable name */ awk, ASE_AWK_EGBLRED, awk->token.line,
g = find_global (awk, name, name_len); name, name_len);
if (g != (ase_size_t)-1) return ASE_NULL;
{
SETERRARG (
awk, ASE_AWK_EGBLRED, awk->token.line,
name, name_len);
return ASE_NULL;
}
#if 0
} }
#endif
/* clone the function name before it is overwritten */ /* clone the function name before it is overwritten */
name_dup = ASE_AWK_STRXDUP (awk, name, name_len); name_dup = ASE_AWK_STRXDUP (awk, name, name_len);
@ -933,31 +926,13 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
param = ASE_STR_BUF(&awk->token.name); param = ASE_STR_BUF(&awk->token.name);
param_len = ASE_STR_LEN(&awk->token.name); param_len = ASE_STR_LEN(&awk->token.name);
#if 0 /* NOTE: the following is not a conflict.
if (awk->option & ASE_AWK_UNIQUEFN) * so the parameter is not checked against
{ * global variables.
/* check if a parameter conflicts with a function * global x;
* function f (f) { print f; } */ * function f (x) { print x; }
if (ase_strxncmp (name_dup, name_len, param, param_len) == 0 || * x in print x is a parameter
ase_map_get (awk->tree.afns, param, param_len) != ASE_NULL) */
{
ASE_AWK_FREE (awk, name_dup);
ase_awk_tab_clear (&awk->parse.params);
SETERRARG (
awk, ASE_AWK_EAFNRED, awk->token.line,
param, param_len);
return ASE_NULL;
}
/* NOTE: the following is not a conflict
* global x;
* function f (x) { print x; }
* x in print x is a parameter
*/
}
#endif
/* check if a parameter conflicts with other parameters */ /* check if a parameter conflicts with other parameters */
if (ase_awk_tab_find ( if (ase_awk_tab_find (
@ -4614,24 +4589,7 @@ static int get_token (ase_awk_t* awk)
else if (c == ASE_T('\"')) else if (c == ASE_T('\"'))
{ {
SET_TOKEN_TYPE (awk, TOKEN_STR); SET_TOKEN_TYPE (awk, TOKEN_STR);
if (get_charstr(awk) == -1) return -1; if (get_charstr(awk) == -1) return -1;
while (awk->option & ASE_AWK_STRCONCAT)
{
do
{
if (skip_spaces(awk) == -1) return -1;
if ((n = skip_comment(awk)) == -1) return -1;
}
while (n == 1);
c = awk->src.lex.curc;
if (c != ASE_T('\"')) break;
if (get_charstr(awk) == -1) return -1;
}
} }
else if (c == ASE_T('=')) else if (c == ASE_T('='))
{ {