changed to handle the error literal in the compiler.

added stix_synerrnumtoerrstr().
This commit is contained in:
hyunghwan.chung
2016-12-28 19:12:14 +00:00
parent eea13c0bd2
commit 2bf8b591cf
9 changed files with 453 additions and 225 deletions

View File

@ -1024,6 +1024,101 @@ typedef enum stix_log_mask_t stix_log_mask_t;
#endif
#if defined(STIX_INCLUDE_COMPILER)
enum stix_iocmd_t
{
STIX_IO_OPEN,
STIX_IO_CLOSE,
STIX_IO_READ
};
typedef enum stix_iocmd_t stix_iocmd_t;
struct stix_ioloc_t
{
unsigned long int line; /**< line */
unsigned long int colm; /**< column */
const stix_ooch_t* file; /**< file specified in #include */
};
typedef struct stix_ioloc_t stix_ioloc_t;
typedef struct stix_ioarg_t stix_ioarg_t;
typedef stix_ooi_t (*stix_ioimpl_t) (
stix_t* stix,
stix_iocmd_t cmd,
stix_ioarg_t* arg
);
enum stix_synerrnum_t
{
STIX_SYNERR_NOERR,
STIX_SYNERR_ILCHR, /* illegal character */
STIX_SYNERR_CMTNC, /* comment not closed */
STIX_SYNERR_STRNC, /* string not closed */
STIX_SYNERR_CLTNT, /* character literal not terminated */
STIX_SYNERR_HLTNT, /* hased literal not terminated */
STIX_SYNERR_CHARLIT, /* wrong character literal */
STIX_SYNERR_COLON, /* : expected */
STIX_SYNERR_STRING, /* string expected */
STIX_SYNERR_RADIX, /* invalid radix */
STIX_SYNERR_RADNUMLIT, /* invalid numeric literal with radix */
STIX_SYNERR_BYTERANGE, /* byte too small or too large */
STIX_SYNERR_ERRLIT, /* wrong error literal */
STIX_SYNERR_LBRACE, /* { expected */
STIX_SYNERR_RBRACE, /* } expected */
STIX_SYNERR_LPAREN, /* ( expected */
STIX_SYNERR_RPAREN, /* ) expected */
STIX_SYNERR_RBRACK, /* ] expected */
STIX_SYNERR_PERIOD, /* . expected */
STIX_SYNERR_COMMA, /* , expected */
STIX_SYNERR_VBAR, /* | expected */
STIX_SYNERR_GT, /* > expected */
STIX_SYNERR_ASSIGN, /* := expected */
STIX_SYNERR_IDENT, /* identifier expected */
STIX_SYNERR_INTEGER, /* integer expected */
STIX_SYNERR_PRIMITIVE, /* primitive: expected */
STIX_SYNERR_DIRECTIVE, /* wrong directive */
STIX_SYNERR_CLASSUNDEF, /* undefined class */
STIX_SYNERR_CLASSDUP, /* duplicate class */
STIX_SYNERR_CLASSCONTRA, /* contradictory class */
STIX_SYNERR_DCLBANNED, /* #dcl not allowed */
STIX_SYNERR_MTHNAME, /* wrong method name */
STIX_SYNERR_MTHNAMEDUP, /* duplicate method name */
STIX_SYNERR_ARGNAMEDUP, /* duplicate argument name */
STIX_SYNERR_TMPRNAMEDUP, /* duplicate temporary variable name */
STIX_SYNERR_VARNAMEDUP, /* duplicate variable name */
STIX_SYNERR_BLKARGNAMEDUP, /* duplicate block argument name */
STIX_SYNERR_VARARG, /* cannot assign to argument */
STIX_SYNERR_VARUNDCL, /* undeclared variable */
STIX_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
STIX_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
STIX_SYNERR_VARAMBIG, /* ambiguious variable - e.g. the variable is found in multiple pool dictionaries imported */
STIX_SYNERR_PRIMARY, /* wrong expression primary */
STIX_SYNERR_TMPRFLOOD, /* too many temporaries */
STIX_SYNERR_ARGFLOOD, /* too many arguments */
STIX_SYNERR_BLKTMPRFLOOD, /* too many block temporaries */
STIX_SYNERR_BLKARGFLOOD, /* too many block arguments */
STIX_SYNERR_BLKFLOOD, /* too large block */
STIX_SYNERR_PFNUM, /* wrong primitive number */
STIX_SYNERR_PFID, /* wrong primitive identifier */
STIX_SYNERR_MODNAME, /* wrong module name */
STIX_SYNERR_INCLUDE, /* #include error */
STIX_SYNERR_NAMESPACE, /* wrong namespace name */
STIX_SYNERR_POOLDIC, /* wrong pool dictionary */
STIX_SYNERR_POOLDICDUP, /* duplicate pool dictionary */
STIX_SYNERR_LITERAL /* literal expected */
};
typedef enum stix_synerrnum_t stix_synerrnum_t;
struct stix_synerr_t
{
stix_synerrnum_t num;
stix_ioloc_t loc;
stix_oocs_t tgt;
};
typedef struct stix_synerr_t stix_synerr_t;
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@ -1321,6 +1416,23 @@ STIX_EXPORT const stix_ooch_t* stix_errnumtoerrstr (
stix_errnum_t errnum
);
#if defined(STIX_INCLUDE_COMPILER)
STIX_EXPORT int stix_compile (
stix_t* stix,
stix_ioimpl_t io
);
STIX_EXPORT void stix_getsynerr (
stix_t* stix,
stix_synerr_t* synerr
);
STIX_EXPORT const stix_ooch_t* stix_synerrnumtoerrstr (
stix_synerrnum_t errnum
);
#endif
#if defined(__cplusplus)
}
#endif