prefix notation type parser

This commit is contained in:
Ellen Arvidsson 2025-04-19 20:35:42 +03:00
parent 9b24c8a496
commit 9ac779c1cf
14 changed files with 1217 additions and 151 deletions

View file

@ -18,17 +18,23 @@
#define SPHO_ERR_BUF_LEN 2048
#define SPHO_ERR(ctx, e) \
do { \
(ctx)->err = (e); \
if ((e) == SPHO_ERR_SYS) \
SPHO_ERR_INFO(ctx, e, errno); \
else \
SPHO_ERR_INFO(ctx, e, 0); \
} while (0)
#ifdef SPHO_DEBUG
#define SPHO_ERR_FILEBUF_LEN 128
#define SPHO_ERR(ctx, e) \
#define SPHO_ERR_INFO(ctx, e, info) \
do { \
(ctx)->err = (e); \
if ((e) == SPHO_ERR_SYS) \
(ctx)->err_info = errno; \
(ctx)->err_info = (info); \
snprintf((ctx)->filebuf, sizeof((ctx)->filebuf), \
__FILE__); \
(ctx)->errline = __LINE__; \
@ -85,18 +91,17 @@
#else /* SPHO_DEBUG */
#define SPHO_ERR(ctx, e) \
#define SPHO_ERR_INFO(ctx, e, info) \
do { \
(ctx)->err = (e); \
if ((e) == SPHO_ERR_SYS) \
(ctx)->err_info = errno; \
(ctx)->err_info = (info); \
} while (0)
#define SPHO_PRECOND(cond)
#define SPHO_ASSERT(cond)
#define SPHO_POSTCOND(cond)
#define SPHO_DBG_PRINT(fmt, ...)
#define SPHO_DEBUG_PRINT(fmt, ...)
#endif /* SPHO_DEBUG */

View file

@ -86,7 +86,7 @@ union tp_data {
struct tp_bappl_data bappl;
struct tp_konst_data konst;
struct tp_var_data var;
struct tp_nominal_data nom;
struct tp_nominal_data nom; // XXX
struct tp_record_data rec;
};
@ -126,6 +126,7 @@ struct spho_tp {
STAILQ_HEAD(spho_tp_l, spho_tp);
#define SPHO_TP_ERR(tp, err) SPHO_ERR((tp)->sc->ctx, (err))
struct spho_var *spho_var_create(struct spho_scope *, char *, size_t);

View file

@ -13,6 +13,13 @@ do { \
} \
} while (0)
#ifdef SPHO_USE_STRLCPY
#define SPHO_STRLCPY(dst, src, len) strlcpy(dst, src, len)
#else
#define SPHO_STRLCPY(dst, src, len) \
(size_t)snprintf(dst, len, "%s", src)
#endif
#endif