*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-06 14:52:51 +00:00
parent 2f3138467a
commit a91c7b2568
6 changed files with 86 additions and 76 deletions

View File

@ -4,7 +4,8 @@
objects = awk.obj,err.obj,tree.obj,str.obj,tab.obj,map.obj,parse.obj,run.obj,rec.obj,val.obj,func.obj,misc.obj,extio.obj,rex.obj objects = awk.obj,err.obj,tree.obj,str.obj,tab.obj,map.obj,parse.obj,run.obj,rec.obj,val.obj,func.obj,misc.obj,extio.obj,rex.obj
CFLAGS = /pointer_size=long /include="../.." CFLAGS = /include="../.."
#CFLAGS = /pointer_size=long /include="../.."
LIBRFLAGS = LIBRFLAGS =
aseawk.olb : $(objects) aseawk.olb : $(objects)

View File

@ -3,3 +3,12 @@
= ASE Quck Start Guide = = ASE Quck Start Guide =
This quick start guide is provided to .... This quick start guide is provided to ....
=== OpenVMS ===
set default [.ase.awk]
mms
set default [-.-.test.awk]
mms
awk :== $DISK$GEIN_SYS:[USERS.BACON.ASE.TEST.AWK]awk.exe
awk -f hello.awk

View File

@ -4,7 +4,8 @@
objects = awk.obj objects = awk.obj
CFLAGS = /pointer_size=long /include="../../.." CFLAGS = /include="../../.."
#CFLAGS = /pointer_size=long /include="../../.."
awk.exe : $(objects) awk.exe : $(objects)
link $(objects),[-.-.awk]aseawk/library link $(objects),[-.-.awk]aseawk/library

View File

@ -1,6 +0,0 @@
$ write sys$output "cc/define=__STAND_ALONE awk.c"
$ cc/define=__STAND_ALONE awk.c
$
$ write sys$output "link awk.obj,[-.-.awk]xpawk/library"
$ link awk.obj,[-.-.awk]xpawk/library

View File

