*** empty log message ***

This commit is contained in:
hyung-hwan 2006-03-04 10:08:13 +00:00
parent 43fbcda16d
commit 4ad38025b8
7 changed files with 574 additions and 319 deletions

View File

@ -1,4 +1,4 @@
SRCS = awk.c tree.c tab.c map.c parse.c run.c sa.c SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c
OBJS = $(SRCS:.c=.obj) OBJS = $(SRCS:.c=.obj)
OUT = xpawk.lib OUT = xpawk.lib

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.25 2006-03-02 15:36:30 bacon Exp $ * $Id: awk.c,v 1.26 2006-03-04 10:06:49 bacon Exp $
*/ */
#include <xp/awk/awk.h> #include <xp/awk/awk.h>
@ -101,49 +101,6 @@ int xp_awk_close (xp_awk_t* awk)
return 0; return 0;
} }
int xp_awk_geterrnum (xp_awk_t* awk)
{
return awk->errnum;
}
const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk)
{
static const xp_char_t* __errstr[] =
{
XP_TEXT("no error"),
XP_TEXT("out of memory"),
XP_TEXT("cannot open source"),
XP_TEXT("cannot close source"),
XP_TEXT("cannot read source"),
XP_TEXT("invalid character"),
XP_TEXT("cannot unget character"),
XP_TEXT("unexpected end of source"),
XP_TEXT("left brace expected"),
XP_TEXT("left parenthesis expected"),
XP_TEXT("right parenthesis expected"),
XP_TEXT("right bracket expected"),
XP_TEXT("comma expected"),
XP_TEXT("semicolon expected"),
XP_TEXT("expression expected"),
XP_TEXT("keyword 'while' expected"),
XP_TEXT("assignment statement expected"),
XP_TEXT("identifier expected"),
XP_TEXT("duplicate BEGIN"),
XP_TEXT("duplicate END"),
XP_TEXT("duplicate function name"),
XP_TEXT("duplicate parameter name"),
XP_TEXT("duplicate variable name"),
XP_TEXT("duplicate name"),
XP_TEXT("undefined identifier")
};
if (awk->errnum >= 0 && awk->errnum < xp_countof(__errstr)) {
return __errstr[awk->errnum];
}
return XP_TEXT("unknown error");
}
// TODO: write a function to clear awk->parse data structure. // TODO: write a function to clear awk->parse data structure.
// this would be need either as a separate function or as a part of xp_awk_clear... // this would be need either as a separate function or as a part of xp_awk_clear...
// do i have to pass an option to xp_awk_clear to do this??? // do i have to pass an option to xp_awk_clear to do this???

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.31 2006-03-03 11:45:45 bacon Exp $ * $Id: awk.h,v 1.32 2006-03-04 10:06:49 bacon Exp $
*/ */
#ifndef _XP_AWK_AWK_H_ #ifndef _XP_AWK_AWK_H_
@ -13,44 +13,12 @@
#include <xp/bas/str.h> #include <xp/bas/str.h>
#endif #endif
#include <xp/awk/err.h>
#include <xp/awk/tree.h> #include <xp/awk/tree.h>
#include <xp/awk/tab.h> #include <xp/awk/tab.h>
#include <xp/awk/map.h> #include <xp/awk/map.h>
#include <xp/awk/val.h> #include <xp/awk/val.h>
enum
{
XP_AWK_ENOERR,
XP_AWK_ENOMEM, /* out of memory */
XP_AWK_ESRCOP,
XP_AWK_ESRCCL,
XP_AWK_ESRCDT, /* error in reading source */
XP_AWK_ELXCHR, /* lexer came accross an wrong character */
XP_AWK_ELXUNG, /* lexer failed to unget a character */
XP_AWK_EENDSRC, /* unexpected end of source */
XP_AWK_ELBRACE, /* left brace expected */
XP_AWK_ELPAREN, /* left parenthesis expected */
XP_AWK_ERPAREN, /* right parenthesis expected */
XP_AWK_ERBRACK, /* right bracket expected */
XP_AWK_ECOMMA, /* comma expected */
XP_AWK_ESEMICOLON, /* semicolon expected */
XP_AWK_EEXPR, /* expression expected */
XP_AWK_EWHILE, /* keyword 'while' is expected */
XP_AWK_EASSIGNMENT, /* assignment statement expected */
XP_AWK_EIDENT, /* identifier expected */
XP_AWK_EDUPBEGIN, /* duplicate BEGIN */
XP_AWK_EDUPEND, /* duplicate END */
XP_AWK_EDUPFUNC, /* duplicate function name */
XP_AWK_EDUPPARAM, /* duplicate parameter name */
XP_AWK_EDUPVAR, /* duplicate variable name */
XP_AWK_EDUPNAME, /* duplicate name - function, variable, etc */
XP_AWK_EUNDEF /* undefined identifier */
};
/* /*
* TYPE: xp_awk_t * TYPE: xp_awk_t
*/ */

