2015-05-08 14:29:35 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
Copyright (c) 2014-2015 Chung, Hyung-Hwan. All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
#include "stix-prv.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-05-17 05:02:30 +00:00
|
|
|
#include <string.h>
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-06-04 18:34:37 +00:00
|
|
|
#include <limits.h>
|
2015-05-15 14:55:12 +00:00
|
|
|
typedef struct xtn_t xtn_t;
|
|
|
|
struct xtn_t
|
|
|
|
{
|
2015-05-16 07:31:16 +00:00
|
|
|
const char* source_path;
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-05-16 07:31:16 +00:00
|
|
|
char bchar_buf[1024];
|
|
|
|
stix_size_t bchar_pos;
|
|
|
|
stix_size_t bchar_len;
|
|
|
|
};
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
static void* sys_alloc (stix_mmgr_t* mmgr, stix_size_t size)
|
|
|
|
{
|
|
|
|
return malloc (size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* sys_realloc (stix_mmgr_t* mmgr, void* ptr, stix_size_t size)
|
|
|
|
{
|
|
|
|
return realloc (ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sys_free (stix_mmgr_t* mmgr, void* ptr)
|
|
|
|
{
|
|
|
|
free (ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static stix_mmgr_t sys_mmgr =
|
|
|
|
{
|
|
|
|
sys_alloc,
|
|
|
|
sys_realloc,
|
|
|
|
sys_free,
|
|
|
|
STIX_NULL
|
|
|
|
};
|
|
|
|
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-05-17 05:02:30 +00:00
|
|
|
static STIX_INLINE stix_ssize_t open_input (stix_t* stix, stix_ioarg_t* arg)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
|
|
|
if (arg->includer)
|
|
|
|
{
|
|
|
|
/* includee */
|
2015-05-17 05:02:30 +00:00
|
|
|
stix_bch_t bcs[1024]; /* TODO: right buffer size */
|
|
|
|
stix_size_t bcslen = STIX_COUNTOF(bcs);
|
|
|
|
stix_size_t ucslen = ~(stix_size_t)0;
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-05-17 05:02:30 +00:00
|
|
|
if (stix_ucstoutf8 (arg->name, &ucslen, bcs, &bcslen) <= -1)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2015-05-17 05:02:30 +00:00
|
|
|
stix_seterrnum (stix, STIX_EECERR);
|
2015-05-15 14:55:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-05-20 14:27:47 +00:00
|
|
|
|
2015-07-03 14:38:37 +00:00
|
|
|
/* TODO: make bcs relative to the includer */
|
|
|
|
|
2015-06-11 13:10:33 +00:00
|
|
|
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
|
|
|
|
arg->handle = fopen (bcs, "rb");
|
|
|
|
#else
|
2015-05-20 14:27:47 +00:00
|
|
|
arg->handle = fopen (bcs, "r");
|
2015-06-11 13:10:33 +00:00
|
|
|
#endif
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* main stream */
|
2015-05-17 05:02:30 +00:00
|
|
|
xtn_t* xtn = stix_getxtn(stix);
|
2015-06-11 13:10:33 +00:00
|
|
|
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
|
|
|
|
arg->handle = fopen (xtn->source_path, "rb");
|
|
|
|
#else
|
2015-05-17 05:02:30 +00:00
|
|
|
arg->handle = fopen (xtn->source_path, "r");
|
2015-06-11 13:10:33 +00:00
|
|
|
#endif
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
2015-05-17 05:02:30 +00:00
|
|
|
|
|
|
|
if (!arg->handle)
|
|
|
|
{
|
|
|
|
stix_seterrnum (stix, STIX_EIOERR);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 05:02:30 +00:00
|
|
|
static STIX_INLINE stix_ssize_t read_input (stix_t* stix, stix_ioarg_t* arg)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2015-05-16 07:31:16 +00:00
|
|
|
xtn_t* xtn = stix_getxtn(stix);
|
2015-05-17 05:02:30 +00:00
|
|
|
stix_size_t n, bcslen, ucslen, remlen;
|
2015-05-16 07:31:16 +00:00
|
|
|
int x;
|
|
|
|
|
2015-05-15 14:55:12 +00:00
|
|
|
STIX_ASSERT (arg->handle != STIX_NULL);
|
2015-05-16 07:31:16 +00:00
|
|
|
n = fread (&xtn->bchar_buf[xtn->bchar_len], STIX_SIZEOF(xtn->bchar_buf[0]), STIX_COUNTOF(xtn->bchar_buf) - xtn->bchar_len, arg->handle);
|
|
|
|
if (n == 0)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2015-05-19 16:26:52 +00:00
|
|
|
if (ferror((FILE*)arg->handle))
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2015-05-16 07:31:16 +00:00
|
|
|
stix_seterrnum (stix, STIX_EIOERR);
|
|
|
|
return -1;
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-16 07:31:16 +00:00
|
|
|
xtn->bchar_len += n;
|
|
|
|
bcslen = xtn->bchar_len;
|
2015-05-17 05:02:30 +00:00
|
|
|
ucslen = STIX_COUNTOF(arg->buf);
|
|
|
|
x = stix_utf8toucs (xtn->bchar_buf, &bcslen, arg->buf, &ucslen);
|
|
|
|
if (x <= -1 && ucslen <= 0)
|
2015-05-16 07:31:16 +00:00
|
|
|
{
|
2015-05-17 05:02:30 +00:00
|
|
|
stix_seterrnum (stix, STIX_EECERR);
|
|
|
|
return -1;
|
2015-05-16 07:31:16 +00:00
|
|
|
}
|
2015-05-17 05:02:30 +00:00
|
|
|
|
|
|
|
remlen = xtn->bchar_len - bcslen;
|
|
|
|
if (remlen > 0) memmove (xtn->bchar_buf, &xtn->bchar_buf[bcslen], remlen);
|
|
|
|
xtn->bchar_len = remlen;
|
|
|
|
return ucslen;
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
2015-05-17 05:02:30 +00:00
|
|
|
static STIX_INLINE stix_ssize_t close_input (stix_t* stix, stix_ioarg_t* arg)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
|
|
|
STIX_ASSERT (arg->handle != STIX_NULL);
|
2015-05-19 16:26:52 +00:00
|
|
|
fclose ((FILE*)arg->handle);
|
2015-05-15 14:55:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-17 05:02:30 +00:00
|
|
|
static stix_ssize_t input_handler (stix_t* stix, stix_iocmd_t cmd, stix_ioarg_t* arg)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
case STIX_IO_OPEN:
|
|
|
|
return open_input (stix, arg);
|
|
|
|
|
|
|
|
case STIX_IO_CLOSE:
|
|
|
|
return close_input (stix, arg);
|
|
|
|
|
|
|
|
case STIX_IO_READ:
|
|
|
|
return read_input (stix, arg);
|
|
|
|
|
|
|
|
default:
|
|
|
|
stix->errnum = STIX_EINTERN;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 15:16:18 +00:00
|
|
|
static char* syntax_error_msg[] =
|
|
|
|
{
|
|
|
|
"no error",
|
|
|
|
"illegal character",
|
|
|
|
"comment not closed",
|
|
|
|
"string not closed",
|
|
|
|
"no character after $",
|
2015-05-19 16:26:52 +00:00
|
|
|
"no valid character after #",
|
2015-06-24 11:53:19 +00:00
|
|
|
"wrong character literal",
|
|
|
|
"colon expected",
|
2015-06-16 13:29:29 +00:00
|
|
|
"string expected",
|
|
|
|
"invalid radix",
|
|
|
|
"invalid numeric literal",
|
2015-06-23 14:00:26 +00:00
|
|
|
"byte too small or too large",
|
2015-05-20 15:52:45 +00:00
|
|
|
"{ expected",
|
|
|
|
"} expected",
|
2015-05-25 17:10:49 +00:00
|
|
|
"( expected",
|
2015-05-20 15:52:45 +00:00
|
|
|
") expected",
|
2015-06-03 17:24:11 +00:00
|
|
|
"] expected",
|
2015-05-20 15:52:45 +00:00
|
|
|
". expected",
|
2015-05-22 15:09:45 +00:00
|
|
|
"| expected",
|
|
|
|
"> expected",
|
2015-07-14 13:35:18 +00:00
|
|
|
":= expected",
|
2015-05-22 15:09:45 +00:00
|
|
|
"identifier expected",
|
|
|
|
"integer expected",
|
|
|
|
"primitive: expected",
|
2015-05-25 18:13:52 +00:00
|
|
|
"wrong directive",
|
2015-05-25 17:10:49 +00:00
|
|
|
"undefined class",
|
|
|
|
"duplicate class",
|
2015-05-28 15:20:27 +00:00
|
|
|
"contradictory class definition",
|
2015-05-25 17:10:49 +00:00
|
|
|
"#dcl not allowed",
|
2015-05-27 17:41:11 +00:00
|
|
|
"wrong method name",
|
|
|
|
"duplicate method name",
|
2015-05-25 17:10:49 +00:00
|
|
|
"duplicate argument name",
|
|
|
|
"duplicate temporary variable name",
|
2015-06-01 15:59:16 +00:00
|
|
|
"duplicate variable name",
|
2015-06-16 13:29:29 +00:00
|
|
|
"duplicate block argument name",
|
2015-06-01 15:59:16 +00:00
|
|
|
"cannot assign to argument",
|
2015-06-03 04:22:19 +00:00
|
|
|
"undeclared variable",
|
|
|
|
"unusable variable in compiled code",
|
|
|
|
"inaccessible variable",
|
|
|
|
"wrong expression primary",
|
2015-06-20 03:07:11 +00:00
|
|
|
"too many temporaries",
|
2015-06-03 17:24:11 +00:00
|
|
|
"too many arguments",
|
2015-06-20 03:07:11 +00:00
|
|
|
"too many block temporaries",
|
2015-06-16 13:29:29 +00:00
|
|
|
"too many block arguments",
|
|
|
|
"too large block",
|
2015-07-03 14:38:37 +00:00
|
|
|
"wrong primitive number",
|
2015-07-12 17:14:21 +00:00
|
|
|
"#include error",
|
2015-07-14 13:35:18 +00:00
|
|
|
"wrong namespace name",
|
2015-07-25 15:01:51 +00:00
|
|
|
"wrong pool dictionary name",
|
2015-07-14 13:35:18 +00:00
|
|
|
"duplicate pool dictionary name",
|
|
|
|
"literal expected"
|
2015-05-19 15:16:18 +00:00
|
|
|
};
|
|
|
|
|
2015-06-06 07:24:35 +00:00
|
|
|
stix_uch_t str_stix[] = { 'S', 't', 'i', 'x' };
|
2015-06-11 09:11:18 +00:00
|
|
|
stix_uch_t str_my_object[] = { 'M', 'y', 'O', 'b','j','e','c','t' };
|
2015-06-06 07:24:35 +00:00
|
|
|
stix_uch_t str_main[] = { 'm', 'a', 'i', 'n' };
|
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
stix_t* stix;
|
2015-05-16 07:31:16 +00:00
|
|
|
xtn_t* xtn;
|
2015-06-06 07:24:35 +00:00
|
|
|
stix_ucs_t objname;
|
|
|
|
stix_ucs_t mthname;
|
2015-06-11 12:09:10 +00:00
|
|
|
int i;
|
2015-05-16 07:31:16 +00:00
|
|
|
|
2015-05-26 16:31:47 +00:00
|
|
|
printf ("Stix 1.0.0 - max named %lu max indexed %lu max class %lu max classinst %lu\n",
|
|
|
|
(unsigned long int)STIX_MAX_NAMED_INSTVARS,
|
|
|
|
(unsigned long int)STIX_MAX_INDEXED_INSTVARS(STIX_MAX_NAMED_INSTVARS),
|
|
|
|
(unsigned long int)STIX_MAX_CLASSVARS,
|
|
|
|
(unsigned long int)STIX_MAX_CLASSINSTVARS);
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-06-04 18:34:37 +00:00
|
|
|
{
|
|
|
|
stix_oop_t k;
|
|
|
|
k = STIX_OOP_FROM_SMINT(-1);
|
|
|
|
printf ("%ld %ld %ld %lX\n", (long int)STIX_OOP_TO_SMINT(k), (long int)STIX_SMINT_MIN, (long int)STIX_SMINT_MAX, (long)LONG_MIN);
|
|
|
|
|
|
|
|
k = STIX_OOP_FROM_SMINT(STIX_SMINT_MAX);
|
|
|
|
printf ("%ld\n", (long int)STIX_OOP_TO_SMINT(k));
|
|
|
|
|
|
|
|
k = STIX_OOP_FROM_SMINT(STIX_SMINT_MIN);
|
|
|
|
printf ("%ld\n", (long int)STIX_OOP_TO_SMINT(k));
|
|
|
|
}
|
2015-05-07 15:58:04 +00:00
|
|
|
|
2015-05-28 16:51:37 +00:00
|
|
|
#if !defined(macintosh)
|
2015-06-11 12:09:10 +00:00
|
|
|
if (argc < 2)
|
2015-05-16 07:31:16 +00:00
|
|
|
{
|
2015-06-11 12:09:10 +00:00
|
|
|
fprintf (stderr, "Usage: %s filename ...\n", argv[0]);
|
2015-05-16 07:31:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-05-28 16:51:37 +00:00
|
|
|
#endif
|
2015-05-16 07:31:16 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
{
|
|
|
|
stix_oow_t x;
|
|
|
|
|
|
|
|
printf ("%u\n", STIX_BITS_MAX(unsigned int, 5));
|
|
|
|
|
|
|
|
x = STIX_CLASS_SPEC_MAKE (10, 1, STIX_OBJ_TYPE_CHAR);
|
|
|
|
printf ("%lu %lu %lu %lu\n", (unsigned long int)x, (unsigned long int)STIX_OOP_FROM_SMINT(x),
|
|
|
|
(unsigned long int)STIX_CLASS_SPEC_NAMED_INSTVAR(x),
|
|
|
|
(unsigned long int)STIX_CLASS_SPEC_INDEXED_TYPE(x));
|
|
|
|
}
|
|
|
|
|
2015-05-15 14:55:12 +00:00
|
|
|
stix = stix_open (&sys_mmgr, STIX_SIZEOF(xtn_t), 512000lu, STIX_NULL);
|
2015-05-07 15:58:04 +00:00
|
|
|
if (!stix)
|
|
|
|
{
|
|
|
|
printf ("cannot open stix\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-05-28 16:51:37 +00:00
|
|
|
stix_oow_t tab_size;
|
|
|
|
|
|
|
|
tab_size = 5000;
|
|
|
|
stix_setoption (stix, STIX_DFL_SYMTAB_SIZE, &tab_size);
|
|
|
|
tab_size = 5000;
|
|
|
|
stix_setoption (stix, STIX_DFL_SYSDIC_SIZE, &tab_size);
|
2015-05-07 15:58:04 +00:00
|
|
|
}
|
|
|
|
|
2015-06-28 14:20:37 +00:00
|
|
|
{
|
|
|
|
int trait = 0;
|
|
|
|
|
2015-06-29 13:52:40 +00:00
|
|
|
/*trait |= STIX_NOGC;*/
|
2015-06-28 14:20:37 +00:00
|
|
|
stix_setoption (stix, STIX_TRAIT, &trait);
|
|
|
|
}
|
|
|
|
|
2015-05-26 16:31:47 +00:00
|
|
|
if (stix_ignite(stix) <= -1)
|
2015-05-07 15:58:04 +00:00
|
|
|
{
|
2015-05-26 16:31:47 +00:00
|
|
|
printf ("cannot ignite stix - %d\n", stix_geterrnum(stix));
|
2015-05-07 15:58:04 +00:00
|
|
|
stix_close (stix);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-05-31 18:43:37 +00:00
|
|
|
stix_uch_t x[] = { 'X', 't', 'r', 'i', 'n', 'g', '\0' };
|
2015-05-17 05:02:30 +00:00
|
|
|
stix_uch_t y[] = { 'S', 'y', 'm', 'b', 'o', 'l', '\0' };
|
2015-05-31 18:43:37 +00:00
|
|
|
stix_oop_t a, b, k;
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
a = stix_makesymbol (stix, x, 6);
|
|
|
|
b = stix_makesymbol (stix, y, 6);
|
|
|
|
|
|
|
|
printf ("%p %p\n", a, b);
|
2015-05-08 14:29:35 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
dump_symbol_table (stix);
|
2015-05-08 14:29:35 +00:00
|
|
|
|
2015-05-31 18:43:37 +00:00
|
|
|
/*
|
|
|
|
stix_pushtmp (stix, &a);
|
|
|
|
stix_pushtmp (stix, &b);
|
|
|
|
k = stix_instantiate (stix, stix->_byte_array, STIX_NULL, 100);
|
|
|
|
stix_poptmps (stix, 2);
|
|
|
|
stix_putatsysdic (stix, a, k);
|
|
|
|
*/
|
2015-05-08 14:29:35 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
stix_gc (stix);
|
2015-05-08 14:29:35 +00:00
|
|
|
a = stix_findsymbol (stix, x, 6);
|
|
|
|
printf ("%p\n", a);
|
2015-05-07 15:58:04 +00:00
|
|
|
dump_symbol_table (stix);
|
2015-05-26 16:31:47 +00:00
|
|
|
|
|
|
|
|
2015-06-06 07:24:35 +00:00
|
|
|
dump_dictionary (stix, stix->sysdic, "System dictionary");
|
2015-05-08 14:29:35 +00:00
|
|
|
}
|
2015-05-15 14:55:12 +00:00
|
|
|
|
2015-05-16 07:31:16 +00:00
|
|
|
xtn = stix_getxtn (stix);
|
2015-06-11 12:09:10 +00:00
|
|
|
|
|
|
|
#if defined(macintosh)
|
|
|
|
i = 20;
|
2015-05-28 16:51:37 +00:00
|
|
|
xtn->source_path = "test.st";
|
2015-06-11 12:09:10 +00:00
|
|
|
goto compile;
|
2015-05-28 16:51:37 +00:00
|
|
|
#endif
|
2015-06-11 12:09:10 +00:00
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2015-06-11 12:09:10 +00:00
|
|
|
xtn->source_path = argv[i];
|
2015-05-20 15:52:45 +00:00
|
|
|
|
2015-06-11 12:09:10 +00:00
|
|
|
compile:
|
2015-05-20 15:52:45 +00:00
|
|
|
|
2015-06-11 12:09:10 +00:00
|
|
|
if (stix_compile (stix, input_handler) <= -1)
|
|
|
|
{
|
|
|
|
if (stix->errnum == STIX_ESYNTAX)
|
2015-05-20 15:52:45 +00:00
|
|
|
{
|
2015-06-11 12:09:10 +00:00
|
|
|
stix_synerr_t synerr;
|
|
|
|
stix_bch_t bcs[1024]; /* TODO: right buffer size */
|
|
|
|
stix_size_t bcslen, ucslen;
|
|
|
|
|
|
|
|
stix_getsynerr (stix, &synerr);
|
|
|
|
|
|
|
|
printf ("ERROR: ");
|
|
|
|
if (synerr.loc.file)
|
2015-05-20 15:52:45 +00:00
|
|
|
{
|
2015-06-11 12:09:10 +00:00
|
|
|
bcslen = STIX_COUNTOF(bcs);
|
|
|
|
ucslen = ~(stix_size_t)0;
|
|
|
|
if (stix_ucstoutf8 (synerr.loc.file, &ucslen, bcs, &bcslen) >= 0)
|
|
|
|
{
|
|
|
|
printf ("%.*s ", (int)bcslen, bcs);
|
|
|
|
}
|
2015-05-20 15:52:45 +00:00
|
|
|
}
|
2015-06-12 13:52:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("%s ", xtn->source_path);
|
|
|
|
}
|
2015-05-20 15:52:45 +00:00
|
|
|
|
|
|
|
|
2015-06-11 12:09:10 +00:00
|
|
|
printf ("syntax error at line %lu column %lu - %s",
|
|
|
|
(unsigned long int)synerr.loc.line, (unsigned long int)synerr.loc.colm,
|
|
|
|
syntax_error_msg[synerr.num]);
|
|
|
|
if (synerr.tgt.len > 0)
|
2015-05-19 15:16:18 +00:00
|
|
|
{
|
2015-06-11 12:09:10 +00:00
|
|
|
bcslen = STIX_COUNTOF(bcs);
|
|
|
|
ucslen = synerr.tgt.len;
|
|
|
|
|
|
|
|
if (stix_ucstoutf8 (synerr.tgt.ptr, &ucslen, bcs, &bcslen) >= 0)
|
|
|
|
{
|
|
|
|
printf (" [%.*s]", (int)bcslen, bcs);
|
|
|
|
}
|
2015-05-19 15:16:18 +00:00
|
|
|
|
2015-06-11 12:09:10 +00:00
|
|
|
}
|
|
|
|
printf ("\n");
|
2015-05-19 15:16:18 +00:00
|
|
|
}
|
2015-06-11 12:09:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("ERROR: cannot compile code - %d\n", stix_geterrnum(stix));
|
|
|
|
}
|
|
|
|
stix_close (stix);
|
|
|
|
return -1;
|
2015-05-19 15:16:18 +00:00
|
|
|
}
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
2015-06-11 09:11:18 +00:00
|
|
|
/* objname.ptr = str_stix;
|
|
|
|
objname.len = 4;*/
|
|
|
|
objname.ptr = str_my_object;
|
|
|
|
objname.len = 8;
|
2015-06-06 07:24:35 +00:00
|
|
|
mthname.ptr = str_main;
|
|
|
|
mthname.len = 4;
|
|
|
|
if (stix_invoke (stix, &objname, &mthname) <= -1)
|
2015-06-04 18:34:37 +00:00
|
|
|
{
|
|
|
|
printf ("ERROR: cannot execute code - %d\n", stix_geterrnum(stix));
|
|
|
|
stix_close (stix);
|
|
|
|
return -1;
|
|
|
|
}
|
2015-06-06 07:24:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
dump_dictionary (stix, stix->sysdic, "System dictionary");
|
2015-05-07 15:58:04 +00:00
|
|
|
stix_close (stix);
|
|
|
|
|
2015-06-04 18:34:37 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|