added QSE_XLI_JSON and abandoned QSE_XLI_TAGMARKER, QSE_XLI_ARRAYMARKER, and QSE_XLI_ASSIGNWITHCOLON

This commit is contained in:
hyung-hwan 2018-01-08 08:25:49 +00:00
parent 03cb7dd9dc
commit 6237b43441
12 changed files with 284 additions and 125 deletions

View File

@ -168,7 +168,7 @@ static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[])
qse_fprintf (out, QSE_T(" -l disallow lists\n")); qse_fprintf (out, QSE_T(" -l disallow lists\n"));
qse_fprintf (out, QSE_T(" -K allow key tags\n")); qse_fprintf (out, QSE_T(" -K allow key tags\n"));
qse_fprintf (out, QSE_T(" -S allow string tags\n")); qse_fprintf (out, QSE_T(" -S allow string tags\n"));
qse_fprintf (out, QSE_T(" -c use a colon for assignment\n")); qse_fprintf (out, QSE_T(" -j input and output in json format\n"));
qse_fprintf (out, QSE_T(" -v perform validation\n")); qse_fprintf (out, QSE_T(" -v perform validation\n"));
qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n")); qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n"));
#if defined(QSE_BUILD_DEBUG) #if defined(QSE_BUILD_DEBUG)
@ -196,9 +196,9 @@ static int handle_args (int argc, qse_char_t* argv[])
static qse_opt_t opt = static qse_opt_t opt =
{ {
#if defined(QSE_BUILD_DEBUG) #if defined(QSE_BUILD_DEBUG)
QSE_T("hi:o:I:O:uaftsdnlKScvm:X:"), QSE_T("hi:o:I:O:uaftsdnlKSjvm:X:"),
#else #else
QSE_T("hi:o:I:O:uaftsdnlKScvm:"), QSE_T("hi:o:I:O:uaftsdnlKSjvm:"),
#endif #endif
lng lng
}; };
@ -292,8 +292,8 @@ static int handle_args (int argc, qse_char_t* argv[])
g_trait |= QSE_XLI_STRTAG; g_trait |= QSE_XLI_STRTAG;
break; break;
case QSE_T('c'): case QSE_T('j'):
g_trait |= QSE_XLI_ASSIGNWITHCOLON; g_trait |= QSE_XLI_JSON;
break; break;
case QSE_T('v'): case QSE_T('v'):

View File

@ -162,6 +162,9 @@ public:
/** data type that can hold any character */ /** data type that can hold any character */
typedef qse_char_t char_t; typedef qse_char_t char_t;
/** data type that can hold an unsigned char_t value */
typedef qse_chau_t chau_t;
/** data type that can hold any character or an end-of-file value */ /** data type that can hold any character or an end-of-file value */
typedef qse_cint_t cint_t; typedef qse_cint_t cint_t;

View File

