Recovered from cvs revision 2007-09-29 01:11:00
This commit is contained in:
parent
d1546c0b7a
commit
5c8dda1041
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.59 2007/09/25 07:17:30 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.60 2007/09/27 11:30:20 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -630,17 +630,11 @@ int Awk::open ()
|
||||
|
||||
int opt =
|
||||
OPT_IMPLICIT |
|
||||
OPT_EXPLICIT |
|
||||
OPT_UNIQUEFN |
|
||||
OPT_IDIV |
|
||||
OPT_SHADING |
|
||||
OPT_SHIFT |
|
||||
OPT_EXTIO |
|
||||
OPT_BLOCKLESS |
|
||||
OPT_BASEONE |
|
||||
OPT_STRIPSPACES |
|
||||
OPT_NEXTOFILE |
|
||||
OPT_ARGSTOMAIN;
|
||||
OPT_BASEONE;
|
||||
ase_awk_setoption (awk, opt);
|
||||
|
||||
runCallback = false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.61 2007/09/25 15:27:54 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.62 2007/09/27 11:04:10 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -533,7 +533,9 @@ public:
|
||||
*/
|
||||
OPT_ARGSTOMAIN = ASE_AWK_ARGSTOMAIN,
|
||||
/** Enables the keyword 'reset' */
|
||||
OPT_RESET = ASE_AWK_RESET
|
||||
OPT_RESET = ASE_AWK_RESET,
|
||||
/** Allows the assignment of a map value to a variable */
|
||||
OPT_MAPTOVAR = ASE_AWK_MAPTOVAR
|
||||
};
|
||||
// end of enum Option
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.14 2007/09/23 16:48:55 bacon Exp $
|
||||
* $Id: Awk.java,v 1.15 2007/09/27 11:04:10 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -38,6 +38,8 @@ public abstract class Awk
|
||||
public static final int OPTION_NEXTOFILE = (1 << 12);
|
||||
public static final int OPTION_CRLF = (1 << 13);
|
||||
public static final int OPTION_ARGSTOMAIN = (1 << 14);
|
||||
public static final int OPTION_RESET = (1 << 15);
|
||||
public static final int OPTION_MAPTOVAR = (1 << 16);
|
||||
|
||||
protected final static Reader stdin =
|
||||
new BufferedReader (new InputStreamReader (System.in));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.14 2007/09/25 15:27:54 bacon Exp $
|
||||
* $Id: awk.h,v 1.16 2007/09/27 11:30:54 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -162,7 +162,7 @@ enum ase_awk_option_t
|
||||
/* support getline and print */
|
||||
ASE_AWK_EXTIO = (1 << 7),
|
||||
|
||||
/* support co-process */
|
||||
/* support co-process - NOT IMPLEMENTED YET */
|
||||
ASE_AWK_COPROC = (1 << 8),
|
||||
|
||||
/* support blockless patterns */
|
||||
@ -196,7 +196,10 @@ enum ase_awk_option_t
|
||||
ASE_AWK_ARGSTOMAIN = (1 << 14),
|
||||
|
||||
/* enable the non-standard keyworkd reset */
|
||||
ASE_AWK_RESET = (1 << 15)
|
||||
ASE_AWK_RESET = (1 << 15),
|
||||
|
||||
/* allows the assignment of a map value to a variable */
|
||||
ASE_AWK_MAPTOVAR = (1 << 16)
|
||||
};
|
||||
|
||||
/* error code */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.15 2007/09/25 15:27:54 bacon Exp $
|
||||
* $Id: run.c,v 1.16 2007/09/27 11:04:10 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -2173,18 +2173,20 @@ static int run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde)
|
||||
val = eval_expression (run, nde->val);
|
||||
if (val == ASE_NULL) return -1;
|
||||
|
||||
#ifdef PROHIBIT_MAP_ASSIGNMENT_TO_VARIABLE
|
||||
if (val->type == ASE_AWK_VAL_MAP)
|
||||
if ((run->awk->option & ASE_AWK_MAPTOVAR) == 0)
|
||||
{
|
||||
/* cannot return a map */
|
||||
ase_awk_refupval (run, val);
|
||||
ase_awk_refdownval (run, val);
|
||||
if (val->type == ASE_AWK_VAL_MAP)
|
||||
{
|
||||
/* cannot return a map */
|
||||
ase_awk_refupval (run, val);
|
||||
ase_awk_refdownval (run, val);
|
||||
|
||||
ase_awk_setrunerror (run,
|
||||
ASE_AWK_EMAPNOTALLOWED, nde->line, ASE_NULL, 0);
|
||||
return -1;
|
||||
ase_awk_setrunerror (
|
||||
run, ASE_AWK_EMAPNOTALLOWED,
|
||||
nde->line, ASE_NULL, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ase_awk_refdownval (run, STACK_RETVAL(run));
|
||||
STACK_RETVAL(run) = val;
|
||||
@ -3089,13 +3091,15 @@ static ase_awk_val_t* do_assignment (
|
||||
var->type == ASE_AWK_NDE_LOCAL ||
|
||||
var->type == ASE_AWK_NDE_ARG)
|
||||
{
|
||||
#ifdef PROHIBIT_MAP_ASSIGNMENT_TO_VARIABLE
|
||||
if (val->type == ASE_AWK_VAL_MAP)
|
||||
if ((run->awk->option & ASE_AWK_MAPTOVAR) == 0)
|
||||
{
|
||||
errnum = ASE_AWK_ENOTASS;
|
||||
goto exit_on_error;
|
||||
if (val->type == ASE_AWK_VAL_MAP)
|
||||
{
|
||||
errnum = ASE_AWK_ENOTASS;
|
||||
goto exit_on_error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = do_assignment_scalar (run, (ase_awk_nde_var_t*)var, val);
|
||||
}
|
||||
else if (var->type == ASE_AWK_NDE_NAMEDIDX ||
|
||||
@ -3145,9 +3149,9 @@ static ase_awk_val_t* do_assignment_scalar (
|
||||
var->type == ASE_AWK_NDE_LOCAL ||
|
||||
var->type == ASE_AWK_NDE_ARG) && var->idx == ASE_NULL);
|
||||
|
||||
#ifdef PROHIBIT_MAP_ASSIGNMENT_TO_VARIABLE
|
||||
ASE_ASSERT (val->type != ASE_AWK_VAL_MAP);
|
||||
#endif
|
||||
ASE_ASSERT (
|
||||
(run->awk->option & ASE_AWK_MAPTOVAR) ||
|
||||
val->type != ASE_AWK_VAL_MAP);
|
||||
|
||||
if (var->type == ASE_AWK_NDE_NAMED)
|
||||
{
|
||||
|
@ -7,9 +7,16 @@
|
||||
- enhanced ase_awk_getglobalname
|
||||
* added an option
|
||||
- ASE_AWK_RESET (awk/awk.h)
|
||||
- Awk::OPT_RESET (awk/Awk.hpp)
|
||||
- Awk::OPT_RESET (awk/Awk.hpp)
|
||||
- Awk::OPTION::RESET (net/Awk.hpp)
|
||||
- TODO: add it to com&java
|
||||
- Awk.OPTION_RESET (awk/Awk.java)
|
||||
- TODO: add it to com
|
||||
* added an option
|
||||
- ASE_AWK_MAPTOVAR (awk/awk.h)
|
||||
- Awk::OPT_MAPTOVAR (awk/Awk.hpp)
|
||||
- Awk::OPTION::MAPTOVAR (net/Awk.hpp)
|
||||
- Awk.OPTION_MAPTOVAR (awk/Awk.java)
|
||||
- TODO: add it to com
|
||||
|
||||
* enhanced Awk::dispatchFunction to set a more accurate error code (awk/Awk.cpp)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.26 2007/09/25 15:27:54 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.27 2007/09/27 11:04:11 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -391,7 +391,8 @@ namespace ASE
|
||||
NEXTOFILE = ASE::Awk::OPT_NEXTOFILE,
|
||||
CRLF = ASE::Awk::OPT_CRLF,
|
||||
ARGSTOMAIN = ASE::Awk::OPT_ARGSTOMAIN,
|
||||
RESET = ASE::Awk::OPT_RESET
|
||||
RESET = ASE::Awk::OPT_RESET,
|
||||
MAPTOVAR = ASE::Awk::OPT_MAPTOVAR
|
||||
};
|
||||
|
||||
enum class DEPTH: int
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.35 2007/09/25 15:27:54 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.36 2007/09/27 11:30:20 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/StdAwk.hpp>
|
||||
@ -544,8 +544,6 @@ static void print_usage (const ase_char_t* argv0)
|
||||
ase_printf (ASE_T(" -w o:n Specify an old and new word pair\n"));
|
||||
ase_printf (ASE_T(" o - an original word\n"));
|
||||
ase_printf (ASE_T(" n - the new word to replace the original\n"));
|
||||
ase_printf (ASE_T(" -ns Don't strip whitespaces\n"));
|
||||
ase_printf (ASE_T(" The STRIPSPACES option is truned off\n"));
|
||||
}
|
||||
|
||||
int awk_main (int argc, ase_char_t* argv[])
|
||||
@ -560,6 +558,30 @@ int awk_main (int argc, ase_char_t* argv[])
|
||||
ase_size_t nsrcins = 0;
|
||||
ase_size_t nsrcouts = 0;
|
||||
|
||||
struct
|
||||
{
|
||||
const ase_char_t* name;
|
||||
TestAwk::Option opt;
|
||||
} otab[] =
|
||||
{
|
||||
{ ASE_T("implicit"), TestAwk::OPT_IMPLICIT },
|
||||
{ ASE_T("explicit"), TestAwk::OPT_EXPLICIT },
|
||||
{ ASE_T("uniquefn"), TestAwk::OPT_UNIQUEFN },
|
||||
{ ASE_T("shading"), TestAwk::OPT_SHADING },
|
||||
{ ASE_T("shift"), TestAwk::OPT_SHIFT },
|
||||
{ ASE_T("idiv"), TestAwk::OPT_IDIV },
|
||||
{ ASE_T("strconcat"), TestAwk::OPT_STRCONCAT },
|
||||
{ ASE_T("extio"), TestAwk::OPT_EXTIO },
|
||||
{ ASE_T("blockless"), TestAwk::OPT_BLOCKLESS },
|
||||
{ ASE_T("baseone"), TestAwk::OPT_BASEONE },
|
||||
{ ASE_T("stripspaces"), TestAwk::OPT_STRIPSPACES },
|
||||
{ ASE_T("nextofile"), TestAwk::OPT_NEXTOFILE },
|
||||
{ ASE_T("crfl"), TestAwk::OPT_CRLF },
|
||||
{ ASE_T("argstomain"), TestAwk::OPT_ARGSTOMAIN },
|
||||
{ ASE_T("reset"), TestAwk::OPT_RESET },
|
||||
{ ASE_T("maptovar"), TestAwk::OPT_MAPTOVAR }
|
||||
};
|
||||
|
||||
if (awk.open() == -1)
|
||||
{
|
||||
ase_fprintf (stderr, ASE_T("cannot open awk\n"));
|
||||
@ -577,30 +599,41 @@ int awk_main (int argc, ase_char_t* argv[])
|
||||
else if (ase_strcmp(argv[i], ASE_T("-a")) == 0) mode = 5;
|
||||
else if (ase_strcmp(argv[i], ASE_T("-m")) == 0) mode = 6;
|
||||
else if (ase_strcmp(argv[i], ASE_T("-w")) == 0) mode = 7;
|
||||
else if (ase_strcmp(argv[i], ASE_T("-nostripspaces")) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption () & ~TestAwk::OPT_STRIPSPACES);
|
||||
}
|
||||
else if (ase_strcmp(argv[i], ASE_T("-noimplicit")) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption () & ~TestAwk::OPT_IMPLICIT);
|
||||
}
|
||||
else if (ase_strcmp(argv[i], ASE_T("-noexplicit")) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption () & ~TestAwk::OPT_EXPLICIT);
|
||||
}
|
||||
else if (ase_strcmp(argv[i], ASE_T("-noshading")) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption () & ~TestAwk::OPT_SHADING);
|
||||
}
|
||||
else if (ase_strcmp(argv[i], ASE_T("-reset")) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption () | TestAwk::OPT_RESET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (argv[i][0] == ASE_T('-'))
|
||||
{
|
||||
int j;
|
||||
|
||||
if (argv[i][1] == ASE_T('n') && argv[i][2] == ASE_T('o'))
|
||||
{
|
||||
for (j = 0; j < ASE_COUNTOF(otab); j++)
|
||||
{
|
||||
if (ase_strcmp(&argv[i][3], otab[j].name) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption() & ~otab[j].opt);
|
||||
goto ok_valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < ASE_COUNTOF(otab); j++)
|
||||
{
|
||||
if (ase_strcmp(&argv[i][1], otab[j].name) == 0)
|
||||
{
|
||||
awk.setOption (awk.getOption() | otab[j].opt);
|
||||
goto ok_valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_usage (argv[0]);
|
||||
return -1;
|
||||
|
||||
ok_valid:
|
||||
;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1,8 +1,8 @@
|
||||
#
|
||||
# $Id: asm.awk,v 1.4 2007/09/27 11:33:45 bacon Exp $
|
||||
#
|
||||
# Taken from the book "The AWK Programming Language"
|
||||
# aseawk++ -si asm.awk -nostripspaces -a asm.s
|
||||
#
|
||||
# ASEAWK should turn on STRIPSPACES & BASEONE to run this program.
|
||||
# aseawk++ -si asm.awk -a asm.s -nostripspaces -baseone
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.15 2007/09/23 16:48:55 bacon Exp $
|
||||
* $Id: awk.c,v 1.16 2007/09/27 11:30:20 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/awk.h>
|
||||
@ -900,17 +900,21 @@ static int awk_main (int argc, ase_char_t* argv[])
|
||||
int deparse = 0;
|
||||
|
||||
opt = ASE_AWK_IMPLICIT |
|
||||
ASE_AWK_EXPLICIT |
|
||||
/*ASE_AWK_EXPLICIT |*/
|
||||
ASE_AWK_UNIQUEFN |
|
||||
ASE_AWK_IDIV |
|
||||
ASE_AWK_SHADING |
|
||||
ASE_AWK_SHIFT |
|
||||
/*ASE_AWK_SHIFT |*/
|
||||
/*ASE_AWK_IDIV |*/
|
||||
/*ASE_AWK_STRCONCAT |*/
|
||||
ASE_AWK_EXTIO |
|
||||
ASE_AWK_BLOCKLESS |
|
||||
ASE_AWK_BASEONE |
|
||||
ASE_AWK_STRIPSPACES |
|
||||
ASE_AWK_NEXTOFILE /*|
|
||||
ASE_AWK_ARGSTOMAIN*/;
|
||||
ASE_AWK_BASEONE /*|*/
|
||||
/*ASE_AWK_STRIPSPACES |*/
|
||||
/*ASE_AWK_NEXTOFILE |*/
|
||||
/*ASE_AWK_CRLF |*/
|
||||
/*ASE_AWK_ARGSTOMAIN |*/
|
||||
/*ASE_AWK_RESET*/
|
||||
/*ASE_AWK_MAPTOVAR*/;
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
|
@ -1,5 +1,3 @@
|
||||
global abc;
|
||||
|
||||
BEGIN {
|
||||
abc[20] = "abc";
|
||||
abc = 10;
|
||||
|
@ -5,4 +5,4 @@ BEGIN {
|
||||
abc = 10;
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [95] LINE [5] map 'abc' not assignable with a scalar
|
||||
RUN ERROR: CODE [96] LINE [5] map 'abc' not assignable with a scalar
|
||||
|
@ -2,4 +2,4 @@ BEGIN {
|
||||
delete ARGC;
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [87] LINE [2] variable 'ARGC' not deletable
|
||||
RUN ERROR: CODE [88] LINE [2] variable 'ARGC' not deletable
|
||||
|
@ -3,4 +3,4 @@ BEGIN {
|
||||
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix;
|
||||
}
|
||||
|
||||
RUN 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xxxxxxxxxhel...' not found
|
||||
RUN ERROR: CODE [86] LINE [2] function 'helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found
|
||||
|
@ -2,4 +2,4 @@ BEGIN {
|
||||
print abc > "123\0abc";
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [110] LINE [2] i/o name containing a null character
|
||||
RUN ERROR: CODE [112] LINE [2] i/o name containing a null character
|
||||
|
@ -3,4 +3,4 @@ BEGIN {
|
||||
split ("a b c",xx);
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [96] LINE [3] cannot change a scalar value to a map
|
||||
RUN ERROR: CODE [97] LINE [3] cannot change a scalar value to a map
|
||||
|
Loading…
Reference in New Issue
Block a user