WIP - #b[ token for byte array
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
632fbfdba2
commit
2e1ae8d9ee
@ -581,6 +581,14 @@ struct hcl_flx_hi_t
|
||||
hcl_oow_t char_count;
|
||||
};
|
||||
|
||||
typedef struct hcl_flx_hb_t hcl_flx_hb_t; /* intermediate state for #b */
|
||||
struct hcl_flx_hb_t
|
||||
{
|
||||
/* state data */
|
||||
hcl_oow_t not_unused; /* for now */
|
||||
};
|
||||
|
||||
|
||||
typedef struct hcl_flx_hn_t hcl_flx_hn_t; /* hash-marked number - radixed number */
|
||||
struct hcl_flx_hn_t
|
||||
{
|
||||
@ -658,6 +666,7 @@ enum hcl_flx_state_t
|
||||
HCL_FLX_COMMENT,
|
||||
HCL_FLX_DELIM_TOKEN,
|
||||
HCL_FLX_HMARKED_TOKEN, /* hash-marked token */
|
||||
HCL_FLX_HMARKED_B, /* #b - intermediate state before #b[ or #b-radixed binary number */
|
||||
HCL_FLX_HMARKED_CHAR, /* hash-marked character that begins with #\ */
|
||||
HCL_FLX_HMARKED_IDENT, /* hash-marked identifier like #include, etc */
|
||||
HCL_FLX_HMARKED_NUMBER, /* hash-marked number - radixed number like #xABCD */
|
||||
@ -750,6 +759,7 @@ struct hcl_compiler_t
|
||||
hcl_flx_dt_t dt; /* delimiter token */
|
||||
hcl_flx_hc_t hc; /* hash-marked character */
|
||||
hcl_flx_hi_t hi; /* hash-marked identifier */
|
||||
hcl_flx_hb_t hb; /* #b ... */
|
||||
hcl_flx_hn_t hn; /* hash-marked number - radixed number */
|
||||
hcl_flx_pi_t pi; /* plain identifier */
|
||||
hcl_flx_pn_t pn; /* plain number */
|
||||
|
21
lib/read.c
21
lib/read.c
@ -1722,6 +1722,7 @@ static int feed_continue_with_char (hcl_t* hcl, hcl_ooci_t c, hcl_flx_state_t st
|
||||
#define FLX_DT(hcl) (&((hcl)->c->feed.lx.u.dt))
|
||||
#define FLX_HC(hcl) (&((hcl)->c->feed.lx.u.hc))
|
||||
#define FLX_HI(hcl) (&((hcl)->c->feed.lx.u.hi))
|
||||
#define FLX_HB(hcl) (&((hcl)->c->feed.lx.u.hb))
|
||||
#define FLX_HN(hcl) (&((hcl)->c->feed.lx.u.hn))
|
||||
#define FLX_PI(hcl) (&((hcl)->c->feed.lx.u.pi))
|
||||
#define FLX_PN(hcl) (&((hcl)->c->feed.lx.u.pn))
|
||||
@ -1739,6 +1740,11 @@ static HCL_INLINE void init_flx_hi (hcl_flx_hi_t* hi)
|
||||
HCL_MEMSET (hi, 0, HCL_SIZEOF(*hi));
|
||||
}
|
||||
|
||||
static HCL_INLINE void init_flx_hb (hcl_flx_hb_t* hb)
|
||||
{
|
||||
HCL_MEMSET (hb, 0, HCL_SIZEOF(*hb));
|
||||
}
|
||||
|
||||
static HCL_INLINE void init_flx_hn (hcl_flx_hn_t* hn, hcl_tok_type_t tok_type, hcl_synerrnum_t synerr_code, int radix)
|
||||
{
|
||||
HCL_MEMSET (hn, 0, HCL_SIZEOF(*hn));
|
||||
@ -1987,8 +1993,15 @@ static int flx_hmarked_token (hcl_t* hcl, hcl_ooci_t c)
|
||||
goto radixed_number;
|
||||
|
||||
case 'b':
|
||||
#if 0
|
||||
init_flx_hn (FLX_HN(hcl), HCL_TOK_RADNUMLIT, HCL_SYNERR_NUMLIT, 2);
|
||||
goto radixed_number;
|
||||
#else
|
||||
/* if #b is followed by [, it is a starter for a byte array */
|
||||
init_flx_hb (FLX_HB(hcl));
|
||||
FEED_CONTINUE_WITH_CHAR (hcl, c, HCL_FLX_HMARKED_B);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'e':
|
||||
init_flx_hn (FLX_HN(hcl), HCL_TOK_ERRLIT, HCL_SYNERR_ERRLIT, 10);
|
||||
@ -2174,11 +2187,13 @@ not_consumed:
|
||||
|
||||
static int flx_hmarked_b (hcl_t* hcl, hcl_ooci_t c)
|
||||
{
|
||||
#if 0
|
||||
hcl_flx_hb_t* hb = FLX_HB(hcl);
|
||||
/*hcl_flx_hb_t* hb = FLX_HB(hcl);*/
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
/* #b[ - byte array starter */
|
||||
FEED_WRAP_UP_WITH_CHAR (hcl, c, HCL_TOK_BAPAREN);
|
||||
goto consumed;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2186,7 +2201,6 @@ static int flx_hmarked_b (hcl_t* hcl, hcl_ooci_t c)
|
||||
FEED_CONTINUE (hcl, HCL_FLX_HMARKED_NUMBER);
|
||||
goto not_consumed;
|
||||
}
|
||||
#endif
|
||||
|
||||
consumed:
|
||||
return 1;
|
||||
@ -2682,6 +2696,7 @@ static int feed_char (hcl_t* hcl, hcl_ooci_t c)
|
||||
case HCL_FLX_COMMENT: return flx_comment(hcl, c);
|
||||
case HCL_FLX_DELIM_TOKEN: return flx_delim_token(hcl, c);
|
||||
case HCL_FLX_HMARKED_TOKEN: return flx_hmarked_token(hcl, c);
|
||||
case HCL_FLX_HMARKED_B: return flx_hmarked_b(hcl, c);
|
||||
case HCL_FLX_HMARKED_CHAR: return flx_hmarked_char(hcl, c);
|
||||
case HCL_FLX_HMARKED_IDENT: return flx_hmarked_ident(hcl, c);
|
||||
case HCL_FLX_HMARKED_NUMBER: return flx_hmarked_number(hcl, c);
|
||||
|
@ -20,6 +20,7 @@ check_ERRORS = \
|
||||
feed-5003.err \
|
||||
feed-5004.err \
|
||||
feed-5005.err \
|
||||
feed-5006.err \
|
||||
mlist-5001.err \
|
||||
var-5001.err \
|
||||
var-5002.err \
|
||||
|
@ -491,6 +491,7 @@ check_ERRORS = \
|
||||
feed-5003.err \
|
||||
feed-5004.err \
|
||||
feed-5005.err \
|
||||
feed-5006.err \
|
||||
mlist-5001.err \
|
||||
var-5001.err \
|
||||
var-5002.err \
|
||||
|
6
t/feed-5006.err
Normal file
6
t/feed-5006.err
Normal file
@ -0,0 +1,6 @@
|
||||
## #b can be followed by [ or binary digits.
|
||||
|
||||
printf "%O\n" #b[ 10 20 30 ];
|
||||
printf "%010b\n" #b0101;
|
||||
printf "%O\n" #bxy; ##ERROR: syntax error - neither valid radixed number nor valid directive #bxy
|
||||
|
Loading…
Reference in New Issue
Block a user