@ -513,6 +513,11 @@ typedef qse_ssize_t qse_ptrdiff_t;
typedef char qse_mchar_t; typedef char qse_mchar_t;
#define QSE_SIZEOF_MCHAR_T QSE_SIZEOF_CHAR #define QSE_SIZEOF_MCHAR_T QSE_SIZEOF_CHAR
/** \typedef qse_mchau_t
* The qse_mchau_t type defines a type that can hold the unsigned qse_mchar_t value.
*/
typedef unsigned char qse_mchau_t;
/** /**
* The qse_mcint_t defines a type that can hold a qse_mchar_t value and * The qse_mcint_t defines a type that can hold a qse_mchar_t value and
* #QSE_MCHAR_EOF. * #QSE_MCHAR_EOF.
@ -520,9 +525,13 @@ typedef char qse_mchar_t;
typedef int qse_mcint_t; typedef int qse_mcint_t;
#define QSE_SIZEOF_MCINT_T QSE_SIZEOF_INT #define QSE_SIZEOF_MCINT_T QSE_SIZEOF_INT
/** \typedef qse_wchar_t /** \typedef qse_wchar_t
* The qse_wchar_t type defines a wide character type. * The qse_wchar_t type defines a wide character type.
*/ */
/** \typedef qse_wchau_t
* The qse_wchau_t type defines a type that can hold the unsigned qse_wchar_t value.
*/
/** \typedef qse_wcint_t /** \typedef qse_wcint_t
* The qse_wcint_t type defines a type that can hold a qse_wchar_t value and * The qse_wcint_t type defines a type that can hold a qse_wchar_t value and
* #QSE_WCHAR_EOF. * #QSE_WCHAR_EOF.
@ -531,6 +540,7 @@ typedef int qse_mcint_t;
/* WATCOM C++ before OpenWatcom */ /* WATCOM C++ before OpenWatcom */
typedef long char qse_wchar_t; typedef long char qse_wchar_t;
typedef unsigned long char qse_wchau_t;
typedef long char qse_wcint_t; typedef long char qse_wcint_t;
#elif defined(__cplusplus) && !( \ #elif defined(__cplusplus) && !( \
@ -541,38 +551,73 @@ typedef int qse_mcint_t;
/* C++ */ /* C++ */
typedef wchar_t qse_wchar_t; typedef wchar_t qse_wchar_t;
#if (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_LONG)
typedef unsigned long int qse_wchau_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_INT)
typedef unsigned int qse_wchau_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_SHORT)
typedef unsigned short int qse_wchau_t;
#else
/* may still be signed, but wchar_t should be large enough that the largest character won't exceed the maximum value of the type */
typedef wchar_t qse_wchau_t;
#endif
typedef wchar_t qse_wcint_t; typedef wchar_t qse_wcint_t;
/* all the way down from here for C */ /* all the way down from here for C */
#elif defined(__GNUC__) && defined(__WCHAR_TYPE__) && defined(__WINT_TYPE__) #elif defined(__GNUC__) && defined(__WCHAR_TYPE__) && defined(__WINT_TYPE__)
typedef __WCHAR_TYPE__ qse_wchar_t; typedef __WCHAR_TYPE__ qse_wchar_t;
#if (defined(__SIZEOF_WCHAR_T) && __SIZEOF_WCHAR_T == QSE_SIZEOF_LONG)
typedef unsigned long int qse_wchau_t;
#elif (defined(__SIZEOF_WCHAR_T) && __SIZEOF_WCHAR_T == QSE_SIZEOF_INT)
typedef unsigned int qse_wchau_t;
#elif (defined(__SIZEOF_WCHAR_T) && __SIZEOF_WCHAR_T == QSE_SIZEOF_SHORT)
typedef unsigned short int qse_wchau_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_LONG)
typedef unsigned long int qse_wchau_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_INT)
typedef unsigned int qse_wchau_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_SHORT)
typedef unsigned short int qse_wchau_t;
#else
/* i can't guarantee the unsignedness */
typedef __WINT_TYPE__ qse_wchau_t;
#endif
typedef __WINT_TYPE__ qse_wcint_t; typedef __WINT_TYPE__ qse_wcint_t;
#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_MCHAR_T) #elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_MCHAR_T)
/* most likely, there is no support for wchar_t */ /* most likely, there is no support for wchar_t */
typedef qse_mchar_t qse_wchar_t; typedef qse_mchar_t qse_wchar_t;
typedef qse_mchau_t qse_wchau_t;
typedef qse_mcint_t qse_wcint_t; typedef qse_mcint_t qse_wcint_t;
#elif (QSE_SIZEOF_WCHAR_T == 2) || (QSE_SIZEOF_WCHAR_T == 0) #elif (QSE_SIZEOF_WCHAR_T == 2) || (QSE_SIZEOF_WCHAR_T == 0)
typedef unsigned short qse_wchar_t; typedef unsigned short int qse_wchar_t;
typedef unsigned short qse_wcint_t; typedef unsigned short int qse_wchau_t;
typedef unsigned short int qse_wcint_t;
#elif (QSE_SIZEOF_WCHAR_T == 4) #elif (QSE_SIZEOF_WCHAR_T == 4)
# if defined(vms) || defined(__vms) # if defined(vms) || defined(__vms)
typedef unsigned int qse_wchar_t; typedef unsigned int qse_wchar_t;
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) # elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
typedef int qse_wchar_t; typedef int qse_wchar_t;
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# elif (defined(sun) || defined(__sun) || defined(__linux)) # elif (defined(sun) || defined(__sun) || defined(__linux))
# if defined(_LP64) # if defined(_LP64)
typedef int qse_wchar_t; typedef int qse_wchar_t;
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# else # else
typedef long qse_wchar_t; typedef long int qse_wchar_t;
typedef long qse_wcint_t; typedef unsigned long int qse_wchau_t;
typedef long int qse_wcint_t;
# endif # endif
# elif defined(__APPLE__) && defined(__MACH__) # elif defined(__APPLE__) && defined(__MACH__)
typedef int qse_wchar_t; typedef int qse_wchar_t;
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# elif defined(hpux) || defined(__hpux) || defined(__hpux__) # elif defined(hpux) || defined(__hpux) || defined(__hpux__)
# if defined(__HP_cc) || defined(__HP_aCC) # if defined(__HP_cc) || defined(__HP_aCC)
@ -580,12 +625,15 @@ typedef int qse_mcint_t;
# else # else
typedef int qse_wchar_t; typedef int qse_wchar_t;
# endif # endif
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# elif QSE_SIZEOF_LONG == 4 # elif QSE_SIZEOF_LONG == 4
typedef long qse_wchar_t; typedef long int qse_wchar_t;
typedef long qse_wcint_t; typedef unsigned long int qse_wchau_t;
typedef long int qse_wcint_t;
# elif QSE_SIZEOF_INT == 4 # elif QSE_SIZEOF_INT == 4
typedef int qse_wchar_t; typedef int qse_wchar_t;
typedef unsigned int qse_wchau_t;
typedef int qse_wcint_t; typedef int qse_wcint_t;
# else # else
# error No supported data type for wchar_t # error No supported data type for wchar_t
@ -597,15 +645,20 @@ typedef int qse_mcint_t;
/** \typedef qse_char_t /** \typedef qse_char_t
* The qse_char_t type defines a character type. * The qse_char_t type defines a character type.
*/ */
/** \typedef qse_chau_t
* The qse_chau_t type defines a type that can hold a unsigned qse_char_t value.
*/
/** \typedef qse_cint_t /** \typedef qse_cint_t
* The qse_cint_t typep defines a type that can hold a qse_char_t value and * The qse_cint_t type defines a type that can hold a qse_char_t value and
* #QSE_CHAR_EOF. * #QSE_CHAR_EOF.
*/ */
#if defined(QSE_CHAR_IS_MCHAR) #if defined(QSE_CHAR_IS_MCHAR)
typedef qse_mchar_t qse_char_t; typedef qse_mchar_t qse_char_t;
typedef qse_mchau_t qse_chau_t;
typedef qse_mcint_t qse_cint_t; typedef qse_mcint_t qse_cint_t;
#elif defined(QSE_CHAR_IS_WCHAR) #elif defined(QSE_CHAR_IS_WCHAR)
typedef qse_wchar_t qse_char_t; typedef qse_wchar_t qse_char_t;
typedef qse_wchau_t qse_chau_t;
typedef qse_wcint_t qse_cint_t; typedef qse_wcint_t qse_cint_t;
#else #else
/* If the character type is not determined in the conf_xxx files */ /* If the character type is not determined in the conf_xxx files */
@ -614,10 +667,12 @@ typedef int qse_mcint_t;
# if defined(UNICODE) || defined(_UNICODE) # if defined(UNICODE) || defined(_UNICODE)
# define QSE_CHAR_IS_WCHAR # define QSE_CHAR_IS_WCHAR
typedef qse_wchar_t qse_char_t; typedef qse_wchar_t qse_char_t;
typedef qse_wchau_t qse_chau_t;
typedef qse_wcint_t qse_cint_t; typedef qse_wcint_t qse_cint_t;
# else # else
# define QSE_CHAR_IS_MCHAR # define QSE_CHAR_IS_MCHAR
typedef qse_mchar_t qse_char_t; typedef qse_mchar_t qse_char_t;
typedef qse_mchau_t qse_chau_t;
typedef qse_mcint_t qse_cint_t; typedef qse_mcint_t qse_cint_t;
# endif # endif
# else # else

