dropped cli-mode code. it turned out to be not effective
This commit is contained in:
parent
f87ebd527e
commit
9a186711e4
101
lib/comp.c
101
lib/comp.c
@ -1365,8 +1365,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
* if the name is another function call, i can't know if the
|
||||
* function name will be valid at the compile time.
|
||||
*/
|
||||
HCL_ASSERT (hcl, HCL_IS_CONS_CONCODED(hcl, obj, HCL_CONCODE_XLIST) ||
|
||||
HCL_IS_CONS_CONCODED(hcl, obj, HCL_CONCODE_EXPLIST));
|
||||
HCL_ASSERT (hcl, HCL_IS_CONS_CONCODED(hcl, obj, HCL_CONCODE_XLIST));
|
||||
|
||||
car = HCL_CONS_CAR(obj);
|
||||
if (HCL_IS_SYMBOL(hcl,car) && (syncode = HCL_OBJ_GET_FLAGS_SYNCODE(car)))
|
||||
@ -1437,8 +1436,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (HCL_IS_SYMBOL(hcl,car) || HCL_IS_CONS_CONCODED(hcl,car,HCL_CONCODE_XLIST) ||
|
||||
((hcl->option.trait & HCL_CLI_MODE) && HCL_IS_STRING(hcl, car)))
|
||||
else if (HCL_IS_SYMBOL(hcl,car) || HCL_IS_CONS_CONCODED(hcl,car,HCL_CONCODE_XLIST))
|
||||
{
|
||||
/* normal function call
|
||||
* (<operator> <operand1> ...) */
|
||||
@ -1457,14 +1455,7 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
oldtop = GET_TOP_CFRAME_INDEX(hcl);
|
||||
HCL_ASSERT (hcl, oldtop >= 0);
|
||||
|
||||
if (HCL_IS_CONS_CONCODED(hcl,obj,HCL_CONCODE_EXPLIST))
|
||||
{
|
||||
SWITCH_TOP_CFRAME (hcl, COP_DO_NOTHING, hcl->_nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
SWITCH_TOP_CFRAME (hcl, COP_EMIT_CALL, HCL_SMOOI_TO_OOP(0));
|
||||
}
|
||||
SWITCH_TOP_CFRAME (hcl, COP_EMIT_CALL, HCL_SMOOI_TO_OOP(0));
|
||||
|
||||
/* compile <operator> */
|
||||
PUSH_CFRAME (hcl, COP_COMPILE_OBJECT, car);
|
||||
@ -1515,23 +1506,11 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||
/* redundant cdr check is performed inside compile_object_list() */
|
||||
PUSH_SUBCFRAME (hcl, COP_COMPILE_ARGUMENT_LIST, cdr);
|
||||
|
||||
if (HCL_IS_CONS_CONCODED(hcl,obj,HCL_CONCODE_EXPLIST))
|
||||
{
|
||||
/* nothing to patch */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* patch the argument count in the operand field of the COP_EMIT_CALL frame */
|
||||
cf = GET_CFRAME(hcl, oldtop);
|
||||
HCL_ASSERT (hcl, cf->opcode == COP_EMIT_CALL);
|
||||
cf->operand = HCL_SMOOI_TO_OOP(nargs);
|
||||
}
|
||||
/* patch the argument count in the operand field of the COP_EMIT_CALL frame */
|
||||
cf = GET_CFRAME(hcl, oldtop);
|
||||
HCL_ASSERT (hcl, cf->opcode == COP_EMIT_CALL);
|
||||
cf->operand = HCL_SMOOI_TO_OOP(nargs);
|
||||
}
|
||||
/* TODO:??? else if (HCL_IS_CONS_CONCODED(hcl, car, HCL_CONCODE_EXPLIST))
|
||||
{
|
||||
HCL_ASSERT (hcl, hcl->option.trait & HCL_CLI_MODE);
|
||||
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT, HCL_SMOOI_TO_OOP(0));
|
||||
} */
|
||||
else
|
||||
{
|
||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_CALLABLE, HCL_NULL, HCL_NULL, "invalid callable %O in function call - %O", car, obj); /* error location */
|
||||
@ -1588,58 +1567,28 @@ static HCL_INLINE int compile_symbol (hcl_t* hcl, hcl_oop_t obj)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hcl->option.trait & HCL_CLI_MODE)
|
||||
/* check if a symbol is a local variable */
|
||||
if (find_temporary_variable_backward(hcl, obj, &index) <= -1)
|
||||
{
|
||||
if (find_temporary_variable_backward(hcl, obj, &index) <= -1)
|
||||
hcl_oop_t cons;
|
||||
/* TODO: if i require all variables to be declared, this part is not needed and should handle it as an error */
|
||||
/* TODO: change the scheme... allow declaration??? */
|
||||
/* global variable */
|
||||
cons = (hcl_oop_t)hcl_getatsysdic(hcl, obj);
|
||||
if (!cons)
|
||||
{
|
||||
hcl_oop_t cons;
|
||||
|
||||
cons = (hcl_oop_t)hcl_getatsysdic(hcl, obj);
|
||||
if (cons)
|
||||
{
|
||||
if (add_literal(hcl, cons, &index) <= -1 ||
|
||||
emit_single_param_instruction(hcl, HCL_CODE_PUSH_OBJECT_0, index) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* in the cli mode, a symbol is pushed as a normal literal if it is not resolved
|
||||
* at the moment of compilation */
|
||||
if (add_literal(hcl, obj, &index) <= -1 ||
|
||||
emit_single_param_instruction(hcl, HCL_CODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return emit_indexed_variable_access(hcl, index, HCL_CODE_PUSH_CTXTEMPVAR_0, HCL_CODE_PUSH_TEMPVAR_0);
|
||||
cons = (hcl_oop_t)hcl_putatsysdic(hcl, obj, hcl->_nil);
|
||||
if (!cons) return -1;
|
||||
}
|
||||
|
||||
if (add_literal(hcl, cons, &index) <= -1 ||
|
||||
emit_single_param_instruction(hcl, HCL_CODE_PUSH_OBJECT_0, index) <= -1) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check if a symbol is a local variable */
|
||||
if (find_temporary_variable_backward(hcl, obj, &index) <= -1)
|
||||
{
|
||||
hcl_oop_t cons;
|
||||
/* TODO: if i require all variables to be declared, this part is not needed and should handle it as an error */
|
||||
/* TODO: change the scheme... allow declaration??? */
|
||||
/* global variable */
|
||||
cons = (hcl_oop_t)hcl_getatsysdic(hcl, obj);
|
||||
if (!cons)
|
||||
{
|
||||
cons = (hcl_oop_t)hcl_putatsysdic(hcl, obj, hcl->_nil);
|
||||
if (!cons) return -1;
|
||||
}
|
||||
|
||||
if (add_literal(hcl, cons, &index) <= -1 ||
|
||||
emit_single_param_instruction(hcl, HCL_CODE_PUSH_OBJECT_0, index) <= -1) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return emit_indexed_variable_access(hcl, index, HCL_CODE_PUSH_CTXTEMPVAR_0, HCL_CODE_PUSH_TEMPVAR_0);
|
||||
}
|
||||
return emit_indexed_variable_access(hcl, index, HCL_CODE_PUSH_CTXTEMPVAR_0, HCL_CODE_PUSH_TEMPVAR_0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1686,10 +1635,6 @@ static int compile_object (hcl_t* hcl)
|
||||
if (compile_cons_dic_expression(hcl, cf->operand) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case HCL_CONCODE_EXPLIST:
|
||||
if (compile_cons_xlist_expression (hcl, cf->operand) <= -1) return -1;
|
||||
break;
|
||||
|
||||
/* TODO: QLIST? */
|
||||
default:
|
||||
if (compile_cons_xlist_expression (hcl, cf->operand) <= -1) return -1;
|
||||
|
@ -26,7 +26,11 @@
|
||||
|
||||
#include "hcl-prv.h"
|
||||
|
||||
#define SYMBOL_ONLY_KEY
|
||||
/* The dictionary functions in this file are used for storing
|
||||
* a dictionary object enclosed in {}. So putting a non-symbol
|
||||
* key is allowed like { 1 2 3 4 } where 1 and 3 are keys.
|
||||
* so SYMBOL_ONLY_KEY must not be defined */
|
||||
/*#define SYMBOL_ONLY_KEY*/
|
||||
|
||||
static hcl_oop_oop_t expand_bucket (hcl_t* hcl, hcl_oop_oop_t oldbuc)
|
||||
{
|
||||
|
15
lib/exec.c
15
lib/exec.c
@ -161,10 +161,9 @@ static void vm_checkbc (hcl_t* hcl, hcl_oob_t bcode)
|
||||
static HCL_INLINE hcl_oop_t make_context (hcl_t* hcl, hcl_ooi_t ntmprs)
|
||||
{
|
||||
HCL_ASSERT (hcl, ntmprs >= 0);
|
||||
return hcl_allocoopobj (hcl, HCL_BRAND_CONTEXT, HCL_CONTEXT_NAMED_INSTVARS + (hcl_oow_t)ntmprs);
|
||||
return hcl_allocoopobj(hcl, HCL_BRAND_CONTEXT, HCL_CONTEXT_NAMED_INSTVARS + (hcl_oow_t)ntmprs);
|
||||
}
|
||||
|
||||
|
||||
static HCL_INLINE int prepare_to_alloc_pid (hcl_t* hcl)
|
||||
{
|
||||
hcl_oow_t new_capa;
|
||||
@ -927,7 +926,7 @@ static int __activate_context (hcl_t* hcl, hcl_oop_context_t rcv_blkctx, hcl_ooi
|
||||
|
||||
/* create a new block context to clone rcv_blkctx */
|
||||
hcl_pushtmp (hcl, (hcl_oop_t*)&rcv_blkctx);
|
||||
blkctx = (hcl_oop_context_t) make_context (hcl, local_ntmprs);
|
||||
blkctx = (hcl_oop_context_t) make_context(hcl, local_ntmprs);
|
||||
hcl_poptmp (hcl);
|
||||
if (!blkctx) return -1;
|
||||
|
||||
@ -1203,7 +1202,7 @@ static int start_initial_process_and_context (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||
hcl_oop_process_t proc;
|
||||
|
||||
/* create a fake initial context. */
|
||||
ctx = (hcl_oop_context_t)make_context (hcl, 0); /* no temporary variables */
|
||||
ctx = (hcl_oop_context_t)make_context(hcl, 0); /* no temporary variables */
|
||||
if (!ctx) return -1;
|
||||
|
||||
/* the initial context starts the life of the entire VM
|
||||
@ -1758,10 +1757,6 @@ static int execute (hcl_t* hcl)
|
||||
if (call_primitive(hcl, b1) <= -1) goto oops;
|
||||
break;
|
||||
|
||||
case HCL_BRAND_SYMBOL:
|
||||
case HCL_BRAND_STRING:
|
||||
if ((hcl->option.trait & HCL_CLI_MODE) && exec_syscmd(hcl, b1) >= 0) break;
|
||||
/* fall thru */
|
||||
default:
|
||||
goto cannot_call;
|
||||
}
|
||||
@ -2281,7 +2276,7 @@ static int execute (hcl_t* hcl)
|
||||
* clones a block context and activates the cloned context.
|
||||
* this base block context is created with no temporaries
|
||||
* for this reason */
|
||||
blkctx = (hcl_oop_context_t)make_context (hcl, 0);
|
||||
blkctx = (hcl_oop_context_t)make_context(hcl, 0);
|
||||
if (!blkctx) goto oops;
|
||||
|
||||
/* the long forward jump instruction has the format of
|
||||
@ -2338,7 +2333,7 @@ static int execute (hcl_t* hcl)
|
||||
* context and activates the cloned context.
|
||||
* this base block context is created with no
|
||||
* stack for this reason. */
|
||||
blkctx = (hcl_oop_context_t)make_context (hcl, 0);
|
||||
blkctx = (hcl_oop_context_t)make_context(hcl, 0);
|
||||
if (!blkctx) goto oops;
|
||||
|
||||
/* get the receiver to the block copy message after block context instantiation
|
||||
|
@ -187,9 +187,6 @@ enum hcl_trait_t
|
||||
HCL_DEBUG_BIGINT = (1u << 1),
|
||||
#endif
|
||||
|
||||
/* command line mode */
|
||||
HCL_CLI_MODE = (1u << 7),
|
||||
|
||||
/* perform no garbage collection when the heap is full.
|
||||
* you still can use hcl_gc() explicitly. */
|
||||
HCL_NOGC = (1u << 8),
|
||||
@ -1424,9 +1421,7 @@ enum hcl_concode_t
|
||||
HCL_CONCODE_ARRAY, /* [] */
|
||||
HCL_CONCODE_BYTEARRAY, /* #[] */
|
||||
HCL_CONCODE_DIC, /* {} */
|
||||
HCL_CONCODE_QLIST, /* #() - data list */
|
||||
|
||||
HCL_CONCODE_EXPLIST /* expresssion list used in the cli mode */
|
||||
HCL_CONCODE_QLIST /* #() - data list */
|
||||
};
|
||||
typedef enum hcl_concode_t hcl_concode_t;
|
||||
|
||||
|
@ -1673,7 +1673,6 @@ int main (int argc, char* argv[])
|
||||
{ ":log", 'l' },
|
||||
{ ":memsize", 'm' },
|
||||
{ "large-pages", '\0' },
|
||||
{ "cli-mode", '\0' },
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
{ ":debug", '\0' }, /* NOTE: there is no short option for --debug */
|
||||
#endif
|
||||
@ -1688,7 +1687,6 @@ int main (int argc, char* argv[])
|
||||
const char* logopt = HCL_NULL;
|
||||
hcl_oow_t memsize = MIN_MEMSIZE;
|
||||
int large_pages = 0;
|
||||
int cli_mode = 0;
|
||||
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
const char* dbgopt = HCL_NULL;
|
||||
@ -1723,11 +1721,6 @@ int main (int argc, char* argv[])
|
||||
large_pages = 1;
|
||||
break;
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "cli-mode") == 0)
|
||||
{
|
||||
cli_mode = 1;
|
||||
break;
|
||||
}
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0)
|
||||
{
|
||||
@ -1794,8 +1787,6 @@ int main (int argc, char* argv[])
|
||||
|
||||
/*trait |= HCL_NOGC;*/
|
||||
trait |= HCL_AWAIT_PROCS;
|
||||
|
||||
if (cli_mode) trait |= HCL_CLI_MODE;
|
||||
hcl_setoption (hcl, HCL_TRAIT, &trait);
|
||||
|
||||
/* disable GC logs */
|
||||
|
@ -206,10 +206,9 @@ static HCL_INLINE int outfmt_obj (hcl_t* hcl, hcl_bitmask_t mask, hcl_oop_t obj,
|
||||
{
|
||||
{ "(", "(" }, /*HCL_CONCODE_XLIST */
|
||||
{ "[", "[" }, /*HCL_CONCODE_ARRAY */
|
||||
{ "#[", "[" }, /*HCL_CONCODE_BYTEARRAY */
|
||||
{ "#[", "[" }, /*HCL_CONCODE_BYTEARRAY */
|
||||
{ "{", "{" }, /*HCL_CONCODE_DIC */
|
||||
{ "#(", "[" }, /*HCL_CONCODE_QLIST */
|
||||
{ "@(", "@(" } /*HCL_CONCODE_EXPLIST */
|
||||
{ "#(", "[" } /*HCL_CONCODE_QLIST */
|
||||
};
|
||||
|
||||
static const hcl_bch_t *closing_parens[][2] =
|
||||
@ -219,7 +218,6 @@ static HCL_INLINE int outfmt_obj (hcl_t* hcl, hcl_bitmask_t mask, hcl_oop_t obj,
|
||||
{ "]", "]" }, /*HCL_CONCODE_BYTEARRAY */
|
||||
{ "}", "}" }, /*HCL_CONCODE_DIC */
|
||||
{ ")", "]" }, /*HCL_CONCODE_QLIST */
|
||||
{ ")", ")" } /*HCL_CONCODE_EXPLIST */
|
||||
};
|
||||
|
||||
static const hcl_bch_t* breakers[][2] =
|
||||
|
268
lib/read.c
268
lib/read.c
@ -1015,18 +1015,7 @@ retry:
|
||||
do
|
||||
{
|
||||
/* skip spaces */
|
||||
while (is_spacechar(hcl->c->lxc.c))
|
||||
{
|
||||
if ((hcl->option.trait & HCL_CLI_MODE) && hcl->c->lxc.c == '\n' && TOKEN_TYPE(hcl) != HCL_IOTOK_EOL)
|
||||
{
|
||||
SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL);
|
||||
CLEAR_TOKEN_NAME (hcl);
|
||||
ADD_TOKEN_STR(hcl, vocas[VOCA_EOL].str, vocas[VOCA_EOL].len);
|
||||
hcl->c->tok.loc = hcl->c->lxc.l; /* set token location */
|
||||
goto done;
|
||||
}
|
||||
GET_CHAR (hcl);
|
||||
}
|
||||
while (is_spacechar(hcl->c->lxc.c)) GET_CHAR (hcl);
|
||||
/* the first character after the last space is in hcl->c->lxc */
|
||||
if ((n = skip_comment(hcl)) <= -1) return -1;
|
||||
}
|
||||
@ -2187,258 +2176,6 @@ static int read_object (hcl_t* hcl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_object_in_cli_mode (hcl_t* hcl)
|
||||
{
|
||||
/*
|
||||
( ls -laF
|
||||
pwd ) -> ( (ls -laF) (pwd) )
|
||||
|
||||
|
||||
|
||||
ls -laF (pwd) -> (ls -laF ( (pwd ) )
|
||||
|
||||
|
||||
ls -laF -> (ls -laF)
|
||||
|
||||
|
||||
( -> (
|
||||
ls -laF -> (ls -laF)
|
||||
pwd -> (pwd)
|
||||
) -> )
|
||||
|
||||
|
||||
( (
|
||||
pwd ( (pwd (
|
||||
ls -laF (ls -laF)
|
||||
) ) )
|
||||
) )
|
||||
|
||||
* SOME key test cases
|
||||
------------
|
||||
(pwd)
|
||||
------------
|
||||
(pwd
|
||||
)
|
||||
------------
|
||||
(
|
||||
pwd)
|
||||
------------
|
||||
(
|
||||
pwd
|
||||
)
|
||||
------------
|
||||
pwd (pwd)
|
||||
------------
|
||||
pwd (pwd
|
||||
)
|
||||
*
|
||||
|
||||
---------------
|
||||
pwd) -------> error
|
||||
|
||||
*/
|
||||
int level = 0, array_level = 0, flagv = 0;
|
||||
hcl_oop_t obj;
|
||||
int start_virtual_list = 1;
|
||||
hcl_iotok_type_t prev_token_type = HCL_IOTOK_EOF;
|
||||
|
||||
if (TOKEN_TYPE(hcl) == HCL_IOTOK_LPAREN) start_virtual_list = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
redo:
|
||||
if (start_virtual_list)
|
||||
{
|
||||
HCL_DEBUG0 (hcl, "STARTING vritual list...\n");
|
||||
flagv = 0;
|
||||
LIST_FLAG_SET_CONCODE (flagv, HCL_CONCODE_XLIST);
|
||||
|
||||
/* push some data to simulate recursion into
|
||||
* a list literal or an array literal */
|
||||
if (enter_list(hcl, flagv) == HCL_NULL) goto oops;
|
||||
level++;
|
||||
//if (LIST_FLAG_GET_CONCODE(flagv) == HCL_CONCODE_ARRAY) array_level++;
|
||||
|
||||
start_virtual_list = 0;
|
||||
}
|
||||
|
||||
switch (TOKEN_TYPE(hcl))
|
||||
{
|
||||
default:
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_ILTOK, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
|
||||
goto oops;
|
||||
|
||||
case HCL_IOTOK_EOF:
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_EOF, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
|
||||
goto oops;
|
||||
|
||||
case HCL_IOTOK_INCLUDE:
|
||||
/* TODO: should i limit where #include can be specified?
|
||||
* disallow it inside a list literal or an array literal? */
|
||||
GET_TOKEN (hcl);
|
||||
if (TOKEN_TYPE(hcl) != HCL_IOTOK_STRLIT)
|
||||
{
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_STRING, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
|
||||
goto oops;
|
||||
}
|
||||
if (begin_include(hcl) <= -1) goto oops;
|
||||
goto redo;
|
||||
|
||||
case HCL_IOTOK_LPAREN: /* () */
|
||||
flagv = 0;
|
||||
LIST_FLAG_SET_CONCODE (flagv, HCL_CONCODE_EXPLIST);
|
||||
/*start_list:*/
|
||||
if (level >= HCL_TYPE_MAX(int))
|
||||
{
|
||||
/* the nesting level has become too deep */
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_NESTING, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* push some data to simulate recursion into
|
||||
* a list literal or an array literal */
|
||||
HCL_DEBUG0 (hcl, "111 STARTING list...\n");
|
||||
if (enter_list(hcl, flagv) == HCL_NULL) goto oops;
|
||||
level++;
|
||||
//if (LIST_FLAG_GET_CONCODE(flagv) == HCL_CONCODE_ARRAY) array_level++;
|
||||
|
||||
/* read the next token */
|
||||
start_virtual_list = 1;
|
||||
goto next_token;
|
||||
|
||||
case HCL_IOTOK_EOL:
|
||||
{
|
||||
int oldflagv;
|
||||
//int concode;
|
||||
|
||||
if (prev_token_type == HCL_IOTOK_EOL || prev_token_type == HCL_IOTOK_LPAREN) goto next_token;
|
||||
|
||||
if (level <= 0)
|
||||
{
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
HCL_DEBUG1 (hcl, "11 LEAVING LIST level->%d\n", (int)level);
|
||||
//concode = LIST_FLAG_GET_CONCODE(flagv);
|
||||
obj = leave_list(hcl, &flagv, &oldflagv);
|
||||
|
||||
level--;
|
||||
//if (LIST_FLAG_GET_CONCODE(oldflagv) == HCL_CONCODE_ARRAY) array_level--;
|
||||
|
||||
start_virtual_list = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case HCL_IOTOK_RPAREN:
|
||||
{
|
||||
int oldflagv;
|
||||
//int concode;
|
||||
|
||||
if (prev_token_type == HCL_IOTOK_LPAREN)
|
||||
{
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_EMPTYXLIST, TOKEN_LOC(hcl), HCL_NULL); /* TODO: change error code?? */
|
||||
goto oops;
|
||||
}
|
||||
else if (prev_token_type == HCL_IOTOK_EOL)
|
||||
{
|
||||
if (level <= 1) goto unbalpbb;
|
||||
|
||||
obj = leave_list(hcl, &flagv, &oldflagv);
|
||||
level--;
|
||||
//if (LIST_FLAG_GET_CONCODE(oldflagv) == HCL_CONCODE_ARRAY) array_level--;
|
||||
|
||||
if (!obj) goto oops;
|
||||
HCL_ASSERT (hcl, level > 0);
|
||||
HCL_ASSERT (hcl, obj == hcl->_nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* exit #1 */
|
||||
if (level <= 1) goto unbalpbb;
|
||||
|
||||
//concode = LIST_FLAG_GET_CONCODE(flagv);
|
||||
HCL_DEBUG0 (hcl, "22 LEAVING LIST\n");
|
||||
obj = leave_list(hcl, &flagv, &oldflagv);
|
||||
level--;
|
||||
//if (LIST_FLAG_GET_CONCODE(oldflagv) == HCL_CONCODE_ARRAY) array_level--;
|
||||
|
||||
if (!obj) goto oops;
|
||||
HCL_ASSERT (hcl, level > 0);
|
||||
|
||||
if (obj != hcl->_nil)
|
||||
{
|
||||
//HCL_ASSERT (hcl, obj == hcl->_nil);
|
||||
HCL_DEBUG1 (hcl, "00 ADDING TO LIST %O\n", obj);
|
||||
if (chain_to_list(hcl, obj) == HCL_NULL) goto oops;
|
||||
clear_comma_colon_flag (hcl);
|
||||
}
|
||||
}
|
||||
|
||||
/* exit #2 */
|
||||
if (level <= 0)
|
||||
{
|
||||
unbalpbb:
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
HCL_DEBUG1 (hcl, "33 LEAVING LIST level %d\n", level);
|
||||
//concode = LIST_FLAG_GET_CONCODE(flagv);
|
||||
obj = leave_list(hcl, &flagv, &oldflagv); /* this object is added to the chain after break */
|
||||
level--;
|
||||
|
||||
//if (LIST_FLAG_GET_CONCODE(oldflagv) == HCL_CONCODE_ARRAY) array_level--;
|
||||
|
||||
if (!obj) goto oops;
|
||||
if (obj == hcl->_nil)
|
||||
{
|
||||
/* consider an input like ls (pwd <EOL>) where EOL is '\n' */
|
||||
goto next_token;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case HCL_IOTOK_NUMLIT:
|
||||
case HCL_IOTOK_RADNUMLIT:
|
||||
obj = string_to_num(hcl, TOKEN_NAME(hcl), TOKEN_TYPE(hcl) == HCL_IOTOK_RADNUMLIT);
|
||||
break;
|
||||
|
||||
case HCL_IOTOK_STRLIT:
|
||||
obj = hcl_makestring(hcl, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl), 0);
|
||||
break;
|
||||
|
||||
case HCL_IOTOK_IDENT:
|
||||
obj = hcl_makestring(hcl, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl), 0);
|
||||
obj = hcl_makesymbol(hcl, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!obj) goto oops;
|
||||
|
||||
/* check if we are at the top level */
|
||||
if (level <= 0) break; /* yes */
|
||||
|
||||
/* if not, append the element read into the current list.
|
||||
* if we are not at the top level, we must be in a list */
|
||||
HCL_DEBUG1 (hcl, "11 ADDING TO LIST %O\n", obj);
|
||||
if (chain_to_list(hcl, obj) == HCL_NULL) goto oops;
|
||||
clear_comma_colon_flag (hcl);
|
||||
|
||||
next_token:
|
||||
prev_token_type = TOKEN_TYPE(hcl);
|
||||
/* read the next token */
|
||||
GET_TOKEN (hcl);
|
||||
}
|
||||
|
||||
hcl->c->r.e = obj;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL); /* to make get_token() not return an immediate EOL after error */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static HCL_INLINE int __read (hcl_t* hcl)
|
||||
{
|
||||
if (get_token(hcl) <= -1) return -1;
|
||||
@ -2447,7 +2184,7 @@ static HCL_INLINE int __read (hcl_t* hcl)
|
||||
hcl_seterrnum (hcl, HCL_EFINIS);
|
||||
return -1;
|
||||
}
|
||||
return (hcl->option.trait & HCL_CLI_MODE)? read_object_in_cli_mode(hcl): read_object(hcl);
|
||||
return read_object(hcl);
|
||||
}
|
||||
|
||||
hcl_oop_t hcl_read (hcl_t* hcl)
|
||||
@ -2615,7 +2352,6 @@ int hcl_attachio (hcl_t* hcl, hcl_ioimpl_t reader, hcl_ioimpl_t printer)
|
||||
|
||||
/* the stream is open. set it as the current input stream */
|
||||
hcl->c->curinp = &hcl->c->inarg;
|
||||
if (hcl->option.trait & HCL_CLI_MODE) SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL);
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
|
75
lib/work.txt
75
lib/work.txt
@ -1,75 +0,0 @@
|
||||
(ls -laF @((pwd) (pwd) (pwd)))
|
||||
2018-08-08 00:32:16 +0900 000000 push_literal @0
|
||||
2018-08-08 00:32:16 +0900 000001 push_literal @1
|
||||
2018-08-08 00:32:16 +0900 000002 push_literal @2
|
||||
2018-08-08 00:32:16 +0900 000003 call 0 pwd
|
||||
2018-08-08 00:32:16 +0900 000004 push_literal @2
|
||||
2018-08-08 00:32:16 +0900 000005 call 0 pwd
|
||||
2018-08-08 00:32:16 +0900 000006 push_literal @2
|
||||
2018-08-08 00:32:16 +0900 000007 call 0 pwd
|
||||
2018-08-08 00:32:16 +0900 000008 call 2
|
||||
2018-08-08 00:32:16 +0900 000009 pop_stacktop
|
||||
2018-08-08 00:32:16 +0900 @0 ls
|
||||
2018-08-08 00:32:16 +0900 @1 -laF
|
||||
2018-08-08 00:32:16 +0900 @2 pwd
|
||||
|
||||
|
||||
|
||||
|
||||
(ls -laF @((echo qq) (echo jj) (echo -n cc)))
|
||||
2018-08-08 00:57:55 +0900 000000 push_literal @0
|
||||
2018-08-08 00:57:55 +0900 000001 push_literal @1
|
||||
2018-08-08 00:57:55 +0900 000002 push_literal @2
|
||||
2018-08-08 00:57:55 +0900 000003 push_literal @3
|
||||
2018-08-08 00:57:55 +0900 000004 call 1 echo qq
|
||||
2018-08-08 00:57:55 +0900 000005 push_literal @2
|
||||
2018-08-08 00:57:55 +0900 000006 push_literal @4
|
||||
2018-08-08 00:57:55 +0900 000007 call 1 echo jj
|
||||
2018-08-08 00:57:55 +0900 000008 push_literal @2
|
||||
2018-08-08 00:57:55 +0900 000009 push_literal @5
|
||||
2018-08-08 00:57:55 +0900 000010 push_literal @6
|
||||
2018-08-08 00:57:55 +0900 000011 call 2 echo -n cc
|
||||
2018-08-08 00:57:55 +0900 000012 call 2 ls -laF ....
|
||||
2018-08-08 00:57:55 +0900 000013 pop_stacktop
|
||||
2018-08-08 00:57:55 +0900 @0 ls
|
||||
2018-08-08 00:57:55 +0900 @1 -laF
|
||||
2018-08-08 00:57:55 +0900 @2 echo
|
||||
2018-08-08 00:57:55 +0900 @3 qq
|
||||
2018-08-08 00:57:55 +0900 @4 jj
|
||||
2018-08-08 00:57:55 +0900 @5 -n
|
||||
2018-08-08 00:57:55 +0900 @6 cc
|
||||
|
||||
|
||||
|
||||
(ls -laF @((@((pwd)))))
|
||||
|
||||
|
||||
|
||||
ls -laF (
|
||||
(
|
||||
pwd
|
||||
ps -ef
|
||||
)
|
||||
) ====> (ls -laF @(
|
||||
(
|
||||
@(
|
||||
(pwd)
|
||||
(ps -ef)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
ls -laF (
|
||||
(
|
||||
pwd
|
||||
ps -ef
|
||||
) -qq
|
||||
) ===========> (ls -laF @(
|
||||
(
|
||||
@((pwd) (ps -ef)) -qq
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user