renamed various names
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2023-11-05 22:31:33 +09:00
parent 94a44f1fd7
commit 20ddd12c89
9 changed files with 144 additions and 144 deletions

View File

@ -93,7 +93,7 @@ struct bb_t
typedef struct xtn_t xtn_t;
struct xtn_t
{
const char* sci_path; /* main source file */
const char* cci_path; /* main source file */
const char* udo_path;
int vm_running;
@ -360,7 +360,7 @@ static void print_synerr (hcl_t* hcl)
}
else
{
hcl_logbfmt (hcl, HCL_LOG_STDERR, "%s", xtn->sci_path);
hcl_logbfmt (hcl, HCL_LOG_STDERR, "%s", xtn->cci_path);
}
hcl_logbfmt (hcl, HCL_LOG_STDERR, "[%zu,%zu] %js",
@ -459,10 +459,10 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
hcl_oow_t xlen;
int is_tty;
fp = fopen(xtn->sci_path, FOPEN_R_FLAGS);
fp = fopen(xtn->cci_path, FOPEN_R_FLAGS);
if (!fp)
{
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: failed to open - %hs - %hs\n", xtn->sci_path, strerror(errno));
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: failed to open - %hs - %hs\n", xtn->cci_path, strerror(errno));
goto oops;
}
@ -485,7 +485,7 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
{
if (ferror(fp))
{
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: failed to read - %hs - %hs\n", xtn->sci_path, strerror(errno));
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: failed to read - %hs - %hs\n", xtn->cci_path, strerror(errno));
goto oops;
}
break;
@ -677,10 +677,10 @@ int main (int argc, char* argv[])
goto oops;
}
xtn->sci_path = argv[opt.ind++]; /* input source code file */
xtn->cci_path = argv[opt.ind++]; /* input source code file */
if (opt.ind < argc) xtn->udo_path = argv[opt.ind++];
if (hcl_attachsciostdwithbcstr(hcl, xtn->sci_path) <= -1)
if (hcl_attachcciostdwithbcstr(hcl, xtn->cci_path) <= -1)
{
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot attach source input stream - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
goto oops;

View File

@ -76,8 +76,8 @@ func (io *IOHandleTable) slot_to_io_handle(slot int) IOHandle {
var io_tab IOHandleTable = IOHandleTable{}
//export hcl_go_read_handler
func hcl_go_read_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
//export hcl_go_cci_handler
func hcl_go_cci_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
var (
g *HCL
err error
@ -88,13 +88,13 @@ func hcl_go_read_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.i
switch cmd {
case C.HCL_IO_OPEN:
var (
ioarg *C.hcl_io_sciarg_t
ioarg *C.hcl_io_cciarg_t
name string
includer_name string
fd int
)
ioarg = (*C.hcl_io_sciarg_t)(arg)
ioarg = (*C.hcl_io_cciarg_t)(arg)
if ioarg.name == nil { // main stream when it's not feed based.
name = ""
} else {
@ -119,18 +119,18 @@ func hcl_go_read_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.i
return 0
case C.HCL_IO_CLOSE:
var ioarg *C.hcl_io_sciarg_t = (*C.hcl_io_sciarg_t)(arg)
var ioarg *C.hcl_io_cciarg_t = (*C.hcl_io_cciarg_t)(arg)
g.io.r.Close(int(uintptr(ioarg.handle)))
return 0
case C.HCL_IO_READ:
var (
ioarg *C.hcl_io_sciarg_t
ioarg *C.hcl_io_cciarg_t
n int
i int
buf []rune
)
ioarg = (*C.hcl_io_sciarg_t)(arg)
ioarg = (*C.hcl_io_cciarg_t)(arg)
buf = make([]rune, 1024) // TODO: different size...
n, err = g.io.r.Read(int(uintptr(ioarg.handle)), buf)
@ -150,8 +150,8 @@ func hcl_go_read_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.i
return -1
}
//export hcl_go_scan_handler
func hcl_go_scan_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
//export hcl_go_udi_handler
func hcl_go_udi_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
var (
g *HCL
err error
@ -198,8 +198,8 @@ func hcl_go_scan_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.i
return -1
}
//export hcl_go_print_handler
func hcl_go_print_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
//export hcl_go_udo_handler
func hcl_go_udo_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.int {
var (
g *HCL
err error
@ -269,11 +269,11 @@ func hcl_go_print_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.
}
// ------------------------------------------------------
type ReadFileHandler struct {
type CciFileHandler struct {
g *HCL
}
func (p *ReadFileHandler) Open(g *HCL, name string, includer_name string) (int, error) {
func (p *CciFileHandler) Open(g *HCL, name string, includer_name string) (int, error) {
var (
f *os.File
r *bufio.Reader
@ -297,7 +297,7 @@ func (p *ReadFileHandler) Open(g *HCL, name string, includer_name string) (int,
return fd, nil
}
func (p *ReadFileHandler) Close(fd int) {
func (p *CciFileHandler) Close(fd int) {
var hnd IOHandle = io_tab.slot_to_io_handle(fd)
if hnd.file != nil {
if hnd.file != os.Stdout && hnd.file != os.Stderr {
@ -308,7 +308,7 @@ func (p *ReadFileHandler) Close(fd int) {
}
}
func (p *ReadFileHandler) Read(fd int, buf []rune) (int, error) {
func (p *CciFileHandler) Read(fd int, buf []rune) (int, error) {
var (
hnd IOHandle
i int
@ -334,13 +334,13 @@ func (p *ReadFileHandler) Read(fd int, buf []rune) (int, error) {
}
// ------------------------------------------------------
type ScanFileHandler struct {
type UdiFileHandler struct {
g *HCL
f *os.File
r *bufio.Reader
}
func (p *ScanFileHandler) Open(g *HCL) error {
func (p *UdiFileHandler) Open(g *HCL) error {
var (
f *os.File
// err error
@ -359,7 +359,7 @@ func (p *ScanFileHandler) Open(g *HCL) error {
return nil
}
func (p *ScanFileHandler) Close() {
func (p *UdiFileHandler) Close() {
if p.f != nil {
if p.f != os.Stdout && p.f != os.Stderr {
p.f.Close()
@ -369,7 +369,7 @@ func (p *ScanFileHandler) Close() {
}
}
func (p *ScanFileHandler) Read(buf []rune) (int, error) {
func (p *UdiFileHandler) Read(buf []rune) (int, error) {
var (
i int
c rune
@ -395,12 +395,12 @@ func (p *ScanFileHandler) Read(buf []rune) (int, error) {
// ------------------------------------------------------
type PrintFileHandler struct {
type UdoFileHandler struct {
f *os.File
w *bufio.Writer
}
func (p *PrintFileHandler) Open(g *HCL) error {
func (p *UdoFileHandler) Open(g *HCL) error {
var (
f *os.File
// err error
@ -420,7 +420,7 @@ func (p *PrintFileHandler) Open(g *HCL) error {
return nil
}
func (p *PrintFileHandler) Close() {
func (p *UdoFileHandler) Close() {
//fmt.Fprintf(os.Stderr, "XXXXXXXXXX close porint\n")
if p.f != nil {
@ -432,7 +432,7 @@ func (p *PrintFileHandler) Close() {
}
}
func (p *PrintFileHandler) Write(data []rune) error {
func (p *UdoFileHandler) Write(data []rune) error {
var err error
//fmt.Fprintf(os.Stderr, "XXXXXXXXXX write porint\n")
@ -441,7 +441,7 @@ func (p *PrintFileHandler) Write(data []rune) error {
return err
}
func (p *PrintFileHandler) WriteBytes(data []byte) error {
func (p *UdoFileHandler) WriteBytes(data []byte) error {
var err error
//fmt.Fprintf(os.Stderr, "XXXXXXXXXX write porint\n")
@ -450,7 +450,7 @@ func (p *PrintFileHandler) WriteBytes(data []byte) error {
return err
}
func (p *PrintFileHandler) Flush() error {
func (p *UdoFileHandler) Flush() error {
//fmt.Fprintf(os.Stderr, "XXXXXXXXXX flush porint\n")
return p.w.Flush()
}

View File

@ -5,18 +5,18 @@ package hcl
#include <hcl-utl.h>
#include <stdlib.h> // for C.freem
extern int hcl_go_read_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
extern int hcl_go_scan_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
extern int hcl_go_print_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
extern int hcl_go_cci_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
extern int hcl_go_udi_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
extern int hcl_go_udo_handler (hcl_t hcl, hcl_io_cmd_t cmd, void* arg);
int hcl_read_handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_read_handler(hcl, cmd, arg);
int hcl_cci_Handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_cci_handler(hcl, cmd, arg);
}
int hcl_scan_handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_scan_handler(hcl, cmd, arg);
int hcl_udi_handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_udi_handler(hcl, cmd, arg);
}
int hcl_print_handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_print_handler(hcl, cmd, arg);
int hcl_udo_handler_for_go (hcl_t hcl, hcl_io_cmd_t cmd, void* arg) {
return hcl_go_udo_handler(hcl, cmd, arg);
}
*/
import "C"
@ -181,7 +181,7 @@ func (hcl *HCL) AddBuiltinPrims() error {
return nil
}
func (hcl *HCL) AttachSCIO(r IOReadImpl) error {
func (hcl *HCL) AttachCCIO(r IOReadImpl) error {
var x C.int
var or IOReadImpl
@ -189,7 +189,7 @@ func (hcl *HCL) AttachSCIO(r IOReadImpl) error {
hcl.io.r = r
x = C.hcl_attachscio(hcl.c, C.hcl_io_impl_t(C.hcl_read_handler_for_go))
x = C.hcl_attachccio(hcl.c, C.hcl_io_impl_t(C.hcl_cci_Handler_for_go))
if x <= -1 {
// restore the io handler set due to attachment failure
hcl.io.r = or
@ -210,8 +210,8 @@ func (hcl *HCL) AttachUDIO(s IOScanImpl, p IOPrintImpl) error {
hcl.io.p = p
x = C.hcl_attachudio(hcl.c,
C.hcl_io_impl_t(C.hcl_scan_handler_for_go),
C.hcl_io_impl_t(C.hcl_print_handler_for_go))
C.hcl_io_impl_t(C.hcl_udi_handler_for_go),
C.hcl_io_impl_t(C.hcl_udo_handler_for_go))
if x <= -1 {
//restore the io handlers set due to attachment failure
hcl.io.s = os

View File

@ -644,13 +644,13 @@ struct hcl_compiler_t
hcl_cb_t* cbp;
/* input handler */
hcl_io_impl_t sci_rdr;
hcl_io_impl_t cci_rdr;
/* static input data buffer */
hcl_io_sciarg_t sci_arg;
hcl_io_cciarg_t cci_arg;
/* pointer to the current input data. initially, it points to &inarg */
hcl_io_sciarg_t* curinp;
hcl_io_cciarg_t* curinp;
/* information about the last meaningful character read.
* this is a copy of curinp->lxc if no ungetting is performed.

View File

@ -316,7 +316,7 @@ static const hcl_bch_t* get_base_name (const hcl_bch_t* path)
}
static HCL_INLINE int open_read_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int open_read_stream (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl);
bb_t* bb = HCL_NULL;
@ -412,7 +412,7 @@ oops:
return -1;
}
static HCL_INLINE int close_read_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int close_read_stream (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl);
bb_t* bb;
@ -427,7 +427,7 @@ static HCL_INLINE int close_read_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
return 0;
}
static HCL_INLINE int read_input (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int read_input (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl);
bb_t* bb;
@ -545,13 +545,13 @@ static int read_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
switch (cmd)
{
case HCL_IO_OPEN:
return open_read_stream(hcl, (hcl_io_sciarg_t*)arg);
return open_read_stream(hcl, (hcl_io_cciarg_t*)arg);
case HCL_IO_CLOSE:
return close_read_stream(hcl, (hcl_io_sciarg_t*)arg);
return close_read_stream(hcl, (hcl_io_cciarg_t*)arg);
case HCL_IO_READ:
return read_input(hcl, (hcl_io_sciarg_t*)arg);
return read_input(hcl, (hcl_io_cciarg_t*)arg);
default:
hcl_seterrnum (hcl, HCL_EINTERN);
@ -718,7 +718,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_
if (hcl_ignite(proto->hcl, worker->server->cfg.actor_heap_size) <= -1) goto oops;
if (hcl_addbuiltinprims(proto->hcl) <= -1) goto oops;
if (hcl_attachscio(proto->hcl, read_handler) <= -1) goto oops;
if (hcl_attachccio(proto->hcl, read_handler) <= -1) goto oops;
if (hcl_attachudio(proto->hcl, HCL_NULL, print_handler) <= -1) goto oops;
return proto;

View File

@ -1218,8 +1218,8 @@ struct hcl_lxc_t
};
typedef struct hcl_lxc_t hcl_lxc_t;
typedef struct hcl_io_sciarg_t hcl_io_sciarg_t;
struct hcl_io_sciarg_t
typedef struct hcl_io_cciarg_t hcl_io_cciarg_t;
struct hcl_io_cciarg_t
{
/**
* [IN] I/O object name.
@ -1250,7 +1250,7 @@ struct hcl_io_sciarg_t
* [IN] points to the data of the includer. It is #HCL_NULL for the
* main stream.
*/
hcl_io_sciarg_t* includer;
hcl_io_cciarg_t* includer;
/*-----------------------------------------------------------------*/
/*----------- from here down, internal use only -------------------*/
@ -1328,7 +1328,7 @@ struct hcl_io_udoarg_t
typedef int (*hcl_io_impl_t) (
hcl_t* hcl,
hcl_io_cmd_t cmd,
void* arg /* one of hcl_io_sciarg_t*, hcl_io_udiarg_t*, hcl_io_udoarg_t* */
void* arg /* one of hcl_io_cciarg_t*, hcl_io_udiarg_t*, hcl_io_udoarg_t* */
);
/* =========================================================================
@ -2241,12 +2241,12 @@ HCL_EXPORT hcl_ooch_t* hcl_readbasesrraw (
);
HCL_EXPORT int hcl_attachscio (
HCL_EXPORT int hcl_attachccio (
hcl_t* hcl,
hcl_io_impl_t sci_rdr
hcl_io_impl_t cci_rdr
);
HCL_EXPORT void hcl_detachscio (
HCL_EXPORT void hcl_detachccio (
hcl_t* hcl
);
@ -2261,14 +2261,14 @@ HCL_EXPORT void hcl_detachudio (
);
HCL_EXPORT int hcl_attachsciostdwithucstr (
HCL_EXPORT int hcl_attachcciostdwithucstr (
hcl_t* hcl,
const hcl_uch_t* sci_file
const hcl_uch_t* cci_file
);
HCL_EXPORT int hcl_attachsciostdwithbcstr (
HCL_EXPORT int hcl_attachcciostdwithbcstr (
hcl_t* hcl,
const hcl_bch_t* sci_file
const hcl_bch_t* cci_file
);
HCL_EXPORT int hcl_attachudiostdwithucstr (

View File

@ -440,13 +440,13 @@ static int get_directive_token_type (hcl_t* hcl, hcl_tok_type_t* tok_type)
return -1;
}
static int _get_char (hcl_t* hcl, hcl_io_sciarg_t* inp)
static int _get_char (hcl_t* hcl, hcl_io_cciarg_t* inp)
{
hcl_ooci_t lc;
if (inp->b.pos >= inp->b.len)
{
if (hcl->c->sci_rdr(hcl, HCL_IO_READ, inp) <= -1) return -1;
if (hcl->c->cci_rdr(hcl, HCL_IO_READ, inp) <= -1) return -1;
if (inp->xlen <= 0)
{
@ -544,7 +544,7 @@ static int is_sr_name_in_use (hcl_t* hcl, const hcl_ooch_t* sr_name)
* this is very error prone. if there are changes in refernece
* points of this sr_name in the source code, this function also
* must be modifed. */
hcl_io_sciarg_t* cur;
hcl_io_cciarg_t* cur;
if (hcl->c->synerr.loc.file == sr_name) return 1;
@ -878,13 +878,13 @@ static void init_feed (hcl_t* hcl)
static int feed_begin_include (hcl_t* hcl)
{
hcl_io_sciarg_t* arg;
hcl_io_cciarg_t* arg;
const hcl_ooch_t* io_name;
io_name = add_sr_name(hcl, TOKEN_NAME(hcl));
if (HCL_UNLIKELY(!io_name)) return -1;
arg = (hcl_io_sciarg_t*)hcl_callocmem(hcl, HCL_SIZEOF(*arg));
arg = (hcl_io_cciarg_t*)hcl_callocmem(hcl, HCL_SIZEOF(*arg));
if (HCL_UNLIKELY(!arg)) goto oops;
arg->name = io_name;
@ -893,18 +893,18 @@ static int feed_begin_include (hcl_t* hcl)
/*arg->nl = '\0';*/
arg->includer = hcl->c->curinp;
if (hcl->c->sci_rdr(hcl, HCL_IO_OPEN, arg) <= -1)
if (hcl->c->cci_rdr(hcl, HCL_IO_OPEN, arg) <= -1)
{
const hcl_ooch_t* org_errmsg = hcl_backuperrmsg(hcl);
hcl_setsynerrbfmt (hcl, HCL_SYNERR_INCLUDE, TOKEN_LOC(hcl), TOKEN_NAME(hcl), "unable to include %js - %js", io_name, org_errmsg);
goto oops;
}
if (arg->includer == &hcl->c->sci_arg) /* top-level include */
if (arg->includer == &hcl->c->cci_arg) /* top-level include */
{
/* TODO: remove hcl_readbasesrchar() and clean up this part.
* hcl_readbasesrchar(), if called in the middle of feeds,
* updates hcl->c->sci_arg's line and colm. so use a separate
* updates hcl->c->cci_arg's line and colm. so use a separate
* field to store the current feed location for now */
hcl->c->feed.lx._oloc = hcl->c->feed.lx.loc;
}
@ -932,14 +932,14 @@ oops:
static int feed_end_include (hcl_t* hcl)
{
int x;
hcl_io_sciarg_t* cur;
hcl_io_cciarg_t* cur;
if (hcl->c->curinp == &hcl->c->sci_arg) return 0; /* no include */
if (hcl->c->curinp == &hcl->c->cci_arg) return 0; /* no include */
/* if it is an included file, close it and
* retry to read a character from an outer file */
x = hcl->c->sci_rdr(hcl, HCL_IO_CLOSE, hcl->c->curinp);
x = hcl->c->cci_rdr(hcl, HCL_IO_CLOSE, hcl->c->curinp);
/* if closing has failed, still destroy the sio structure
* first as normal and return the failure below. this way,
@ -948,7 +948,7 @@ static int feed_end_include (hcl_t* hcl)
cur = hcl->c->curinp;
hcl->c->curinp = hcl->c->curinp->includer;
if (hcl->c->curinp == &hcl->c->sci_arg)
if (hcl->c->curinp == &hcl->c->cci_arg)
{
hcl->c->feed.lx.loc = hcl->c->feed.lx._oloc;
}
@ -2365,13 +2365,13 @@ static int feed_from_includee (hcl_t* hcl)
{
int x;
HCL_ASSERT (hcl, hcl->c->curinp != HCL_NULL && hcl->c->curinp != &hcl->c->sci_arg);
HCL_ASSERT (hcl, hcl->c->curinp != HCL_NULL && hcl->c->curinp != &hcl->c->cci_arg);
do
{
if (hcl->c->curinp->b.pos >= hcl->c->curinp->b.len)
{
if (hcl->c->sci_rdr(hcl, HCL_IO_READ, hcl->c->curinp) <= -1)
if (hcl->c->cci_rdr(hcl, HCL_IO_READ, hcl->c->curinp) <= -1)
{
return -1;
}
@ -2406,14 +2406,14 @@ static int feed_from_includee (hcl_t* hcl)
if (feed_begin_include(hcl) <= -1) return -1;
}
}
while (hcl->c->curinp != &hcl->c->sci_arg);
while (hcl->c->curinp != &hcl->c->cci_arg);
return 0;
}
int hcl_beginfeed (hcl_t* hcl, hcl_on_cnode_t on_cnode)
{
HCL_ASSERT (hcl, hcl->c != HCL_NULL); /* call hcl_attachscio() or hcl_attachsciostd() first */
HCL_ASSERT (hcl, hcl->c != HCL_NULL); /* call hcl_attachccio() or hcl_attachcciostd() first */
init_feed (hcl);
if (on_cnode) hcl->c->feed.on_cnode = on_cnode;
@ -2465,7 +2465,7 @@ int hcl_feed (hcl_t* hcl, const hcl_ooch_t* data, hcl_oow_t len)
hcl->c->feed.rd.do_include_file = 0;
}
if (hcl->c->curinp && hcl->c->curinp != &hcl->c->sci_arg && feed_from_includee(hcl) <= -1)
if (hcl->c->curinp && hcl->c->curinp != &hcl->c->cci_arg && feed_from_includee(hcl) <= -1)
{
/* TODO: return the number of processed characters via an argument? */
goto oops;
@ -2732,7 +2732,7 @@ static void fini_compiler_cb (hcl_t* hcl)
clear_sr_names (hcl);
if (hcl->c->tok.name.ptr) hcl_freemem (hcl, hcl->c->tok.name.ptr);
hcl_detachscio (hcl);
hcl_detachccio (hcl);
hcl_freemem (hcl, hcl->c);
hcl->c = HCL_NULL;
@ -2786,11 +2786,11 @@ static int init_compiler (hcl_t* hcl)
return 0;
}
int hcl_attachscio (hcl_t* hcl, hcl_io_impl_t sci_rdr)
int hcl_attachccio (hcl_t* hcl, hcl_io_impl_t cci_rdr)
{
int n;
int inited_compiler = 0;
hcl_io_sciarg_t new_sciarg;
hcl_io_cciarg_t new_cciarg;
if (!hcl->c)
{
@ -2799,25 +2799,25 @@ int hcl_attachscio (hcl_t* hcl, hcl_io_impl_t sci_rdr)
}
if (sci_rdr)
if (cci_rdr)
{
/* The name field and the includer field are HCL_NULL
* for the main stream */
HCL_MEMSET (&new_sciarg, 0, HCL_SIZEOF(new_sciarg));
new_sciarg.line = 1;
new_sciarg.colm = 1;
HCL_MEMSET (&new_cciarg, 0, HCL_SIZEOF(new_cciarg));
new_cciarg.line = 1;
new_cciarg.colm = 1;
/* open the top-level source input stream */
n = sci_rdr(hcl, HCL_IO_OPEN, &new_sciarg);
n = cci_rdr(hcl, HCL_IO_OPEN, &new_cciarg);
if (n <= -1) goto oops;
if (hcl->c->sci_rdr)
if (hcl->c->cci_rdr)
{
/* close the old source input stream */
hcl->c->sci_rdr (hcl, HCL_IO_CLOSE, &hcl->c->sci_arg);
hcl->c->cci_rdr (hcl, HCL_IO_CLOSE, &hcl->c->cci_arg);
}
hcl->c->sci_rdr = sci_rdr;
hcl->c->sci_arg = new_sciarg;
hcl->c->cci_rdr = cci_rdr;
hcl->c->cci_arg = new_cciarg;
/* clear unneeded source stream names */
/*clear_sr_names (hcl); <---- TODO: tricky to clean up here */
@ -2825,7 +2825,7 @@ int hcl_attachscio (hcl_t* hcl, hcl_io_impl_t sci_rdr)
/* initialize some other key fields */
hcl->c->nungots = 0;
/* the source stream is open. set it as the current input stream */
hcl->c->curinp = &hcl->c->sci_arg;
hcl->c->curinp = &hcl->c->cci_arg;
}
return 0;
@ -2835,7 +2835,7 @@ oops:
return -1;
}
void hcl_detachscio (hcl_t* hcl)
void hcl_detachccio (hcl_t* hcl)
{
/* an error occurred and control has reached here
* probably, some included files might not have been
@ -2843,14 +2843,14 @@ void hcl_detachscio (hcl_t* hcl)
if (hcl->c)
{
if (hcl->c->sci_rdr)
if (hcl->c->cci_rdr)
{
while (hcl->c->curinp != &hcl->c->sci_arg)
while (hcl->c->curinp != &hcl->c->cci_arg)
{
hcl_io_sciarg_t* prev;
hcl_io_cciarg_t* prev;
/* nothing much to do about a close error */
hcl->c->sci_rdr (hcl, HCL_IO_CLOSE, hcl->c->curinp);
hcl->c->cci_rdr (hcl, HCL_IO_CLOSE, hcl->c->curinp);
prev = hcl->c->curinp->includer;
HCL_ASSERT (hcl, hcl->c->curinp->name != HCL_NULL);
@ -2858,8 +2858,8 @@ void hcl_detachscio (hcl_t* hcl)
hcl->c->curinp = prev;
}
hcl->c->sci_rdr (hcl, HCL_IO_CLOSE, hcl->c->curinp);
hcl->c->sci_rdr = HCL_NULL; /* ready for another attachment */
hcl->c->cci_rdr (hcl, HCL_IO_CLOSE, hcl->c->curinp);
hcl->c->cci_rdr = HCL_NULL; /* ready for another attachment */
}
}
}
@ -2943,8 +2943,8 @@ void hcl_flushudio (hcl_t* hcl)
void hcl_setbasesrloc (hcl_t* hcl, hcl_oow_t line, hcl_oow_t colm)
{
hcl->c->sci_arg.line = line;
hcl->c->sci_arg.colm = colm;
hcl->c->cci_arg.line = line;
hcl->c->cci_arg.colm = colm;
}
hcl_lxc_t* hcl_readbasesrchar (hcl_t* hcl)
@ -2952,9 +2952,9 @@ hcl_lxc_t* hcl_readbasesrchar (hcl_t* hcl)
/* read a character using the base input stream. the caller must care extra
* care when using this function. this function reads the main stream regardless
* of the inclusion status and ignores the ungot characters. */
int n = _get_char(hcl, &hcl->c->sci_arg);
int n = _get_char(hcl, &hcl->c->cci_arg);
if (n <= -1) return HCL_NULL;
return &hcl->c->sci_arg.lxc;
return &hcl->c->cci_arg.lxc;
}
hcl_ooch_t* hcl_readbasesrraw (hcl_t* hcl, hcl_oow_t* xlen)
@ -2965,7 +2965,7 @@ hcl_ooch_t* hcl_readbasesrraw (hcl_t* hcl, hcl_oow_t* xlen)
HCL_ASSERT (hcl, hcl->c != HCL_NULL); /* call hio_attachio() or hio_attachiostd() with proper arguments first */
if (hcl->c->sci_rdr(hcl, HCL_IO_READ, &hcl->c->sci_arg) <= -1) return HCL_NULL;
*xlen = hcl->c->sci_arg.xlen;
return hcl->c->sci_arg.buf;
if (hcl->c->cci_rdr(hcl, HCL_IO_READ, &hcl->c->cci_arg) <= -1) return HCL_NULL;
*xlen = hcl->c->cci_arg.xlen;
return hcl->c->cci_arg.buf;
}

View File

@ -288,7 +288,7 @@ struct xtn_t
* set these two field and reset them at the end.
* since hcl_attachio() callls the open handler, these fields
* are valid only inside the open handelr */
const char* sci_path; /* main source file */
const char* cci_path; /* main source file */
const char* udi_path; /* runtime input file */
const char* udo_path; /* runtime output file */
@ -3198,7 +3198,7 @@ static const hcl_bch_t* get_base_name (const hcl_bch_t* path)
return (last == HCL_NULL)? path: (last + 1);
}
static HCL_INLINE int open_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int open_cci_stream (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
xtn_t* xtn = GET_XTN(hcl);
bb_t* bb = HCL_NULL;
@ -3250,15 +3250,15 @@ static HCL_INLINE int open_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
/* main stream */
hcl_oow_t pathlen;
pathlen = xtn->sci_path? hcl_count_bcstr(xtn->sci_path): 0;
pathlen = xtn->cci_path? hcl_count_bcstr(xtn->cci_path): 0;
bb = (bb_t*)hcl_callocmem(hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1)));
if (!bb) goto oops;
bb->fn = (hcl_bch_t*)(bb + 1);
if (pathlen > 0 && xtn->sci_path)
if (pathlen > 0 && xtn->cci_path)
{
hcl_copy_bcstr (bb->fn, pathlen + 1, xtn->sci_path);
hcl_copy_bcstr (bb->fn, pathlen + 1, xtn->cci_path);
/*bb->fp = fopen(bb->fn, FOPEN_R_FLAGS);*/
}
else
@ -3276,7 +3276,7 @@ static HCL_INLINE int open_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
arg->name = hcl_dupbtooocstr(hcl, bb->fn, HCL_NULL);
/* ignore duplication failure */
/* TODO: change the type of arg->name from const hcl_ooch_t* to hcl_ooch_t*.
* change its specification from [IN] only to [INOUT] in hcl_io_sciarg_t. */
* change its specification from [IN] only to [INOUT] in hcl_io_cciarg_t. */
/* END HACK */
}
@ -3292,7 +3292,7 @@ oops:
return -1;
}
static HCL_INLINE int close_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int close_cci_stream (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
/*xtn_t* xtn = GET_XTN(hcl);*/
bb_t* bb;
@ -3316,7 +3316,7 @@ static HCL_INLINE int close_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
return 0;
}
static HCL_INLINE int read_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
static HCL_INLINE int read_cci_stream (hcl_t* hcl, hcl_io_cciarg_t* arg)
{
/*xtn_t* xtn = GET_XTN(hcl);*/
bb_t* bb;
@ -3367,18 +3367,18 @@ static HCL_INLINE int read_sci_stream (hcl_t* hcl, hcl_io_sciarg_t* arg)
}
/* source code input handler */
static int sci_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
static int cci_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
{
switch (cmd)
{
case HCL_IO_OPEN:
return open_sci_stream(hcl, (hcl_io_sciarg_t*)arg);
return open_cci_stream(hcl, (hcl_io_cciarg_t*)arg);
case HCL_IO_CLOSE:
return close_sci_stream(hcl, (hcl_io_sciarg_t*)arg);
return close_cci_stream(hcl, (hcl_io_cciarg_t*)arg);
case HCL_IO_READ:
return read_sci_stream(hcl, (hcl_io_sciarg_t*)arg);
return read_cci_stream(hcl, (hcl_io_cciarg_t*)arg);
case HCL_IO_FLUSH:
/* no effect on an input stream */
@ -3398,15 +3398,15 @@ static HCL_INLINE int open_in_stream (hcl_t* hcl, hcl_io_udiarg_t* arg)
hcl_oow_t pathlen;
pathlen = xtn->sci_path? hcl_count_bcstr(xtn->sci_path): 0;
pathlen = xtn->cci_path? hcl_count_bcstr(xtn->cci_path): 0;
bb = (bb_t*)hcl_callocmem(hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1)));
if (!bb) goto oops;
bb->fn = (hcl_bch_t*)(bb + 1);
if (pathlen > 0 && xtn->sci_path)
if (pathlen > 0 && xtn->cci_path)
{
hcl_copy_bcstr (bb->fn, pathlen + 1, xtn->sci_path);
hcl_copy_bcstr (bb->fn, pathlen + 1, xtn->cci_path);
bb->fp = fopen(bb->fn, FOPEN_R_FLAGS);
}
else
@ -3654,36 +3654,36 @@ static int udo_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
/* --------------------------------------------------------------------- */
int hcl_attachsciostdwithbcstr (hcl_t* hcl, const hcl_bch_t* sci_file)
int hcl_attachcciostdwithbcstr (hcl_t* hcl, const hcl_bch_t* cci_file)
{
xtn_t* xtn = GET_XTN(hcl);
int n;
HCL_ASSERT (hcl, xtn->sci_path == HCL_NULL);
xtn->sci_path = sci_file;
HCL_ASSERT (hcl, xtn->cci_path == HCL_NULL);
n = hcl_attachscio(hcl, sci_handler);
xtn->cci_path = cci_file;
xtn->sci_path = HCL_NULL;
n = hcl_attachccio(hcl, cci_handler);
xtn->cci_path = HCL_NULL;
return n;
}
int hcl_attachsciostdwithucstr (hcl_t* hcl, const hcl_uch_t* sci_file)
int hcl_attachcciostdwithucstr (hcl_t* hcl, const hcl_uch_t* cci_file)
{
xtn_t* xtn = GET_XTN(hcl);
int n;
HCL_ASSERT (hcl, xtn->sci_path == HCL_NULL);
HCL_ASSERT (hcl, xtn->cci_path == HCL_NULL);
xtn->sci_path = hcl_duputobcstr(hcl, sci_file, HCL_NULL);
if (HCL_UNLIKELY(!xtn->sci_path)) return -1;
n = hcl_attachscio(hcl, sci_handler);
xtn->cci_path = hcl_duputobcstr(hcl, cci_file, HCL_NULL);
if (HCL_UNLIKELY(!xtn->cci_path)) return -1;
hcl_freemem (hcl, (void*)xtn->sci_path);
xtn->sci_path = HCL_NULL;
n = hcl_attachccio(hcl, cci_handler);
hcl_freemem (hcl, (void*)xtn->cci_path);
xtn->cci_path = HCL_NULL;
return n;
}
@ -3723,7 +3723,7 @@ int hcl_attachudiostdwithucstr (hcl_t* hcl, const hcl_uch_t* udi_file, const hcl
xtn->udi_path = hcl_duputobcstr(hcl, udi_file, HCL_NULL);
if (HCL_UNLIKELY(!xtn->udi_path))
{
hcl_freemem (hcl, (void*)xtn->sci_path);
hcl_freemem (hcl, (void*)xtn->cci_path);
return -1;
}

View File

@ -55,9 +55,9 @@ func main() {
var err error = nil
var param Param
var rfh hcl.ReadFileHandler
var sfh hcl.ScanFileHandler
var pfh hcl.PrintFileHandler
var rfh hcl.CciFileHandler
var sfh hcl.UdiFileHandler
var pfh hcl.UdoFileHandler
err = handle_arguments(&param);
if err != nil {
@ -87,7 +87,7 @@ func main() {
goto oops
}
err = x.AttachSCIO(&rfh)
err = x.AttachCCIO(&rfh)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
goto oops