View File

@ -66,7 +66,7 @@ enum qse_xli_errnum_t
QSE_XLI_ESYNTAX, /**< syntax error */ QSE_XLI_ESYNTAX, /**< syntax error */
QSE_XLI_ESCOLON, /**< semicolon expected in place of '${0}' */ QSE_XLI_ESCOLON, /**< semicolon expected in place of '${0}' */
QSE_XLI_EEQ, /**< = expected in place of '${0}' */ QSE_XLI_EASSIGN, /**< = expected in place of '${0}' */
QSE_XLI_ELBREQ, /**< { or = expected in place of '${0}' */ QSE_XLI_ELBREQ, /**< { or = expected in place of '${0}' */
QSE_XLI_ERBRCE, /**< } expected in place of '${0}' */ QSE_XLI_ERBRCE, /**< } expected in place of '${0}' */
QSE_XLI_EPAVAL, /**< pair value expected in place of '${0}' */ QSE_XLI_EPAVAL, /**< pair value expected in place of '${0}' */
@ -126,9 +126,7 @@ enum qse_xli_opt_t
* and the second chracter specifies the tag closer. The are used when * and the second chracter specifies the tag closer. The are used when
* key tags and/or string tags are enabled. By default, it is "[]". * key tags and/or string tags are enabled. By default, it is "[]".
*/ */
QSE_XLI_TAGMARKER, QSE_XLI_TAGMARKER
QSE_XLI_ARRAYMARKER
}; };
typedef enum qse_xli_opt_t qse_xli_opt_t; typedef enum qse_xli_opt_t qse_xli_opt_t;
@ -158,9 +156,8 @@ enum qse_xli_trait_t
* "tg" is stored into the tag field of qse_xli_str_t. */ * "tg" is stored into the tag field of qse_xli_str_t. */
QSE_XLI_STRTAG = (1 << 10), QSE_XLI_STRTAG = (1 << 10),
/** use a colon as an assignment character intead of an equal sign. /** support the json format */
* it doesn't apply when reading or writing in the ini format. */ QSE_XLI_JSON = (1 << 11),
QSE_XLI_ASSIGNWITHCOLON = (1 << 11),
/** enable pair validation against pair definitions while reading */ /** enable pair validation against pair definitions while reading */
QSE_XLI_VALIDATE = (1 << 12) QSE_XLI_VALIDATE = (1 << 12)
@ -407,9 +404,10 @@ enum qse_xli_scm_flag_t
QSE_XLI_SCM_VALNIL = (1 << 1), QSE_XLI_SCM_VALNIL = (1 << 1),
QSE_XLI_SCM_VALSTR = (1 << 2), QSE_XLI_SCM_VALSTR = (1 << 2),
QSE_XLI_SCM_VALLIST = (1 << 3), QSE_XLI_SCM_VALLIST = (1 << 3),
QSE_XLI_SCM_VALARRAY = (1 << 4),
QSE_XLI_SCM_KEYNODUP = (1 << 4), QSE_XLI_SCM_KEYNODUP = (1 << 5),
QSE_XLI_SCM_KEYALIAS = (1 << 5), QSE_XLI_SCM_KEYALIAS = (1 << 6),
/** Indicates that the value is a list with uncertain definitions with /** Indicates that the value is a list with uncertain definitions with
* the following constraints: * the following constraints:
@ -420,7 +418,7 @@ enum qse_xli_scm_flag_t
* is specified. * is specified.
* *
* Applies only if #QSE_XLI_SCM_VALLIST is set. */ * Applies only if #QSE_XLI_SCM_VALLIST is set. */
QSE_XLI_SCM_VALIFFY = (1 << 6) QSE_XLI_SCM_VALIFFY = (1 << 7)
}; };
typedef enum qse_xli_scm_flag_t qse_xli_scm_flag_t; typedef enum qse_xli_scm_flag_t qse_xli_scm_flag_t;

View File

@ -29,6 +29,7 @@
static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_fflush (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_fflush (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_int (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi); static int fnc_int (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
static int fnc_asort (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi);
#define A_MAX QSE_TYPE_MAX(int) #define A_MAX QSE_TYPE_MAX(int)
@ -57,6 +58,9 @@ static qse_awk_fnc_t sysfnctab[] =
/* integer conversion */ /* integer conversion */
{ {QSE_T("int"), 3}, 0, { {1, 1, QSE_NULL}, fnc_int, 0 }, QSE_NULL}, { {QSE_T("int"), 3}, 0, { {1, 1, QSE_NULL}, fnc_int, 0 }, QSE_NULL},
/* array sort */
{ {QSE_T("asort"), 5}, 0, { {1, 3, QSE_NULL}, fnc_asort, 0 }, QSE_NULL},
/* string functions */ /* string functions */
{ {QSE_T("index"), 5}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_index, 0 }, QSE_NULL}, { {QSE_T("index"), 5}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_index, 0 }, QSE_NULL},
{ {QSE_T("substr"), 6}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_substr, 0 }, QSE_NULL}, { {QSE_T("substr"), 6}, 0, { {2, 3, QSE_NULL}, qse_awk_fnc_substr, 0 }, QSE_NULL},
@ -1369,3 +1373,27 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
qse_awk_rtx_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
static int fnc_asort (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
{
qse_size_t nargs;
qse_awk_val_t* a0;
qse_awk_int_t lv;
qse_awk_val_t* r;
int n;
/* TODO: .......................... */
nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1);
a0 = qse_awk_rtx_getarg (run, 0);
n = qse_awk_rtx_valtoint (run, a0, &lv);
if (n <= -1) return -1;
r = qse_awk_rtx_makeintval (run, lv);
if (r == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, r);
return 0;
}

View File