@ -1,6 +1,6 @@
#include <ase/lsp/lsp.h> #include <ase/lsp/lsp.h>
#include "../etc/printf.h" #include "../../etc/printf.c"
#include "../etc/main.h" #include "../../etc/main.c"
#ifdef _WIN32 #ifdef _WIN32
#include <tchar.h> #include <tchar.h>
@ -19,10 +19,9 @@
#include <mcheck.h> #include <mcheck.h>
#endif #endif
static ase_ssize_t get_input (int cmd, void* arg, ase_char_t* data, ase_size_t size)
static xp_ssize_t get_input (int cmd, void* arg, xp_char_t* data, xp_size_t size)
{ {
xp_ssize_t n; ase_ssize_t n;
switch (cmd) switch (cmd)
{ {
@ -31,17 +30,19 @@ static xp_ssize_t get_input (int cmd, void* arg, xp_char_t* data, xp_size_t size
return 0; return 0;
case ASE_LSP_IO_READ: case ASE_LSP_IO_READ:
{
if (size < 0) return -1; if (size < 0) return -1;
n = xp_sio_getc (xp_sio_in, data); n = xp_sio_getc (xp_sio_in, data);
if (n == 0) return 0; if (n == 0) return 0;
if (n != 1) return -1; if (n != 1) return -1;
return n; return n;
} }
}
return -1; return -1;
} }
static xp_ssize_t put_output (int cmd, void* arg, xp_char_t* data, xp_size_t size) static ase_ssize_t put_output (int cmd, void* arg, ase_char_t* data, ase_size_t size)
{ {
switch (cmd) switch (cmd)
@ -58,14 +59,14 @@ static xp_ssize_t put_output (int cmd, void* arg, xp_char_t* data, xp_size_t siz
} }
int to_int (const xp_char_t* str) int to_int (const ase_char_t* str)
{ {
int r = 0; int r = 0;
while (*str != XP_CHAR('\0')) while (*str != ASE_T('\0'))
{ {
if (!xp_isdigit(*str)) break; if (!xp_isdigit(*str)) break;
r = r * 10 + (*str - XP_CHAR('0')); r = r * 10 + (*str - ASE_T('0'));
str++; str++;
} }
@ -76,55 +77,55 @@ int to_int (const xp_char_t* str)
int handle_cli_error ( int handle_cli_error (
const xp_cli_t* cli, int code, const xp_cli_t* cli, int code,
const xp_char_t* name, const xp_char_t* value) const ase_char_t* name, const ase_char_t* value)
{ {
xp_printf (XP_T("usage: %s /memory=nnn /increment=nnn\n"), cli->verb); xp_printf (ASE_T("usage: %s /memory=nnn /increment=nnn\n"), cli->verb);
if (code == XP_CLI_ERROR_INVALID_OPTNAME) { if (code == ASE_CLI_ERROR_INVALID_OPTNAME) {
xp_printf (XP_T("unknown option - %s\n"), name); xp_printf (ASE_T("unknown option - %s\n"), name);
} }
else if (code == XP_CLI_ERROR_MISSING_OPTNAME) { else if (code == ASE_CLI_ERROR_MISSING_OPTNAME) {
xp_printf (XP_T("missing option - %s\n"), name); xp_printf (ASE_T("missing option - %s\n"), name);
} }
else if (code == XP_CLI_ERROR_REDUNDANT_OPTVAL) { else if (code == ASE_CLI_ERROR_REDUNDANT_OPTVAL) {
xp_printf (XP_T("redundant value %s for %s\n"), value, name); xp_printf (ASE_T("redundant value %s for %s\n"), value, name);
} }
else if (code == XP_CLI_ERROR_MISSING_OPTVAL) { else if (code == ASE_CLI_ERROR_MISSING_OPTVAL) {
xp_printf (XP_T("missing value for %s\n"), name); xp_printf (ASE_T("missing value for %s\n"), name);
} }
else if (code == XP_CLI_ERROR_MEMORY) { else if (code == ASE_CLI_ERROR_MEMORY) {
xp_printf (XP_T("memory error in processing %s\n"), name); xp_printf (ASE_T("memory error in processing %s\n"), name);
} }
else { else {
xp_printf (XP_T("error code: %d\n"), code); xp_printf (ASE_T("error code: %d\n"), code);
} }
return -1; return -1;
} }
xp_cli_t* parse_cli (int argc, xp_char_t* argv[]) xp_cli_t* parse_cli (int argc, ase_char_t* argv[])
{ {
static const xp_char_t* optsta[] = static const ase_char_t* optsta[] =
{ {
XP_T("/"), XP_T("--"), XP_NULL ASE_T("/"), ASE_T("--"), ASE_NULL
}; };
static xp_cliopt_t opts[] = static xp_cliopt_t opts[] =
{ {
{ XP_T("memory"), XP_CLI_OPTNAME | XP_CLI_OPTVAL }, { ASE_T("memory"), ASE_CLI_OPTNAME | ASE_CLI_OPTVAL },
{ XP_T("increment"), XP_CLI_OPTNAME | XP_CLI_OPTVAL }, { ASE_T("increment"), ASE_CLI_OPTNAME | ASE_CLI_OPTVAL },
{ XP_NULL, 0 } { ASE_NULL, 0 }
}; };
static xp_cli_t cli = static xp_cli_t cli =
{ {
handle_cli_error, handle_cli_error,
optsta, optsta,
XP_T("="), ASE_T("="),
opts opts
}; };
if (xp_parsecli (argc, argv, &cli) == -1) return XP_NULL; if (xp_parsecli (argc, argv, &cli) == -1) return ASE_NULL;
return &cli; return &cli;
} }
@ -136,7 +137,7 @@ struct syscas_data_t
}; };
#endif #endif
static void* __lsp_malloc (xp_size_t n, void* custom_data) static void* __lsp_malloc (ase_size_t n, void* custom_data)
{ {
#ifdef _WIN32 #ifdef _WIN32
return HeapAlloc (((syscas_data_t*)custom_data)->heap, 0, n); return HeapAlloc (((syscas_data_t*)custom_data)->heap, 0, n);
@ -145,7 +146,7 @@ static void* __lsp_malloc (xp_size_t n, void* custom_data)
#endif #endif
} }
static void* __lsp_realloc (void* ptr, xp_size_t n, void* custom_data) static void* __lsp_realloc (void* ptr, ase_size_t n, void* custom_data)
{ {
#ifdef _WIN32 #ifdef _WIN32
/* HeapReAlloc behaves differently from realloc */ /* HeapReAlloc behaves differently from realloc */
@ -226,7 +227,7 @@ static void lsp_printf (const ase_char_t* fmt, ...)
va_end (ap); va_end (ap);
} }
int __main (int argc, xp_char_t* argv[]) int __main (int argc, ase_char_t* argv[])
{ {
ase_lsp_t* lsp; ase_lsp_t* lsp;
ase_lsp_obj_t* obj; ase_lsp_obj_t* obj;
@ -241,20 +242,20 @@ int __main (int argc, xp_char_t* argv[])
/* /*
if (xp_setlocale () == -1) { if (xp_setlocale () == -1) {
xp_fprintf (xp_stderr, xp_fprintf (xp_stderr,
XP_T("error: cannot set locale\n")); ASE_T("error: cannot set locale\n"));
return -1; return -1;
} }
*/ */
if ((cli = parse_cli (argc, argv)) == XP_NULL) return -1; if ((cli = parse_cli (argc, argv)) == ASE_NULL) return -1;
mem = to_int(xp_getclioptval(cli, XP_T("memory"))); mem = to_int(xp_getclioptval(cli, ASE_T("memory")));
inc = to_int(xp_getclioptval(cli, XP_T("increment"))); inc = to_int(xp_getclioptval(cli, ASE_T("increment")));
xp_clearcli (cli); xp_clearcli (cli);
if (mem <= 0) if (mem <= 0)
{ {
xp_fprintf (xp_stderr, xp_fprintf (xp_stderr,
XP_T("error: invalid memory size given\n")); ASE_T("error: invalid memory size given\n"));
return -1; return -1;
} }
@ -264,7 +265,7 @@ int __main (int argc, xp_char_t* argv[])
syscas.realloc = __lsp_realloc; syscas.realloc = __lsp_realloc;
syscas.free = __lsp_free; syscas.free = __lsp_free;
#ifdef ASE_CHAR_IS_MCHAR #ifdef ASE_T_IS_MCHAR
syscas.is_upper = isupper; syscas.is_upper = isupper;
syscas.is_lower = islower; syscas.is_lower = islower;
syscas.is_alpha = isalpha; syscas.is_alpha = isalpha;
@ -314,62 +315,62 @@ int __main (int argc, xp_char_t* argv[])
lsp = ase_lsp_open (&syscas, mem, inc); lsp = ase_lsp_open (&syscas, mem, inc);
if (lsp == XP_NULL) if (lsp == ASE_NULL)
{ {
#ifdef _WIN32 #ifdef _WIN32
HeapDestroy (syscas_data.heap); HeapDestroy (syscas_data.heap);
#endif #endif
xp_fprintf (xp_stderr, xp_fprintf (xp_stderr,
XP_T("error: cannot create a lsp instance\n")); ASE_T("error: cannot create a lsp instance\n"));
return -1; return -1;
} }
xp_printf (XP_T("LSP 0.0001\n")); xp_printf (ASE_T("LSP 0.0001\n"));
ase_lsp_attach_input (lsp, get_input, XP_NULL); ase_lsp_attach_input (lsp, get_input, ASE_NULL);
ase_lsp_attach_output (lsp, put_output, XP_NULL); ase_lsp_attach_output (lsp, put_output, ASE_NULL);
while (1) while (1)
{ {
xp_sio_puts (xp_sio_out, XP_T("[")); xp_sio_puts (xp_sio_out, ASE_T("["));
xp_sio_puts (xp_sio_out, argv[0]); xp_sio_puts (xp_sio_out, argv[0]);
xp_sio_puts (xp_sio_out, XP_T("]")); xp_sio_puts (xp_sio_out, ASE_T("]"));
xp_sio_flush (xp_sio_out); xp_sio_flush (xp_sio_out);
obj = ase_lsp_read (lsp); obj = ase_lsp_read (lsp);
if (obj == XP_NULL) if (obj == ASE_NULL)
{ {
int errnum = ase_lsp_geterrnum(lsp); int errnum = ase_lsp_geterrnum(lsp);
const xp_char_t* errstr; const ase_char_t* errstr;
if (errnum != ASE_LSP_ERR_END && if (errnum != ASE_LSP_ERR_END &&
errnum != ASE_LSP_ERR_EXIT) errnum != ASE_LSP_ERR_EXIT)
{ {
errstr = ase_lsp_geterrstr(errnum); errstr = ase_lsp_geterrstr(errnum);
xp_fprintf (xp_stderr, xp_fprintf (xp_stderr,
XP_T("error in read: [%d] %s\n"), errnum, errstr); ASE_T("error in read: [%d] %s\n"), errnum, errstr);
} }
if (errnum < ASE_LSP_ERR_SYNTAX) break; if (errnum < ASE_LSP_ERR_SYNTAX) break;
continue; continue;
} }
if ((obj = ase_lsp_eval (lsp, obj)) != XP_NULL) if ((obj = ase_lsp_eval (lsp, obj)) != ASE_NULL)
{ {
ase_lsp_print (lsp, obj); ase_lsp_print (lsp, obj);
xp_sio_puts (xp_sio_out, XP_T("\n")); xp_sio_puts (xp_sio_out, ASE_T("\n"));
} }
else else
{ {
int errnum; int errnum;
const xp_char_t* errstr; const ase_char_t* errstr;
errnum = ase_lsp_geterrnum(lsp); errnum = ase_lsp_geterrnum(lsp);
if (errnum == ASE_LSP_ERR_EXIT) break; if (errnum == ASE_LSP_ERR_EXIT) break;
errstr = ase_lsp_geterrstr(errnum); errstr = ase_lsp_geterrstr(errnum);
xp_fprintf (xp_stderr, xp_fprintf (xp_stderr,
XP_T("error in eval: [%d] %s\n"), errnum, errstr); ASE_T("error in eval: [%d] %s\n"), errnum, errstr);
} }
} }
@ -381,7 +382,7 @@ int __main (int argc, xp_char_t* argv[])
return 0; return 0;
} }
int xp_main (int argc, xp_char_t* argv[]) int xp_main (int argc, ase_char_t* argv[])
{ {
int n; int n;

4
ase/test/lsp/t7.lsp Normal file
View File

@ -0,0 +1,4 @@
(setq a '(1 2 3))
(cons a (cons a 10))
(setq xx (cons a (cons a 10)))