From 10dff52d5842ba6d7b53b734e3ebc413eaf1ddc0 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sun, 13 May 2018 18:55:22 +0000 Subject: [PATCH] introduced the notation for a smptr literal - #\pXX. changed the error listeral notation to #\eNN fro #\NN --- moo/kernel/Apex.moo | 28 ++++----- moo/kernel/generr.moo | 15 ++++- moo/lib/comp.c | 122 +++++++++++++++++++++++++++++++++---- moo/lib/err.c | 138 +++++++++++++++++++++--------------------- moo/lib/logfmt.c | 4 +- moo/lib/moo-prv.h | 3 +- moo/lib/moo.h | 4 +- 7 files changed, 213 insertions(+), 101 deletions(-) diff --git a/moo/kernel/Apex.moo b/moo/kernel/Apex.moo index 173406f..ee0fb5a 100644 --- a/moo/kernel/Apex.moo +++ b/moo/kernel/Apex.moo @@ -8,19 +8,19 @@ class(#limited) Error(Apex) pooldic Error.Code { - ENOERR := #\0. - EGENERIC := #\1. - ENOIMPL := #\2. - ESYSERR := #\3. - EINTERN := #\4. - ESYSMEM := #\5. - EOOMEM := #\6. - EINVAL := #\7. - ENOENT := #\8. - EPERM := #\12. - ERANGE := #\20. + ENOERR := #\E0. + EGENERIC := #\E1. + ENOIMPL := #\E2. + ESYSERR := #\E3. + EINTERN := #\E4. + ESYSMEM := #\E5. + EOOMEM := #\E6. + EINVAL := #\E7. + ENOENT := #\E8. + EPERM := #\E12. + ERANGE := #\E20. - ELIMIT := #\9999. + ELIMIT := #\E9999. (* add more items... *) } @@ -302,8 +302,8 @@ extend Error pooldic/const { - NONE := #\0. - GENERIC := #\1. + NONE := #\e0. + GENERIC := #\e1. } -------------------------------- *) diff --git a/moo/kernel/generr.moo b/moo/kernel/generr.moo index a58e65a..26b62b7 100644 --- a/moo/kernel/generr.moo +++ b/moo/kernel/generr.moo @@ -52,6 +52,7 @@ class MyObject(Object) 'string not closed' 'no character after $' 'no valid character after #' + 'no valid character after #\' 'wrong character literal' 'colon expected' 'string expected' @@ -59,6 +60,7 @@ class MyObject(Object) 'invalid numeric literal' 'byte too small or too large' 'wrong error literal' + 'wrong smptr literal' '{ expected' '} expected' '( expected' @@ -154,13 +156,22 @@ class MyObject(Object) method(#class) printString: s prefix: prefix index: index on: f { - | c | + | c | c := s size - 1. f puts('static moo_ooch_t ', prefix, index asString, '[] = {'). 0 to: c do: [:i | - f putc($', (s at: i), $'). + | ch | + ch := s at: i. + if (ch == $\ or: [ch == $"]) + { + f putc($', $\, (s at: i), $'). + } + else + { + f putc($', (s at: i), $'). + }. (i = c) ifFalse: [f putc($,) ]. ]. diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 092b6e3..4ed3a24 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -270,6 +270,12 @@ static MOO_INLINE int is_digitchar (moo_ooci_t c) return (c >= '0' && c <= '9'); } +static MOO_INLINE int is_xdigitchar (moo_ooci_t c) +{ +/* TODO: support full unicode */ + return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + static MOO_INLINE int is_alnumchar (moo_ooci_t c) { /* TODO: support full unicode */ @@ -288,7 +294,7 @@ static MOO_INLINE int is_binselchar (moo_ooci_t c) * - an exclamation mark is excluded intentioinally because i can't tell * the method symbol #! from the comment introducer #!. * - a question mark forms a normal identifier. - * - a backslash is used to form an error literal combined with a hash sign. (e.g. #\10) + * - a backslash is used to form an error literal combined with a hash sign. (e.g. #\E10) */ switch (c) @@ -645,7 +651,7 @@ static moo_oop_t string_to_error (moo_t* moo, moo_oocs_t* str, moo_ioloc_t* loc) ptr = str->ptr, end = str->ptr + str->len; - /* i assume that the input is in the form of error(NNN) + /* i assume that the input is in the form of \#ENNN * all other letters are non-digits except the NNN part. * i just skip all non-digit letters for simplicity sake. */ while (ptr < end) @@ -669,6 +675,48 @@ static moo_oop_t string_to_error (moo_t* moo, moo_oocs_t* str, moo_ioloc_t* loc) return MOO_ERROR_TO_OOP(num); } +static moo_oop_t string_to_smptr (moo_t* moo, moo_oocs_t* str, moo_ioloc_t* loc) +{ + moo_oow_t num = 0; + const moo_ooch_t* ptr, * end; + + ptr = str->ptr, + end = str->ptr + str->len; + + /* i assume that the input is in the form of \#PNNN + * all other letters are non-xdigits except the NNN part. + * i just skip all non-digit letters for simplicity sake. */ + while (ptr < end) + { + if (is_xdigitchar(*ptr)) + { + moo_oow_t xnum; + + xnum = num * 16; + if (*ptr >= 'a' && *ptr <= 'f') xnum += (*ptr - 'a' + 10); + else if (*ptr >= 'A' && *ptr <= 'F') xnum += (*ptr - 'A' + 10); + else xnum += (*ptr - '0'); + + if (xnum < num) + { + /* overflowed */ + moo_setsynerr (moo, MOO_SYNERR_SMPTRLITINVAL, loc, str); + return MOO_NULL; + } + num = xnum; + } + ptr++; + } + + if (!MOO_IN_SMPTR_RANGE(num)) + { + moo_setsynerr (moo, MOO_SYNERR_SMPTRLITINVAL, loc, str); + return MOO_NULL; + } + + return MOO_SMPTR_TO_OOP(num); +} + /* --------------------------------------------------------------------- * SOME PRIVIATE UTILITILES * --------------------------------------------------------------------- */ @@ -1743,23 +1791,54 @@ retry: break; case '\\': - /* #\NNN - error literal - #\0, #\1234, etc */ - SET_TOKEN_TYPE(moo, MOO_IOTOK_ERRLIT); ADD_TOKEN_CHAR(moo, c); GET_CHAR_TO (moo, c); - if (!is_digitchar(c)) + if (c == 'E' || c == 'e') + { + /* #\eNNN - error literal - #\e0, #\e1234, etc */ + SET_TOKEN_TYPE(moo, MOO_IOTOK_ERRLIT); + ADD_TOKEN_CHAR(moo, c); + GET_CHAR_TO (moo, c); + if (!is_digitchar(c)) + { + ADD_TOKEN_CHAR(moo, c); /* to include it to the error messsage */ + moo_setsynerr (moo, MOO_SYNERR_ERRLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); + return -1; + } + do + { + ADD_TOKEN_CHAR(moo, c); + GET_CHAR_TO (moo, c); + } + while (is_digitchar(c) || c == '_'); + } + else if (c == 'P' || c == 'p') + { + /* #\pXXX - smptr literal - #\p0, #\p100, etc */ + SET_TOKEN_TYPE(moo, MOO_IOTOK_SMPTRLIT); + ADD_TOKEN_CHAR(moo, c); + GET_CHAR_TO (moo, c); + + if (!is_xdigitchar(c)) + { + ADD_TOKEN_CHAR(moo, c); /* to include it to the error messsage */ + moo_setsynerr (moo, MOO_SYNERR_SMPTRLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); + return -1; + } + do + { + ADD_TOKEN_CHAR(moo, c); + GET_CHAR_TO (moo, c); + } + while (is_xdigitchar(c) || c == '_'); + } + else { ADD_TOKEN_CHAR(moo, c); /* to include it to the error messsage */ - moo_setsynerr (moo, MOO_SYNERR_ERRLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); + moo_setsynerr (moo, MOO_SYNERR_HBSLPINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); return -1; } - do - { - ADD_TOKEN_CHAR(moo, c); - GET_CHAR_TO (moo, c); - } - while (is_digitchar(c) || c == '_'); unget_char (moo, &moo->c->lxc); break; @@ -4975,7 +5054,21 @@ static int compile_expression_primary (moo_t* moo, const moo_oocs_t* ident, cons { moo_oop_t tmp; - tmp = string_to_error (moo, TOKEN_NAME(moo), TOKEN_LOC(moo)); + tmp = string_to_error(moo, TOKEN_NAME(moo), TOKEN_LOC(moo)); + if (!tmp) return -1; + + if (add_literal(moo, tmp, &index) <= -1 || + emit_single_param_instruction(moo, BCODE_PUSH_LITERAL_0, index) <= -1) return -1; + + GET_TOKEN (moo); + break; + } + + case MOO_IOTOK_SMPTRLIT: + { + moo_oop_t tmp; + + tmp = string_to_smptr(moo, TOKEN_NAME(moo), TOKEN_LOC(moo)); if (!tmp) return -1; if (add_literal(moo, tmp, &index) <= -1 || @@ -7829,6 +7922,9 @@ static moo_oop_t token_to_literal (moo_t* moo, int rdonly) case MOO_IOTOK_ERRLIT: return string_to_error(moo, TOKEN_NAME(moo), TOKEN_LOC(moo)); + case MOO_IOTOK_SMPTRLIT: + return string_to_smptr(moo, TOKEN_NAME(moo), TOKEN_LOC(moo)); + case MOO_IOTOK_CHARLIT: MOO_ASSERT (moo, TOKEN_NAME_LEN(moo) == 1); return MOO_CHAR_TO_OOP(TOKEN_NAME_PTR(moo)[0]); diff --git a/moo/lib/err.c b/moo/lib/err.c index 7549b28..9c442e1 100644 --- a/moo/lib/err.c +++ b/moo/lib/err.c @@ -81,73 +81,75 @@ static moo_ooch_t synerrstr_2[] = {'c','o','m','m','e','n','t',' ','n','o','t',' static moo_ooch_t synerrstr_3[] = {'s','t','r','i','n','g',' ','n','o','t',' ','c','l','o','s','e','d','\0'}; static moo_ooch_t synerrstr_4[] = {'n','o',' ','c','h','a','r','a','c','t','e','r',' ','a','f','t','e','r',' ','$','\0'}; static moo_ooch_t synerrstr_5[] = {'n','o',' ','v','a','l','i','d',' ','c','h','a','r','a','c','t','e','r',' ','a','f','t','e','r',' ','#','\0'}; -static moo_ooch_t synerrstr_6[] = {'w','r','o','n','g',' ','c','h','a','r','a','c','t','e','r',' ','l','i','t','e','r','a','l','\0'}; -static moo_ooch_t synerrstr_7[] = {'c','o','l','o','n',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_8[] = {'s','t','r','i','n','g',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_9[] = {'i','n','v','a','l','i','d',' ','r','a','d','i','x','\0'}; -static moo_ooch_t synerrstr_10[] = {'i','n','v','a','l','i','d',' ','n','u','m','e','r','i','c',' ','l','i','t','e','r','a','l','\0'}; -static moo_ooch_t synerrstr_11[] = {'b','y','t','e',' ','t','o','o',' ','s','m','a','l','l',' ','o','r',' ','t','o','o',' ','l','a','r','g','e','\0'}; -static moo_ooch_t synerrstr_12[] = {'w','r','o','n','g',' ','e','r','r','o','r',' ','l','i','t','e','r','a','l','\0'}; -static moo_ooch_t synerrstr_13[] = {'{',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_14[] = {'}',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_15[] = {'(',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_16[] = {')',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_17[] = {']',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_18[] = {'.',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_19[] = {',',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_20[] = {'|',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_21[] = {'>',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_22[] = {':','=',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_23[] = {'i','d','e','n','t','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_24[] = {'i','n','t','e','g','e','r',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_25[] = {'p','r','i','m','i','t','i','v','e',':',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_26[] = {'w','r','o','n','g',' ','d','i','r','e','c','t','i','v','e','\0'}; -static moo_ooch_t synerrstr_27[] = {'u','n','d','e','f','i','n','e','d',' ','c','l','a','s','s','\0'}; -static moo_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'}; -static moo_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'}; -static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_31[] = {'i','n','v','a','l','i','d',' ','n','o','n','-','p','o','i','n','t','e','r',' ','i','n','s','t','a','n','c','e',' ','s','i','z','e','\0'}; -static moo_ooch_t synerrstr_32[] = {'p','r','o','h','i','b','i','t','e','d',' ','i','n','h','e','r','i','t','a','n','c','e','\0'}; -static moo_ooch_t synerrstr_33[] = {'v','a','r','i','a','b','l','e',' ','d','e','c','l','a','r','a','t','i','o','n',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'}; -static moo_ooch_t synerrstr_34[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_35[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_36[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_38[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_39[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_40[] = {'i','n','v','a','l','i','d',' ','v','a','r','i','a','d','i','c',' ','m','e','t','h','o','d',' ','d','e','f','i','n','i','t','i','o','n','\0'}; -static moo_ooch_t synerrstr_41[] = {'v','a','r','i','a','b','l','e',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_42[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_43[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_44[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_45[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_46[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'}; -static moo_ooch_t synerrstr_47[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'}; -static moo_ooch_t synerrstr_48[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'}; -static moo_ooch_t synerrstr_49[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'}; -static moo_ooch_t synerrstr_50[] = {'t','o','o',' ','m','a','n','y',' ','i','n','s','t','a','n','c','e','/','c','l','a','s','s',' ','v','a','r','i','a','b','l','e','s','\0'}; -static moo_ooch_t synerrstr_51[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'}; -static moo_ooch_t synerrstr_52[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'}; -static moo_ooch_t synerrstr_53[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; -static moo_ooch_t synerrstr_54[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'}; -static moo_ooch_t synerrstr_55[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; -static moo_ooch_t synerrstr_56[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'}; -static moo_ooch_t synerrstr_57[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'}; -static moo_ooch_t synerrstr_58[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'}; -static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'}; -static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'}; -static moo_ooch_t synerrstr_62[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_63[] = {'f','a','i','l','e','d',' ','t','o',' ','i','m','p','o','r','t',' ','m','o','d','u','l','e','\0'}; -static moo_ooch_t synerrstr_64[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; -static moo_ooch_t synerrstr_65[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_66[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_67[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_68[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_69[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_70[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'}; -static moo_ooch_t synerrstr_71[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'}; -static moo_ooch_t synerrstr_72[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_6[] = {'n','o',' ','v','a','l','i','d',' ','c','h','a','r','a','c','t','e','r',' ','a','f','t','e','r',' ','#','\\','\0'}; +static moo_ooch_t synerrstr_7[] = {'w','r','o','n','g',' ','c','h','a','r','a','c','t','e','r',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_8[] = {'c','o','l','o','n',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_9[] = {'s','t','r','i','n','g',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_10[] = {'i','n','v','a','l','i','d',' ','r','a','d','i','x','\0'}; +static moo_ooch_t synerrstr_11[] = {'i','n','v','a','l','i','d',' ','n','u','m','e','r','i','c',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_12[] = {'b','y','t','e',' ','t','o','o',' ','s','m','a','l','l',' ','o','r',' ','t','o','o',' ','l','a','r','g','e','\0'}; +static moo_ooch_t synerrstr_13[] = {'w','r','o','n','g',' ','e','r','r','o','r',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_14[] = {'w','r','o','n','g',' ','s','m','p','t','r',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_15[] = {'{',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_16[] = {'}',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_17[] = {'(',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_18[] = {')',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_19[] = {']',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_20[] = {'.',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_21[] = {',',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_22[] = {'|',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_23[] = {'>',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_24[] = {':','=',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_25[] = {'i','d','e','n','t','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_26[] = {'i','n','t','e','g','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_27[] = {'p','r','i','m','i','t','i','v','e',':',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_28[] = {'w','r','o','n','g',' ','d','i','r','e','c','t','i','v','e','\0'}; +static moo_ooch_t synerrstr_29[] = {'u','n','d','e','f','i','n','e','d',' ','c','l','a','s','s','\0'}; +static moo_ooch_t synerrstr_30[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'}; +static moo_ooch_t synerrstr_31[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'}; +static moo_ooch_t synerrstr_32[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_33[] = {'i','n','v','a','l','i','d',' ','n','o','n','-','p','o','i','n','t','e','r',' ','i','n','s','t','a','n','c','e',' ','s','i','z','e','\0'}; +static moo_ooch_t synerrstr_34[] = {'p','r','o','h','i','b','i','t','e','d',' ','i','n','h','e','r','i','t','a','n','c','e','\0'}; +static moo_ooch_t synerrstr_35[] = {'v','a','r','i','a','b','l','e',' ','d','e','c','l','a','r','a','t','i','o','n',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'}; +static moo_ooch_t synerrstr_36[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_37[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_38[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_39[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_40[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_41[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_42[] = {'i','n','v','a','l','i','d',' ','v','a','r','i','a','d','i','c',' ','m','e','t','h','o','d',' ','d','e','f','i','n','i','t','i','o','n','\0'}; +static moo_ooch_t synerrstr_43[] = {'v','a','r','i','a','b','l','e',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_44[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_45[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_46[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_47[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_48[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'}; +static moo_ooch_t synerrstr_49[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'}; +static moo_ooch_t synerrstr_50[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'}; +static moo_ooch_t synerrstr_51[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'}; +static moo_ooch_t synerrstr_52[] = {'t','o','o',' ','m','a','n','y',' ','i','n','s','t','a','n','c','e','/','c','l','a','s','s',' ','v','a','r','i','a','b','l','e','s','\0'}; +static moo_ooch_t synerrstr_53[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'}; +static moo_ooch_t synerrstr_54[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'}; +static moo_ooch_t synerrstr_55[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; +static moo_ooch_t synerrstr_56[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'}; +static moo_ooch_t synerrstr_57[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; +static moo_ooch_t synerrstr_58[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'}; +static moo_ooch_t synerrstr_59[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'}; +static moo_ooch_t synerrstr_60[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'}; +static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'}; +static moo_ooch_t synerrstr_62[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_63[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'}; +static moo_ooch_t synerrstr_64[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_65[] = {'f','a','i','l','e','d',' ','t','o',' ','i','m','p','o','r','t',' ','m','o','d','u','l','e','\0'}; +static moo_ooch_t synerrstr_66[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; +static moo_ooch_t synerrstr_67[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_68[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_69[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_70[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_71[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_72[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'}; +static moo_ooch_t synerrstr_73[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'}; +static moo_ooch_t synerrstr_74[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'}; static moo_ooch_t* synerrstr[] = { synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7, @@ -159,7 +161,7 @@ static moo_ooch_t* synerrstr[] = synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55, synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63, synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69, synerrstr_70, synerrstr_71, - synerrstr_72 + synerrstr_72, synerrstr_73, synerrstr_74 }; #endif /* END: GENERATED WITH generr.moo */ diff --git a/moo/lib/logfmt.c b/moo/lib/logfmt.c index 11ae700..ed7864e 100644 --- a/moo/lib/logfmt.c +++ b/moo/lib/logfmt.c @@ -396,7 +396,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_ } else if (MOO_OOP_IS_SMPTR(oop)) { - if (outbfmt(moo, mask, "%p", MOO_OOP_TO_SMPTR(oop)) <= -1) return -1; + if (outbfmt(moo, mask, "#\\p%X", MOO_OOP_TO_SMPTR(oop)) <= -1) return -1; } else if (MOO_OOP_IS_CHAR(oop)) { @@ -404,7 +404,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_ } else if (MOO_OOP_IS_ERROR(oop)) { - if (outbfmt(moo, mask, "#\\%zd", MOO_OOP_TO_ERROR(oop)) <= -1) return -1; + if (outbfmt(moo, mask, "#\\e%zd", MOO_OOP_TO_ERROR(oop)) <= -1) return -1; } else { diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 3b18eca..c8b3b5e 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -331,7 +331,8 @@ enum moo_iotok_type_t MOO_IOTOK_SYMLIT, MOO_IOTOK_NUMLIT, MOO_IOTOK_RADNUMLIT, - MOO_IOTOK_ERRLIT, /* #\NN */ + MOO_IOTOK_ERRLIT, /* #\eNN */ + MOO_IOTOK_SMPTRLIT, /* #\pXX */ MOO_IOTOK_NIL, MOO_IOTOK_SELF, diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 517498b..bc441ac 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1595,7 +1595,8 @@ enum moo_synerrnum_t MOO_SYNERR_CMTNC, /* comment not closed */ MOO_SYNERR_STRNC, /* string not closed */ MOO_SYNERR_CLTNT, /* character literal not terminated */ - MOO_SYNERR_HLTNT, /* hashed literal not terminated */ + MOO_SYNERR_HLTNT, /* hashed literal not terminated - no valid character after #*/ + MOO_SYNERR_HBSLPINVAL, /* invalid hash-backslahed literal prefix - no valid character after #\ */ MOO_SYNERR_CHARLITINVAL, /* wrong character literal */ MOO_SYNERR_COLON, /* : expected */ MOO_SYNERR_STRING, /* string expected */ @@ -1603,6 +1604,7 @@ enum moo_synerrnum_t MOO_SYNERR_RADNUMLITINVAL, /* invalid numeric literal with radix */ MOO_SYNERR_BYTERANGE, /* byte too small or too large */ MOO_SYNERR_ERRLITINVAL, /* wrong error literal */ + MOO_SYNERR_SMPTRLITINVAL, /* wrong smptr literal */ MOO_SYNERR_LBRACE, /* { expected */ MOO_SYNERR_RBRACE, /* } expected */ MOO_SYNERR_LPAREN, /* ( expected */