@ -35,7 +35,7 @@ int qse_mbscmp (const qse_mchar_t* s1, const qse_mchar_t* s2)
s1++; s2++; s1++; s2++;
} }
return (*s1 > *s2)? 1: -1; return ((qse_mchau_t)*s1 > (qse_mchau_t)*s2)? 1: -1;
} }
int qse_mbsxcmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2) int qse_mbsxcmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
@ -44,7 +44,7 @@ int qse_mbsxcmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
while (s1 < end && *s2 != QSE_MT('\0')) while (s1 < end && *s2 != QSE_MT('\0'))
{ {
if (*s1 != *s2) return (*s1 > *s2)? 1: -1; if (*s1 != *s2) return ((qse_mchau_t)*s1 > (qse_mchau_t)*s2)? 1: -1;
s1++; s2++; s1++; s2++;
} }
@ -56,7 +56,7 @@ int qse_mbsxncmp (
const qse_mchar_t* s1, qse_size_t ln1, const qse_mchar_t* s1, qse_size_t ln1,
const qse_mchar_t* s2, qse_size_t ln2) const qse_mchar_t* s2, qse_size_t ln2)
{ {
qse_mchar_t c1, c2; qse_mchau_t c1, c2;
const qse_mchar_t* end1 = s1 + ln1; const qse_mchar_t* end1 = s1 + ln1;
const qse_mchar_t* end2 = s2 + ln2; const qse_mchar_t* end2 = s2 + ln2;
@ -78,24 +78,24 @@ int qse_mbsxncmp (
int qse_mbscasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2) int qse_mbscasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2)
{ {
while (QSE_TOMUPPER(*s1) == QSE_TOMUPPER(*s2)) while (QSE_TOMUPPER((qse_mchau_t)*s1) == QSE_TOMUPPER((qse_mchau_t)*s2))
{ {
if (*s1 == QSE_C('\0')) return 0; if (*s1 == QSE_C('\0')) return 0;
s1++; s2++; s1++; s2++;
} }
return (QSE_TOMUPPER(*s1) > QSE_TOMUPPER(*s2))? 1: -1; return (QSE_TOMUPPER((qse_mchau_t)*s1) > QSE_TOMUPPER((qse_mchau_t)*s2))? 1: -1;
} }
int qse_mbsxcasecmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2) int qse_mbsxcasecmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
{ {
qse_mchar_t c1, c2; qse_mchau_t c1, c2;
const qse_mchar_t* end = s1 + ln; const qse_mchar_t* end = s1 + ln;
while (s1 < end && *s2 != QSE_MT('\0')) while (s1 < end && *s2 != QSE_MT('\0'))
{ {
c1 = QSE_TOMUPPER(*s1); c1 = QSE_TOMUPPER((qse_mchau_t)*s1);
c2 = QSE_TOMUPPER(*s2); c2 = QSE_TOMUPPER((qse_mchau_t)*s2);
if (c1 != c2) return (c1 > c2)? 1: -1; if (c1 != c2) return (c1 > c2)? 1: -1;
s1++; s2++; s1++; s2++;
} }
@ -107,16 +107,16 @@ int qse_mbsxncasecmp (
const qse_mchar_t* s1, qse_size_t ln1, const qse_mchar_t* s1, qse_size_t ln1,
const qse_mchar_t* s2, qse_size_t ln2) const qse_mchar_t* s2, qse_size_t ln2)
{ {
qse_mchar_t c1, c2; qse_mchau_t c1, c2;
const qse_mchar_t* end1 = s1 + ln1; const qse_mchar_t* end1 = s1 + ln1;
const qse_mchar_t* end2 = s2 + ln2; const qse_mchar_t* end2 = s2 + ln2;
while (s1 < end1) while (s1 < end1)
{ {
c1 = QSE_TOMUPPER (*s1); c1 = QSE_TOMUPPER ((qse_mchau_t)*s1);
if (s2 < end2) if (s2 < end2)
{ {
c2 = QSE_TOMUPPER (*s2); c2 = QSE_TOMUPPER ((qse_mchau_t)*s2);
if (c1 > c2) return 1; if (c1 > c2) return 1;
if (c1 < c2) return -1; if (c1 < c2) return -1;
} }
@ -138,20 +138,20 @@ int qse_mbszcmp (const qse_mchar_t* s1, const qse_mchar_t* s2, qse_size_t n)
s1++; s2++; n--; s1++; s2++; n--;
} }
return (*s1 > *s2)? 1: -1; return ((qse_mchau_t)*s1 > (qse_mchau_t)*s2)? 1: -1;
} }
int qse_mbszcasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2, qse_size_t n) int qse_mbszcasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2, qse_size_t n)
{ {
if (n == 0) return 0; if (n == 0) return 0;
while (QSE_TOMUPPER(*s1) == QSE_TOMUPPER(*s2)) while (QSE_TOMUPPER((qse_mchau_t)*s1) == QSE_TOMUPPER((qse_mchau_t)*s2))
{ {
if (*s1 == QSE_MT('\0') || n == 1) return 0; if (*s1 == QSE_MT('\0') || n == 1) return 0;
s1++; s2++; n--; s1++; s2++; n--;
} }
return (QSE_TOMUPPER(*s1) > QSE_TOMUPPER(*s2))? 1: -1; return (QSE_TOMUPPER((qse_mchau_t)*s1) > QSE_TOMUPPER((qse_mchau_t)*s2))? 1: -1;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -173,7 +173,7 @@ int qse_wcsxcmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
while (s1 < end && *s2 != QSE_WT('\0')) while (s1 < end && *s2 != QSE_WT('\0'))
{ {
if (*s1 != *s2) return (*s1 > *s2)? 1: -1; if (*s1 != *s2) return ((qse_wchau_t)*s1 > (qse_wchau_t)*s2)? 1: -1;
s1++; s2++; s1++; s2++;
} }
@ -184,7 +184,7 @@ int qse_wcsxncmp (
const qse_wchar_t* s1, qse_size_t ln1, const qse_wchar_t* s1, qse_size_t ln1,
const qse_wchar_t* s2, qse_size_t ln2) const qse_wchar_t* s2, qse_size_t ln2)
{ {
qse_wchar_t c1, c2; qse_wchau_t c1, c2;
const qse_wchar_t* end1 = s1 + ln1; const qse_wchar_t* end1 = s1 + ln1;
const qse_wchar_t* end2 = s2 + ln2; const qse_wchar_t* end2 = s2 + ln2;
@ -206,24 +206,24 @@ int qse_wcsxncmp (
int qse_wcscasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2) int qse_wcscasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2)
{ {
while (QSE_TOWUPPER(*s1) == QSE_TOWUPPER(*s2)) while (QSE_TOWUPPER((qse_wchau_t)*s1) == QSE_TOWUPPER((qse_wchau_t)*s2))
{ {
if (*s1 == QSE_C('\0')) return 0; if (*s1 == QSE_C('\0')) return 0;
s1++, s2++; s1++, s2++;
} }
return (QSE_TOWUPPER(*s1) > QSE_TOWUPPER(*s2))? 1: -1; return (QSE_TOWUPPER((qse_wchau_t)*s1) > QSE_TOWUPPER((qse_wchau_t)*s2))? 1: -1;
} }
int qse_wcsxcasecmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2) int qse_wcsxcasecmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
{ {
qse_wchar_t c1, c2; qse_wchau_t c1, c2;
const qse_wchar_t* end = s1 + ln; const qse_wchar_t* end = s1 + ln;
while (s1 < end && *s2 != QSE_WT('\0')) while (s1 < end && *s2 != QSE_WT('\0'))
{ {
c1 = QSE_TOWUPPER(*s1); c1 = QSE_TOWUPPER((qse_wchau_t)*s1);
c2 = QSE_TOWUPPER(*s2); c2 = QSE_TOWUPPER((qse_wchau_t)*s2);
if (c1 != c2) return (c1 > c2)? 1: -1; if (c1 != c2) return (c1 > c2)? 1: -1;
s1++; s2++; s1++; s2++;
} }
@ -234,16 +234,16 @@ int qse_wcsxncasecmp (
const qse_wchar_t* s1, qse_size_t ln1, const qse_wchar_t* s1, qse_size_t ln1,
const qse_wchar_t* s2, qse_size_t ln2) const qse_wchar_t* s2, qse_size_t ln2)
{ {
qse_wchar_t c1, c2; qse_wchau_t c1, c2;
const qse_wchar_t* end1 = s1 + ln1; const qse_wchar_t* end1 = s1 + ln1;
const qse_wchar_t* end2 = s2 + ln2; const qse_wchar_t* end2 = s2 + ln2;
while (s1 < end1) while (s1 < end1)
{ {
c1 = QSE_TOWUPPER (*s1); c1 = QSE_TOWUPPER((qse_wchau_t)*s1);
if (s2 < end2) if (s2 < end2)
{ {
c2 = QSE_TOWUPPER (*s2); c2 = QSE_TOWUPPER((qse_wchau_t)*s2);
if (c1 > c2) return 1; if (c1 > c2) return 1;
if (c1 < c2) return -1; if (c1 < c2) return -1;
} }
@ -264,18 +264,18 @@ int qse_wcszcmp (const qse_wchar_t* s1, const qse_wchar_t* s2, qse_size_t n)
s1++; s2++; n--; s1++; s2++; n--;
} }
return (*s1 > *s2)? 1: -1; return ((qse_wchau_t)*s1 > (qse_wchau_t)*s2)? 1: -1;
} }
int qse_wcszcasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2, qse_size_t n) int qse_wcszcasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2, qse_size_t n)
{ {
if (n == 0) return 0; if (n == 0) return 0;
while (QSE_TOWUPPER(*s1) == QSE_TOWUPPER(*s2)) while (QSE_TOWUPPER((qse_wchau_t)*s1) == QSE_TOWUPPER((qse_wchau_t)*s2))
{ {
if (*s1 == QSE_WT('\0') || n == 1) return 0; if (*s1 == QSE_WT('\0') || n == 1) return 0;
s1++; s2++; n--; s1++; s2++; n--;
} }
return (QSE_TOWUPPER(*s1) > QSE_TOWUPPER(*s2))? 1: -1; return (QSE_TOWUPPER((qse_wchau_t)*s1) > QSE_TOWUPPER((qse_wchau_t)*s2))? 1: -1;
} }