48
ase/awk/err.c Normal file
View File

@ -0,0 +1,48 @@
/*
* $Id: err.c,v 1.1 2006-03-04 10:08:13 bacon Exp $
*/
#include <xp/awk/awk.h>
int xp_awk_geterrnum (xp_awk_t* awk)
{
return awk->errnum;
}
const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk)
{
static const xp_char_t* __errstr[] =
{
XP_TEXT("no error"),
XP_TEXT("out of memory"),
XP_TEXT("cannot open source"),
XP_TEXT("cannot close source"),
XP_TEXT("cannot read source"),
XP_TEXT("invalid character"),
XP_TEXT("cannot unget character"),
XP_TEXT("unexpected end of source"),
XP_TEXT("left brace expected"),
XP_TEXT("left parenthesis expected"),
XP_TEXT("right parenthesis expected"),
XP_TEXT("right bracket expected"),
XP_TEXT("comma expected"),
XP_TEXT("semicolon expected"),
XP_TEXT("expression expected"),
XP_TEXT("keyword 'while' expected"),
XP_TEXT("assignment statement expected"),
XP_TEXT("identifier expected"),
XP_TEXT("duplicate BEGIN"),
XP_TEXT("duplicate END"),
XP_TEXT("duplicate function name"),
XP_TEXT("duplicate parameter name"),
XP_TEXT("duplicate variable name"),
XP_TEXT("duplicate name"),
XP_TEXT("undefined identifier")
};
if (awk->errnum >= 0 && awk->errnum < xp_countof(__errstr)) {
return __errstr[awk->errnum];
}
return XP_TEXT("unknown error");
}

45
ase/awk/err.h Normal file
View File

@ -0,0 +1,45 @@
/*
* $Id: err.h,v 1.1 2006-03-04 10:08:13 bacon Exp $
*/
#ifndef _XP_AWK_ERR_H_
#define _XP_AWK_ERR_H_
#ifndef _XP_AWK_AWK_H_
#error Never include this file directly. Include <xp/awk/awk.h> instead
#endif
enum
{
XP_AWK_ENOERR, /* no error */
XP_AWK_ENOMEM, /* out of memory */
XP_AWK_ESRCOP,
XP_AWK_ESRCCL,
XP_AWK_ESRCDT, /* error in reading source */
XP_AWK_ELXCHR, /* lexer came accross an wrong character */
XP_AWK_ELXUNG, /* lexer failed to unget a character */
XP_AWK_EENDSRC, /* unexpected end of source */
XP_AWK_ELBRACE, /* left brace expected */
XP_AWK_ELPAREN, /* left parenthesis expected */
XP_AWK_ERPAREN, /* right parenthesis expected */
XP_AWK_ERBRACK, /* right bracket expected */
XP_AWK_ECOMMA, /* comma expected */
XP_AWK_ESEMICOLON, /* semicolon expected */
XP_AWK_EEXPR, /* expression expected */
XP_AWK_EWHILE, /* keyword 'while' is expected */
XP_AWK_EASSSTM, /* assignment statement expected */
XP_AWK_EIDENT, /* identifier expected */
XP_AWK_EDUPBEGIN, /* duplicate BEGIN */
XP_AWK_EDUPEND, /* duplicate END */
XP_AWK_EDUPFUNC, /* duplicate function name */
XP_AWK_EDUPPARAM, /* duplicate parameter name */
XP_AWK_EDUPVAR, /* duplicate variable name */
XP_AWK_EDUPNAME, /* duplicate name - function, variable, etc */
XP_AWK_EUNDEF /* undefined identifier */
};
#endif

View File

@ -1,4 +1,4 @@
SRCS = awk.c tree.c tab.c map.c parse.c run.c sa.c SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
OUT = libxpawk.a OUT = libxpawk.a

File diff suppressed because it is too large Load Diff