diff --git a/bin/main.c b/bin/main.c index f3d4a2e..81fabaa 100644 --- a/bin/main.c +++ b/bin/main.c @@ -636,7 +636,7 @@ int main (int argc, char* argv[]) } } - if (opt.ind >= argc) goto print_usage; + if ((opt.ind + 1) != argc) goto print_usage; #endif hcl = hcl_openstd(HCL_SIZEOF(xtn_t), HCL_NULL); @@ -653,7 +653,7 @@ int main (int argc, char* argv[]) hcl_setoption (hcl, HCL_SYMTAB_SIZE, &tab_size); tab_size = 5000; hcl_setoption (hcl, HCL_SYSDIC_SIZE, &tab_size); - tab_size = 600; + tab_size = 600; /* TODO: choose a better stack size or make this user specifiable */ hcl_setoption (hcl, HCL_PROCSTK_SIZE, &tab_size); } diff --git a/lib/read.c b/lib/read.c index 5634a57..3057242 100644 --- a/lib/read.c +++ b/lib/read.c @@ -1064,6 +1064,7 @@ static int feed_process_token (hcl_t* hcl) { hcl_frd_t* frd = &hcl->c->feed.rd; hcl_loc_t* list_loc = HCL_NULL; + int rbrace_again = 0; /* TODO: frd->obj and frd->list_loc can become local variables in this function.. */ /* this function composes an s-expression non-recursively @@ -1242,6 +1243,7 @@ static int feed_process_token (hcl_t* hcl) int concode; hcl_rstl_t* rstl; + semicolon: /* the parent list must be inspected instead of the current feed/read status pointed to by frd. */ rstl = hcl->c->r.st; if (!rstl || !(rstl->flagv & AUTO_FORGED)) @@ -1283,11 +1285,19 @@ static int feed_process_token (hcl_t* hcl) rstl = hcl->c->r.st; /* check the parent, not the current */ if (rstl && (rstl->flagv & AUTO_FORGED)) { + #if 0 /* the auto-forged list has not been terminated. it must be terminated closed first */ hcl_setsynerrbfmt (hcl, HCL_SYNERR_SEMICOLON, TOKEN_LOC(hcl), TOKEN_NAME(hcl), "semicolon expected"); goto oops; + #else + /* if the expression inside {} is an auto-forged xlist expression and there is no semiclon provided, + * treat it as if the semiclon is placed before }. e.g. { printf "hello\n" } */ + rbrace_again = 1; + goto semicolon; + #endif } } + rbrace_ok: concode = LIST_FLAG_GET_CONCODE(frd->flagv); if (concode == HCL_CONCODE_XLIST && (frd->flagv & AUTO_FORGED)) @@ -1523,6 +1533,12 @@ static int feed_process_token (hcl_t* hcl) } ok: + if (rbrace_again) + { + rbrace_again = 0; + list_loc = HCL_NULL; + goto rbrace_ok; + } return 0; oops: