From 295058a3e5eb04f42cd498f747a438ee2944fe42 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 8 Mar 2007 14:31:34 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/err.c | 8 ++++---- ase/awk/parse.c | 44 ++++++++-------------------------------- ase/test/awk/err-016.awk | 5 +++++ 3 files changed, 18 insertions(+), 39 deletions(-) create mode 100644 ase/test/awk/err-016.awk diff --git a/ase/awk/err.c b/ase/awk/err.c index 8c777f7b..0ffdde51 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.87 2007-03-06 14:51:51 bacon Exp $ + * $Id: err.c,v 1.88 2007-03-08 14:31:34 bacon Exp $ * * {License} */ @@ -59,7 +59,7 @@ static const ase_char_t* __geterrstr (int errnum) ASE_T("unexpected end of a comment"), ASE_T("unexpected end of a string"), ASE_T("unexpected end of a regular expression"), - ASE_T("a left brace expected"), + ASE_T("a left brace expected n place of '%.*s'"), ASE_T("a left parenthesis expected in place of '%.*s'"), ASE_T("a right parenthesis expected in place of '%.*s'"), ASE_T("a right bracket expected in place of '%.*s'"), @@ -75,8 +75,8 @@ static const ase_char_t* __geterrstr (int errnum) ASE_T("assignment statement expected"), ASE_T("identifier expected"), ASE_T("'%.*s' not a valid function name"), - ASE_T("BEGIN requires an action block"), - ASE_T("END requires an action block"), + ASE_T("BEGIN not followed by a left bracket on the same line"), + ASE_T("END not followed by a left bracket on the same line"), ASE_T("duplicate BEGIN"), ASE_T("duplicate END"), ASE_T("built-in function '%.*s' redefined"), diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 71de24fc..f9b8b942 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.253 2007-03-06 14:51:52 bacon Exp $ + * $Id: parse.c,v 1.254 2007-03-08 14:31:34 bacon Exp $ * * {License} */ @@ -573,17 +573,15 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk) { /* when the blockless pattern is supported * BEGIN and { should be located on the same line */ - ase_awk_seterror_old ( + ase_awk_seterror ( awk, ASE_AWK_EBLKBEG, awk->token.prev.line, - ASE_T("BEGIN not followed by a left bracket on the same line")); + ASE_NULL, 0); return ASE_NULL; } if (!MATCH(awk,TOKEN_LBRACE)) { - ase_awk_seterror_old ( - awk, ASE_AWK_ELBRACE, awk->token.prev.line, - ASE_T("BEGIN not followed by a left bracket")); + SET_ERROR_TOKEN (awk, ASE_AWK_ELBRACE); return ASE_NULL; } @@ -600,17 +598,15 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk) { /* when the blockless pattern is supported * END and { should be located on the same line */ - ase_awk_seterror_old ( + ase_awk_seterror ( awk, ASE_AWK_EBLKEND, awk->token.prev.line, - ASE_T("END not followed by a left bracket on the same line")); + ASE_NULL, 0); return ASE_NULL; } if (!MATCH(awk,TOKEN_LBRACE)) { - ase_awk_seterror_old ( - awk, ASE_AWK_ELBRACE, awk->token.prev.line, - ASE_T("END not followed by a left bracket")); + SET_ERROR_TOKEN (awk, ASE_AWK_ELBRACE); return ASE_NULL; } @@ -692,10 +688,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk) if (!MATCH(awk,TOKEN_LBRACE)) { ase_awk_clrpt (awk, ptn); - ase_awk_seterror_old ( - awk, ASE_AWK_ELBRACE, - (MATCH(awk,TOKEN_EOF)? awk->token.prev.line: awk->token.line), - ASE_T("not a valid start of a block")); + SET_ERROR_TOKEN (awk, ASE_AWK_ELBRACE); return ASE_NULL; } @@ -992,26 +985,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) ASE_AWK_FREE (awk, name_dup); ase_awk_tab_clear (&awk->parse.params); - if (MATCH(awk,TOKEN_EOF)) - { - ase_awk_seterror_old ( - awk, ASE_AWK_EENDSRC, awk->token.prev.line, - ASE_NULL); - } - else - { - awk->prmfns.misc.sprintf ( - awk->prmfns.misc.custom_data, - awk->errmsg, ASE_COUNTOF(awk->errmsg), - ASE_T("'%.*s' not a valid start of the function body"), - ASE_STR_LEN(&awk->token.name), - ASE_STR_BUF(&awk->token.name)); - - ase_awk_seterror_old ( - awk, ASE_AWK_ELBRACE, awk->token.line, - awk->errmsg); - } - + SET_ERROR_TOKEN (awk, ASE_AWK_ELBRACE); return ASE_NULL; } if (__get_token(awk) == -1) diff --git a/ase/test/awk/err-016.awk b/ase/test/awk/err-016.awk new file mode 100644 index 00000000..28a3e1a8 --- /dev/null +++ b/ase/test/awk/err-016.awk @@ -0,0 +1,5 @@ + +BEGIN +{ + print "hello world"; +}