some improvement to the hcl command in the interactive mode
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
b80bea5f73
commit
c260301db1
27
bin/main.c
27
bin/main.c
@ -388,6 +388,13 @@ static void print_synerr (hcl_t* hcl)
|
|||||||
hcl_logbfmt (hcl, HCL_LOG_STDERR, "\n");
|
hcl_logbfmt (hcl, HCL_LOG_STDERR, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void print_error (hcl_t* hcl, const hcl_bch_t* msghdr)
|
||||||
|
{
|
||||||
|
if (HCL_ERRNUM(hcl) == HCL_ESYNERR) print_synerr (hcl);
|
||||||
|
else hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: %hs - [%d] %js\n", msghdr, hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
||||||
|
}
|
||||||
|
|
||||||
static void show_prompt (hcl_t* hcl, int level)
|
static void show_prompt (hcl_t* hcl, int level)
|
||||||
{
|
{
|
||||||
/* TODO: different prompt per level */
|
/* TODO: different prompt per level */
|
||||||
@ -485,8 +492,15 @@ static hcl_oop_t execute_in_batch_mode(hcl_t* hcl, int verbose)
|
|||||||
static int on_fed_cnode_in_interactive_mode (hcl_t* hcl, hcl_cnode_t* obj)
|
static int on_fed_cnode_in_interactive_mode (hcl_t* hcl, hcl_cnode_t* obj)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||||
if (hcl_compile(hcl, obj, HCL_COMPILE_CLEAR_CODE | HCL_COMPILE_CLEAR_FNBLK) <= -1) return -1;
|
int flags = HCL_COMPILE_CLEAR_CODE | HCL_COMPILE_CLEAR_FNBLK;
|
||||||
execute_in_interactive_mode (hcl);
|
|
||||||
|
/* in the interactive, the compile error must not break the input loop.
|
||||||
|
* this function returns 0 to go on despite a compile-time error */
|
||||||
|
|
||||||
|
if (hcl_compile(hcl, obj, flags) <= -1)
|
||||||
|
print_error(hcl, "failed to compile");
|
||||||
|
else
|
||||||
|
execute_in_interactive_mode (hcl);
|
||||||
|
|
||||||
show_prompt (hcl, 0);
|
show_prompt (hcl, 0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -553,7 +567,11 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bch = ch;
|
bch = ch;
|
||||||
if (hcl_feedbchars(hcl, &bch, 1) <= -1) goto feed_error;
|
if (hcl_feedbchars(hcl, &bch, 1) <= -1)
|
||||||
|
{
|
||||||
|
print_error (hcl, "failed to feed");
|
||||||
|
show_prompt (hcl, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -577,8 +595,7 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
|||||||
if (hcl_endfeed(hcl) <= -1)
|
if (hcl_endfeed(hcl) <= -1)
|
||||||
{
|
{
|
||||||
feed_error:
|
feed_error:
|
||||||
if (hcl->errnum == HCL_ESYNERR) print_synerr (hcl);
|
print_error (hcl, "failed to feed");
|
||||||
else hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot feed - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
|
|
||||||
goto oops; /* TODO: proceed or just exit? */
|
goto oops; /* TODO: proceed or just exit? */
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
@ -2054,6 +2054,7 @@ static int flx_start (hcl_t* hcl, hcl_ooci_t c)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* TODO: limit identifier character - is_identchar(), is_identleadchar() */
|
||||||
init_flx_pi (FLX_PI(hcl));
|
init_flx_pi (FLX_PI(hcl));
|
||||||
FEED_CONTINUE (hcl, HCL_FLX_PLAIN_IDENT);
|
FEED_CONTINUE (hcl, HCL_FLX_PLAIN_IDENT);
|
||||||
}
|
}
|
||||||
@ -2506,7 +2507,7 @@ static int flx_plain_ident (hcl_t* hcl, hcl_ooci_t c) /* identifier */
|
|||||||
/* if single-segmented, perform classification(call classify_ident_token()) again
|
/* if single-segmented, perform classification(call classify_ident_token()) again
|
||||||
* bcause self and super as the first segment have not been marked as a non-identifier above */
|
* bcause self and super as the first segment have not been marked as a non-identifier above */
|
||||||
tok_type = (pi->seg_count == 1? classify_ident_token(hcl, TOKEN_NAME(hcl)):
|
tok_type = (pi->seg_count == 1? classify_ident_token(hcl, TOKEN_NAME(hcl)):
|
||||||
(pi->is_cla? HCL_TOK_IDENT_DOTTED_CLA: HCL_TOK_IDENT_DOTTED));
|
(pi->is_cla? HCL_TOK_IDENT_DOTTED_CLA: HCL_TOK_IDENT_DOTTED));
|
||||||
FEED_WRAP_UP (hcl, tok_type);
|
FEED_WRAP_UP (hcl, tok_type);
|
||||||
goto not_consumed;
|
goto not_consumed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user