View File

@ -47,7 +47,7 @@ const qse_char_t* qse_xli_dflerrstr (
QSE_T("syntax error"), QSE_T("syntax error"),
QSE_T("semicolon expected in place of '${0}'"), QSE_T("semicolon expected in place of '${0}'"),
QSE_T("equal-sign expected in place of '${0}'"), QSE_T("assignment symbol expected in place of '${0}'"),
QSE_T("left-brace or assignment token expected in place of '${0}'"), QSE_T("left-brace or assignment token expected in place of '${0}'"),
QSE_T("right-brace expected in place of '${0}'"), QSE_T("right-brace expected in place of '${0}'"),
QSE_T("pair value expected in place of '${0}'"), QSE_T("pair value expected in place of '${0}'"),

View File

@ -378,7 +378,7 @@ static int read_list (qse_xli_t* xli)
if (!MATCH(xli, QSE_XLI_TOK_EQ)) if (!MATCH(xli, QSE_XLI_TOK_EQ))
{ {
qse_xli_seterror (xli, QSE_XLI_EEQ, QSE_STR_XSTR(xli->tok.name), &xli->tok.loc); qse_xli_seterror (xli, QSE_XLI_EASSIGN, QSE_STR_XSTR(xli->tok.name), &xli->tok.loc);
goto oops; goto oops;
} }

View File

@ -27,7 +27,6 @@
#include "xli.h" #include "xli.h"
#include <qse/cmn/chr.h> #include <qse/cmn/chr.h>
/* /*
"key1" { "key1" {
# comment # comment
@ -39,6 +38,9 @@
} }
*/ */
static qse_char_t tag_opener[] = { QSE_T('['), QSE_T('(') };
static qse_char_t tag_closer[] = { QSE_T(']'), QSE_T(')') };
static int get_token (qse_xli_t* xli); static int get_token (qse_xli_t* xli);
static int read_list (qse_xli_t* xli, qse_xli_list_t* list, const qse_xli_scm_t* override); static int read_list (qse_xli_t* xli, qse_xli_list_t* list, const qse_xli_scm_t* override);
@ -305,33 +307,37 @@ static int get_symbols (qse_xli_t* xli, qse_cint_t c, qse_xli_tok_t* tok)
{ {
const qse_char_t* str; const qse_char_t* str;
qse_size_t len; qse_size_t len;
int tid; int tid[2]; /* normal id, alternative id */
}; };
static struct ops_t ops[] = static struct ops_t ops[] =
{ {
{ QSE_T("="), 1, QSE_XLI_TOK_EQ }, { QSE_T("="), 1, { QSE_XLI_TOK_EQ, QSE_XLI_TOK_COLON } },
{ QSE_T(","), 1, QSE_XLI_TOK_COMMA }, { QSE_T(":"), 1, { QSE_XLI_TOK_COLON, QSE_XLI_TOK_EQ } },
{ QSE_T(":"), 1, QSE_XLI_TOK_COLON }, { QSE_T(","), 1, { QSE_XLI_TOK_COMMA, QSE_XLI_TOK_COMMA } },
{ QSE_T(";"), 1, QSE_XLI_TOK_SEMICOLON }, { QSE_T(";"), 1, { QSE_XLI_TOK_SEMICOLON, QSE_XLI_TOK_SEMICOLON } },
{ QSE_T("{"), 1, QSE_XLI_TOK_LBRACE }, { QSE_T("{"), 1, { QSE_XLI_TOK_LBRACE, QSE_XLI_TOK_LBRACE } },
{ QSE_T("}"), 1, QSE_XLI_TOK_RBRACE }, { QSE_T("}"), 1, { QSE_XLI_TOK_RBRACE, QSE_XLI_TOK_RBRACE } },
{ QSE_NULL, 0, 0, } { QSE_T("["), 1, { QSE_XLI_TOK_LBRACK, QSE_XLI_TOK_LPAREN } },
{ QSE_T("]"), 1, { QSE_XLI_TOK_RBRACK, QSE_XLI_TOK_RPAREN } },
{ QSE_T("("), 1, { QSE_XLI_TOK_LPAREN, QSE_XLI_TOK_LBRACK } },
{ QSE_T(")"), 1, { QSE_XLI_TOK_RPAREN, QSE_XLI_TOK_RBRACK } },
{ QSE_NULL, 0, { 0, 0 } }
}; };
struct ops_t* p; struct ops_t* p;
int idx = 0; int idx = 0;
int tid_mode = (xli->opt.trait & QSE_XLI_JSON)? 1: 0;
/* note that the loop below is not generaic enough. /* note that the loop below is not generaic enough.
* you must keep the operators strings in a particular order */ * you must keep the operators strings in a particular order */
for (p = ops; p->str != QSE_NULL; ) for (p = ops; p->str != QSE_NULL; )
{ {
if (p->str[idx] == QSE_T('\0')) if (p->str[idx] == QSE_T('\0'))
{ {
ADD_TOKEN_STR (xli, tok, p->str, p->len); ADD_TOKEN_STR (xli, tok, p->str, p->len);
SET_TOKEN_TYPE (xli, tok, p->tid); SET_TOKEN_TYPE (xli, tok, p->tid[tid_mode]);
return 1; return 1;
} }
@ -452,7 +458,7 @@ oops:
static int get_token_into (qse_xli_t* xli, qse_xli_tok_t* tok) static int get_token_into (qse_xli_t* xli, qse_xli_tok_t* tok)
{ {
qse_cint_t c; qse_cint_t c;
int n; int n, tag_mode = (xli->opt.trait & QSE_XLI_JSON)? 1: 0;
int skip_semicolon_after_include = 0; int skip_semicolon_after_include = 0;
retry: retry:
@ -537,7 +543,7 @@ retry:
GET_CHAR_TO (xli, c); GET_CHAR_TO (xli, c);
if (c == QSE_T('_') || c == QSE_T('-') || if (c == QSE_T('_') || c == QSE_T('-') ||
(!(xli->opt.trait & QSE_XLI_ASSIGNWITHCOLON) && c == QSE_T(':')) || (!(xli->opt.trait & QSE_XLI_JSON) && c == QSE_T(':')) ||
c == QSE_T('*') || c == QSE_T('/') || QSE_ISALPHA (c)) c == QSE_T('*') || c == QSE_T('/') || QSE_ISALPHA (c))
{ {
all_digits = 0; all_digits = 0;
@ -636,7 +642,7 @@ retry:
} }
} }
} }
else if ((xli->opt.trait & (QSE_XLI_KEYTAG | QSE_XLI_STRTAG)) && c == xli->opt.tag_marker[0]) /* [ */ else if ((xli->opt.trait & (QSE_XLI_KEYTAG | QSE_XLI_STRTAG)) && c == tag_opener[tag_mode]) /* [ */
{ {
/* a string tag is a bracketed word placed in front of a string value. /* a string tag is a bracketed word placed in front of a string value.
* A = [tg] "abc"; * A = [tg] "abc";
@ -658,7 +664,7 @@ retry:
return -1; return -1;
} }
if (c == xli->opt.tag_marker[1]) /* ] */ if (c == tag_closer[tag_mode]) /* ] */
{ {
/* terminating quote */ /* terminating quote */
GET_CHAR (xli); GET_CHAR (xli);
@ -861,7 +867,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, const qse_xli_sc
} }
} }
if (MATCH(xli, xli->opt._assign_tok)) /* either QSE_XLI_TOK_EQ or QSE_XLI_TOK_COLON */ if (MATCH(xli, QSE_XLI_TOK_EQ))
{ {
if (get_token (xli) <= -1) goto oops; if (get_token (xli) <= -1) goto oops;
@ -970,7 +976,12 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag, const qse_xli_sc
} }
/* TODO: check against schema */ /* TODO: check against schema */
}
else if (xli->opt.trait & QSE_XLI_JSON)
{
/* the assignment operator is mandator */
qse_xli_seterror (xli, QSE_XLI_EASSIGN, QSE_STR_XSTR(xli->tok.name), &xli->tok.loc);
goto oops;
} }
else if (!(xli->opt.trait & QSE_XLI_NOLIST) && MATCH (xli, QSE_XLI_TOK_LBRACE)) else if (!(xli->opt.trait & QSE_XLI_NOLIST) && MATCH (xli, QSE_XLI_TOK_LBRACE))
{ {
@ -1080,6 +1091,75 @@ void qse_xli_freelistlink (qse_xli_t* xli, qse_xli_list_link_t* link)
qse_xli_freemem (xli, link); qse_xli_freemem (xli, link);
} }
#if 0
static int __read_array (qse_xli_t* xli, int opt_outer_brace)
{
qse_size_t pair_count = 0;
while (1)
{
if (MATCH (xli, QSE_XLI_TOK_XINCLUDE))
{
if (get_token(xli) <= -1) return -1;
if (!MATCH(xli,QSE_XLI_TOK_SQSTR) && !MATCH(xli,QSE_XLI_TOK_DQSTR))
{
qse_xli_seterror (xli, QSE_XLI_EINCLSTR, QSE_NULL, &xli->tok.loc);
return -1;
}
if (begin_include (xli) <= -1) return -1;
}
else if (opt_outer_brace == 1 && pair_count == 0 && MATCH(xli, QSE_XLI_TOK_LBRACK))
{
opt_outer_brace++;
if (get_token(xli) <= -1) return -1;
}
else if (MATCH(xli, QSE_XLI_TOK_IDENT) || MATCH(xli, QSE_XLI_TOK_SQSTR) || MATCH(xli, QSE_XLI_TOK_DQSTR))
{
//if (read_pair(xli, QSE_NULL, override) <= -1) return -1;
pair_count++;
}
else if (MATCH(xli, QSE_XLI_TOK_LBRACE))
{
}
else if (MATCH(xli, QSE_XLI_TOK_LBRACK))
{
if (get_token(xli) <= -1) return -1;
if (__read_array(xli, 0) <= -1) return -1;
if (!MATCH(xli, QSE_XLI_TOK_RBRACK))
{
}
if (get_token(xli) <= -1) return -1;
}
else if (MATCH(xli, QSE_XLI_TOK_TEXT))
{
if (get_token(xli) <= -1) return -1;
}
else
{
break;
}
}
if (opt_outer_brace >= 2)
{
if (!MATCH(xli, QSE_XLI_TOK_RBRACE))
{
qse_xli_seterror (xli, QSE_XLI_ERBRCE, QSE_STR_XSTR(xli->tok.name), &xli->tok.loc);
return -1;
}
if (get_token(xli) <= -1) return -1;
}
return 0;
}
#endif
static int __read_list (qse_xli_t* xli, const qse_xli_scm_t* override, int opt_outer_brace) static int __read_list (qse_xli_t* xli, const qse_xli_scm_t* override, int opt_outer_brace)
{ {
qse_size_t pair_count = 0; qse_size_t pair_count = 0;

View File

@ -214,7 +214,7 @@ static int key_needs_quoting (qse_xli_t* xli, const qse_char_t* str, int nstr)
if (c == QSE_T('\0')) break; if (c == QSE_T('\0')) break;
if (c == QSE_T('_') || c == QSE_T('-') || if (c == QSE_T('_') || c == QSE_T('-') ||
(!(xli->opt.trait & QSE_XLI_ASSIGNWITHCOLON) && c == QSE_T(':')) || (!(xli->opt.trait & QSE_XLI_JSON) && c == QSE_T(':')) ||
c == QSE_T('*') || c == QSE_T('/') || QSE_ISALPHA(c)) c == QSE_T('*') || c == QSE_T('/') || QSE_ISALPHA(c))
{ {
all_digits = 0; all_digits = 0;
@ -269,7 +269,31 @@ static int write_list (qse_xli_t* xli, qse_xli_list_t* list, int depth)
{ QSE_T("\""), 1 } { QSE_T("\""), 1 }
}; };
static qse_char_t tag_opener[] = { QSE_T('['), QSE_T('(') };
static qse_char_t tag_closer[] = { QSE_T(']'), QSE_T(')') };
static struct
{
qse_char_t* ptr;
qse_size_t len;
} assign_symbol[] =
{
{ QSE_T(" = "), 3 },
{ QSE_T(": "), 2 }
};
static struct
{
qse_char_t* ptr;
qse_size_t len;
} list_assign_symbol[] =
{
{ QSE_T(" "), 1 },
{ QSE_T(": "), 2 }
};
qse_xli_atom_t* curatom; qse_xli_atom_t* curatom;
int tag_mode = (xli->opt.trait & QSE_XLI_JSON)? 1: 0;
for (curatom = list->head; curatom; curatom = curatom->next) for (curatom = list->head; curatom; curatom = curatom->next)
{ {
@ -284,9 +308,9 @@ static int write_list (qse_xli_t* xli, qse_xli_list_t* list, int depth)
if (pair->tag) if (pair->tag)
{ {
if (write_to_current_stream(xli, &xli->opt.tag_marker[0], 1, 0) <= -1 || if (write_to_current_stream(xli, &tag_opener[tag_mode], 1, 0) <= -1 ||
write_to_current_stream(xli, pair->tag, qse_strlen(pair->tag), 0) <= -1 || write_to_current_stream(xli, pair->tag, qse_strlen(pair->tag), 0) <= -1 ||
write_to_current_stream(xli, &xli->opt.tag_marker[1], 1, 0) <= -1) return -1; write_to_current_stream(xli, &tag_closer[tag_mode], 1, 0) <= -1) return -1;
} }
QSE_ASSERT(pair->_key_quoted >= 0 && pair->_key_quoted < QSE_COUNTOF(quotes)); QSE_ASSERT(pair->_key_quoted >= 0 && pair->_key_quoted < QSE_COUNTOF(quotes));
@ -319,14 +343,7 @@ static int write_list (qse_xli_t* xli, qse_xli_list_t* list, int depth)
{ {
qse_xli_str_t* str = (qse_xli_str_t*)pair->val; qse_xli_str_t* str = (qse_xli_str_t*)pair->val;
if (xli->opt.trait & QSE_XLI_ASSIGNWITHCOLON) if (write_to_current_stream(xli, assign_symbol[tag_mode].ptr, assign_symbol[tag_mode].len, 0) <= -1) return -1;
{
if (write_to_current_stream(xli, QSE_T(": "), 2, 0) <= -1) return -1;
}
else
{
if (write_to_current_stream(xli, QSE_T(" = "), 3, 0) <= -1) return -1;
}
while (1) while (1)
{ {
@ -351,7 +368,9 @@ static int write_list (qse_xli_t* xli, qse_xli_list_t* list, int depth)
case QSE_XLI_LIST: case QSE_XLI_LIST:
{ {
if (write_to_current_stream(xli, QSE_T(" {\n"), 3, 0) <= -1 || if (write_to_current_stream(xli, list_assign_symbol[tag_mode].ptr, list_assign_symbol[tag_mode].len, 0) <= -1) return -1;
if (write_to_current_stream(xli, QSE_T("{\n"), 2, 0) <= -1 ||
write_list (xli, (qse_xli_list_t*)pair->val, depth + 1) <= -1 || write_list (xli, (qse_xli_list_t*)pair->val, depth + 1) <= -1 ||
write_indentation (xli, depth) <= -1 || write_indentation (xli, depth) <= -1 ||
write_to_current_stream(xli, QSE_T("}\n"), 2, 0) <= -1) return -1; write_to_current_stream(xli, QSE_T("}\n"), 2, 0) <= -1) return -1;

View File

@ -70,11 +70,6 @@ int qse_xli_init (qse_xli_t* xli, qse_mmgr_t* mmgr, qse_size_t rootxtnsize)
xli->errstr = qse_xli_dflerrstr; xli->errstr = qse_xli_dflerrstr;
xli->opt.root_xtnsize = rootxtnsize; xli->opt.root_xtnsize = rootxtnsize;
xli->opt.key_splitter = QSE_T('.'); xli->opt.key_splitter = QSE_T('.');
xli->opt.tag_marker[0] = QSE_T('[');
xli->opt.tag_marker[1] = QSE_T(']');
xli->opt.array_marker[0] = QSE_T('(');
xli->opt.array_marker[1] = QSE_T(')');
xli->opt._assign_tok = QSE_XLI_TOK_EQ;
xli->dotted_curkey = qse_str_open (mmgr, 0, 128); xli->dotted_curkey = qse_str_open (mmgr, 0, 128);
if (xli->dotted_curkey == QSE_NULL) goto oops; if (xli->dotted_curkey == QSE_NULL) goto oops;
@ -126,7 +121,6 @@ int qse_xli_setopt (qse_xli_t* xli, qse_xli_opt_t id, const void* value)
{ {
case QSE_XLI_TRAIT: case QSE_XLI_TRAIT:
xli->opt.trait = *(const int*)value; xli->opt.trait = *(const int*)value;
xli->opt._assign_tok = (xli->opt.trait & QSE_XLI_ASSIGNWITHCOLON)? QSE_XLI_TOK_COLON: QSE_XLI_TOK_EQ;
return 0; return 0;
case QSE_XLI_PAIRXTNSIZE: case QSE_XLI_PAIRXTNSIZE:
@ -140,16 +134,6 @@ int qse_xli_setopt (qse_xli_t* xli, qse_xli_opt_t id, const void* value)
case QSE_XLI_KEYSPLITTER: case QSE_XLI_KEYSPLITTER:
xli->opt.key_splitter = *(const qse_char_t*)value; xli->opt.key_splitter = *(const qse_char_t*)value;
return 0; return 0;
case QSE_XLI_TAGMARKER:
xli->opt.tag_marker[0] = ((const qse_char_t*)value)[0];
xli->opt.tag_marker[1] = ((const qse_char_t*)value)[1];
return 0;
case QSE_XLI_ARRAYMARKER:
xli->opt.array_marker[0] = ((const qse_char_t*)value)[0];
xli->opt.array_marker[1] = ((const qse_char_t*)value)[1];
return 0;
} }
qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL);
@ -175,14 +159,6 @@ int qse_xli_getopt (qse_xli_t* xli, qse_xli_opt_t id, void* value)
case QSE_XLI_KEYSPLITTER: case QSE_XLI_KEYSPLITTER:
*(qse_char_t*)value = xli->opt.key_splitter; *(qse_char_t*)value = xli->opt.key_splitter;
return 0; return 0;
case QSE_XLI_TAGMARKER:
((qse_char_t*)value)[0] = xli->opt.tag_marker[1];
return 0;
case QSE_XLI_ARRAYMARKER:
((qse_char_t*)value)[0] = xli->opt.array_marker[1];
return 0;
}; };
qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL);

View File

@ -40,6 +40,10 @@ enum qse_xli_tok_type_t
QSE_XLI_TOK_COLON, QSE_XLI_TOK_COLON,
QSE_XLI_TOK_LBRACE, QSE_XLI_TOK_LBRACE,
QSE_XLI_TOK_RBRACE, QSE_XLI_TOK_RBRACE,
QSE_XLI_TOK_LBRACK,
QSE_XLI_TOK_RBRACK,
QSE_XLI_TOK_LPAREN,
QSE_XLI_TOK_RPAREN,
QSE_XLI_TOK_EQ, QSE_XLI_TOK_EQ,
QSE_XLI_TOK_COMMA, QSE_XLI_TOK_COMMA,
QSE_XLI_TOK_DQSTR, QSE_XLI_TOK_DQSTR,
@ -94,10 +98,6 @@ struct qse_xli_t
qse_size_t pair_xtnsize; qse_size_t pair_xtnsize;
qse_size_t root_xtnsize; qse_size_t root_xtnsize;
qse_char_t key_splitter; /**< character to use to split a key in the fqpn format */ qse_char_t key_splitter; /**< character to use to split a key in the fqpn format */
qse_char_t tag_marker[2];
qse_char_t array_marker[2];
qse_xli_tok_type_t _assign_tok;
} opt; } opt;
qse_xli_ecb_t* ecb; qse_xli_ecb_t* ecb;