added hcl_getsynerrnum() and enhanced EOF handling

This commit is contained in:
hyung-hwan 2018-07-28 04:08:09 +00:00
parent 4280387771
commit 1b59610444
10 changed files with 56 additions and 8 deletions

View File

@ -354,6 +354,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -584,7 +585,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)" || chmod -R a+r "$(distdir)"
dist-gzip: distdir dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-bzip2: distdir dist-bzip2: distdir
@ -610,7 +611,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \ @echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2 "deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-zip: distdir dist-zip: distdir
@ -628,7 +629,7 @@ dist dist-all:
distcheck: dist distcheck: dist
case '$(DIST_ARCHIVES)' in \ case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \ *.tar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \ *.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \ *.tar.lz*) \
@ -638,7 +639,7 @@ distcheck: dist
*.tar.Z*) \ *.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \ *.shar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac

14
configure vendored
View File

@ -782,6 +782,7 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -875,6 +876,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1127,6 +1129,15 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1264,7 +1275,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir libdir localedir mandir runstatedir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1417,6 +1428,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]

View File

@ -420,6 +420,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@

View File

@ -375,6 +375,12 @@ void hcl_getsynerr (hcl_t* hcl, hcl_synerr_t* synerr)
if (synerr) *synerr = hcl->c->synerr; if (synerr) *synerr = hcl->c->synerr;
} }
hcl_synerrnum_t hcl_getsynerrnum (hcl_t* hcl)
{
HCL_ASSERT (hcl, hcl->c != HCL_NULL);
return hcl->c->synerr.num;
}
void hcl_setsynerrbfmt (hcl_t* hcl, hcl_synerrnum_t num, const hcl_ioloc_t* loc, const hcl_oocs_t* tgt, const hcl_bch_t* msgfmt, ...) void hcl_setsynerrbfmt (hcl_t* hcl, hcl_synerrnum_t num, const hcl_ioloc_t* loc, const hcl_oocs_t* tgt, const hcl_bch_t* msgfmt, ...)
{ {
static hcl_bch_t syntax_error[] = "syntax error - "; static hcl_bch_t syntax_error[] = "syntax error - ";

View File

@ -169,6 +169,7 @@ enum hcl_iotok_type_t
HCL_IOTOK_LBRACE, /* { */ HCL_IOTOK_LBRACE, /* { */
HCL_IOTOK_RBRACE, /* } */ HCL_IOTOK_RBRACE, /* } */
HCL_IOTOK_VBAR, HCL_IOTOK_VBAR,
HCL_IOTOK_EOL, /* end of line */
HCL_IOTOK_INCLUDE HCL_IOTOK_INCLUDE
}; };

View File

@ -2651,7 +2651,6 @@ int hcl_server_start (hcl_server_t* server, const hcl_bch_t* addrs)
free_worker (worker); free_worker (worker);
} }
} }
} }
} }
} }

View File

@ -187,6 +187,9 @@ enum hcl_trait_t
HCL_DEBUG_BIGINT = (1u << 1), HCL_DEBUG_BIGINT = (1u << 1),
#endif #endif
/* command line mode */
HCL_CLI_MODE = (1u << 7),
/* perform no garbage collection when the heap is full. /* perform no garbage collection when the heap is full.
* you still can use hcl_gc() explicitly. */ * you still can use hcl_gc() explicitly. */
HCL_NOGC = (1u << 8), HCL_NOGC = (1u << 8),
@ -1754,6 +1757,9 @@ HCL_EXPORT void hcl_getsynerr (
hcl_synerr_t* synerr hcl_synerr_t* synerr
); );
HCL_EXPORT hcl_synerrnum_t hcl_getsynerrnum (
hcl_t* hcl
);
HCL_EXPORT void hcl_setsynerrbfmt ( HCL_EXPORT void hcl_setsynerrbfmt (
hcl_t* hcl, hcl_t* hcl,

View File

@ -1674,6 +1674,7 @@ int main (int argc, char* argv[])
{ ":log", 'l' }, { ":log", 'l' },
{ ":memsize", 'm' }, { ":memsize", 'm' },
{ "large-pages", '\0' }, { "large-pages", '\0' },
{ "cli-mode", '\0' },
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
{ ":debug", '\0' }, /* NOTE: there is no short option for --debug */ { ":debug", '\0' }, /* NOTE: there is no short option for --debug */
#endif #endif
@ -1688,6 +1689,7 @@ int main (int argc, char* argv[])
const char* logopt = HCL_NULL; const char* logopt = HCL_NULL;
hcl_oow_t memsize = MIN_MEMSIZE; hcl_oow_t memsize = MIN_MEMSIZE;
int large_pages = 0; int large_pages = 0;
int cli_mode = 0;
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
const char* dbgopt = HCL_NULL; const char* dbgopt = HCL_NULL;
@ -1722,6 +1724,11 @@ int main (int argc, char* argv[])
large_pages = 1; large_pages = 1;
break; break;
} }
else if (hcl_comp_bcstr(opt.lngopt, "cli-mode") == 0)
{
cli_mode = 1;
break;
}
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0) else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0)
{ {
@ -1788,6 +1795,8 @@ int main (int argc, char* argv[])
/*trait |= HCL_NOGC;*/ /*trait |= HCL_NOGC;*/
trait |= HCL_AWAIT_PROCS; trait |= HCL_AWAIT_PROCS;
if (cli_mode) trait |= HCL_CLI_MODE;
hcl_setoption (hcl, HCL_TRAIT, &trait); hcl_setoption (hcl, HCL_TRAIT, &trait);
/* disable GC logs */ /* disable GC logs */
@ -1879,7 +1888,7 @@ count++;
else if (hcl->errnum == HCL_ESYNERR) else if (hcl->errnum == HCL_ESYNERR)
{ {
print_synerr (hcl); print_synerr (hcl);
if (xtn->reader_istty) continue; if (xtn->reader_istty && hcl_getsynerrnum(hcl) != HCL_SYNERR_EOF) continue;
} }
else else
{ {

View File

@ -58,6 +58,7 @@ static struct voca_t
{ 7, { '#','\\','s','p','a','c','e' } }, { 7, { '#','\\','s','p','a','c','e' } },
{ 5, { '#','\\','t','a','b' } }, { 5, { '#','\\','t','a','b' } },
{ 6, { '#','\\','v','t','a','b' } }, { 6, { '#','\\','v','t','a','b' } },
{ 5, { '<','E','O','L','>' } },
{ 5, { '<','E','O','F','>' } } { 5, { '<','E','O','F','>' } }
}; };
@ -75,6 +76,7 @@ enum voca_id_t
VOCA_TAB, VOCA_TAB,
VOCA_VTAB, VOCA_VTAB,
VOCA_EOL,
VOCA_EOF VOCA_EOF
}; };
typedef enum voca_id_t voca_id_t; typedef enum voca_id_t voca_id_t;
@ -1013,7 +1015,17 @@ retry:
do do
{ {
/* skip spaces */ /* skip spaces */
while (is_spacechar(hcl->c->lxc.c)) GET_CHAR (hcl); while (is_spacechar(hcl->c->lxc.c))
{
if ((hcl->option.trait & HCL_CLI_MODE) && hcl->c->lxc.c == '\n')
{
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 */
}
GET_CHAR (hcl);
}
/* the first character after the last space is in hcl->c->lxc */ /* the first character after the last space is in hcl->c->lxc */
if ((n = skip_comment(hcl)) <= -1) return -1; if ((n = skip_comment(hcl)) <= -1) return -1;
} }

View File

@ -377,6 +377,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@