diff --git a/moo/kernel/generr.moo b/moo/kernel/generr.moo index 4578eb0..23ad22f 100644 --- a/moo/kernel/generr.moo +++ b/moo/kernel/generr.moo @@ -58,7 +58,8 @@ class MyObject(Object) 'colon expected' 'string expected' 'invalid radix' - 'invalid numeric literal' + 'invalid integer literal' + 'invalid fixed-point decimal literal' 'byte too small or too large' 'wrong error literal' 'wrong smptr literal' diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 81ddb78..384fe52 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -666,7 +666,7 @@ static int string_to_smooi (moo_t* moo, moo_oocs_t* str, int radixed, moo_ooi_t* return 0; } -static moo_oop_t string_to_num (moo_t* moo, moo_oocs_t* str, int radixed) +static moo_oop_t string_to_int (moo_t* moo, moo_oocs_t* str, int radixed) { int negsign, base; const moo_ooch_t* ptr, * end; @@ -704,29 +704,23 @@ static moo_oop_t string_to_num (moo_t* moo, moo_oocs_t* str, int radixed) return moo_strtoint(moo, ptr, end - ptr, base); } -#if 0 -static moo_oop_t string_to_fpdec (moo_t* moo, moo_oocs_t* str, const moo_ioloc_t* loc) +static moo_oop_t string_to_fpdec (moo_t* moo, moo_oocs_t* str) { moo_oow_t pos, len; moo_oow_t scale = 0; moo_oop_t v; int base = 10; +MOO_DEBUG2 (moo, "string to fpdec... %.*js\n", str->len, str->ptr); pos = str->len; while (pos > 0) { - pos--; - if (str->ptr[pos] == '.') + if (str->ptr[--pos] == '.') { scale = str->len - pos - 1; - if (scale > MOO_SMOOI_MAX) - { - moo_setsynerrbfmt (moo, MOO_SYNERR_NUMRANGE, loc, str, "too many digits after decimal point"); - return MOO_NULL; - } - MOO_ASSERT (moo, scale > 0); - /*if (scale > 0)*/ MOO_MEMMOVE (&str->ptr[pos], &str->ptr[pos + 1], scale * MOO_SIZEOF(str->ptr[0])); /* remove the decimal point from the string */ + MOO_ASSERT (moo, scale <= MOO_SMOOI_MAX); + MOO_MEMMOVE (&str->ptr[pos], &str->ptr[pos + 1], scale * MOO_SIZEOF(str->ptr[0])); /* remove the decimal point from the string */ break; } } @@ -745,7 +739,6 @@ static moo_oop_t string_to_fpdec (moo_t* moo, moo_oocs_t* str, const moo_ioloc_t return moo_makefpdec(moo, v, scale); } -#endif static moo_oop_t string_to_error (moo_t* moo, moo_oocs_t* str, moo_ioloc_t* loc) { @@ -1378,7 +1371,7 @@ static int get_numlit (moo_t* moo, int negated) int radix_overflowed = 0; c = moo->c->lxc.c; - SET_TOKEN_TYPE (moo, MOO_IOTOK_NUMLIT); + SET_TOKEN_TYPE (moo, MOO_IOTOK_INTLIT); /*TODO: support a complex numeric literal */ do @@ -1432,7 +1425,7 @@ static int get_numlit (moo_t* moo, int negated) if (CHAR_TO_NUM(c, radix) >= radix) { /* no digit after the radix specifier */ - moo_setsynerr (moo, MOO_SYNERR_RADNUMLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); + moo_setsynerr (moo, MOO_SYNERR_RADINTLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); return -1; } @@ -1456,16 +1449,32 @@ static int get_numlit (moo_t* moo, int negated) } while (CHAR_TO_NUM(c, radix) < radix); - SET_TOKEN_TYPE (moo, MOO_IOTOK_RADNUMLIT); + SET_TOKEN_TYPE (moo, MOO_IOTOK_RADINTLIT); unget_char (moo, &moo->c->lxc); } - else + else if (c == '.') { -#if 0 - if (c == '.') + moo_iolxc_t period; + moo_oow_t scale = 0; + + period = moo->c->lxc; + GET_CHAR_TO (moo, c); + if (!is_digitchar(c)) { + unget_char (moo, &moo->c->lxc); + unget_char (moo, &period); + } + else + { + ADD_TOKEN_CHAR (moo, '.'); do { + if (scale >= MOO_SMOOI_MAX) + { + moo_setsynerrbfmt (moo, MOO_SYNERR_FPDECLITINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo), "invalid fixed-point decimal - too many digits after point"); + return -1; + } + scale++; ADD_TOKEN_CHAR (moo, c); GET_CHAR_TO (moo, c); if (c == '_') @@ -1484,16 +1493,18 @@ static int get_numlit (moo_t* moo, int negated) } while (is_digitchar(c)); - /* TODO: handle floating-point? fpdec if only suffixed with 's' like 1.23s4? */ + MOO_ASSERT (moo, scale > 0); + + /* TODO: handle floating-point? fpdec if only suffixed with 's' like 1.23s4?, 'e','g' for floating point? + * for now, there is no floating point support. as long as a point appears, it's a fpdec number. */ + +MOO_DEBUG2 (moo, "FPDEC LITERAL [%.*js]\n", TOKEN_NAME_LEN(moo), TOKEN_NAME_PTR(moo)); SET_TOKEN_TYPE (moo, MOO_IOTOK_FPDECLIT); } - else - { -#endif + } + else + { unget_char (moo, &moo->c->lxc); -#if 0 - } -#endif } /* @@ -2878,18 +2889,6 @@ static int add_symbol_literal (moo_t* moo, const moo_oocs_t* str, moo_oow_t offs return add_literal(moo, tmp, index); } - -static int add_fpdec_literal (moo_t* moo, const moo_oocs_t* str, moo_oow_t* index) -{ - moo_oop_t tmp; - -#if 0 - tmp = moo_makefpdec(moo, value, scale); - if (!tmp) return -1; -#endif - return add_literal(moo, tmp, index); -} - static MOO_INLINE int set_class_fqn (moo_t* moo, moo_cunit_class_t* cc, const moo_oocs_t* name) { if (copy_string_to(moo, name, &cc->fqn, &cc->fqn_capa, 0, '\0') <= -1) return -1; @@ -4085,7 +4084,7 @@ static int compile_method_pragma (moo_t* moo) GET_TOKEN (moo); switch (TOKEN_TYPE(moo)) { - case MOO_IOTOK_NUMLIT: + case MOO_IOTOK_INTLIT: /*TODO: more checks the validity of the primitive number. support number with radix and so on support more extensive syntax. support primitive name, not number*/ ptr = TOKEN_NAME_PTR(moo); end = ptr + TOKEN_NAME_LEN(moo); @@ -4813,7 +4812,7 @@ static int read_byte_array_literal (moo_t* moo, int rdonly, moo_oop_t* xlit) GET_TOKEN_GOTO (moo, oops); /* skip #[ and read the next token */ - while (TOKEN_TYPE(moo) == MOO_IOTOK_NUMLIT || TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT || TOKEN_TYPE(moo) == MOO_IOTOK_CHARLIT) + while (TOKEN_TYPE(moo) == MOO_IOTOK_INTLIT || TOKEN_TYPE(moo) == MOO_IOTOK_RADINTLIT || TOKEN_TYPE(moo) == MOO_IOTOK_CHARLIT) { /* TODO: check if the number is an integer */ @@ -4822,7 +4821,7 @@ static int read_byte_array_literal (moo_t* moo, int rdonly, moo_oop_t* xlit) /* accept a character literal inside a byte array literal */ tmp = TOKEN_NAME_PTR(moo)[0]; } - else if (string_to_smooi(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT, &tmp) <= -1) + else if (string_to_smooi(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADINTLIT, &tmp) <= -1) { /* the token reader reads a valid token. no other errors * than the range error must not occur */ @@ -5273,14 +5272,14 @@ static int compile_expression_primary (moo_t* moo, const moo_oocs_t* ident, cons GET_TOKEN (moo); break; - case MOO_IOTOK_NUMLIT: - case MOO_IOTOK_RADNUMLIT: + case MOO_IOTOK_INTLIT: + case MOO_IOTOK_RADINTLIT: { /* TODO: floating pointer number */ /* TODO: other types of numbers, etc */ moo_oop_t tmp; - tmp = string_to_num(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT); + tmp = string_to_int(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADINTLIT); if (!tmp) return -1; if (MOO_OOP_IS_SMOOI(tmp)) @@ -5297,13 +5296,19 @@ static int compile_expression_primary (moo_t* moo, const moo_oocs_t* ident, cons break; } -#if 0 case MOO_IOTOK_FPDECLIT: - if (add_fpdec_literal(moo, TOKEN_NAME(moo, &index) <= -1 || + { + moo_oop_t tmp; + + tmp = string_to_fpdec(moo, TOKEN_NAME(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; -#endif + } case MOO_IOTOK_SYMLIT: if (add_symbol_literal(moo, TOKEN_NAME(moo), 1, &index) <= -1 || @@ -7674,13 +7679,13 @@ static int process_class_modifiers (moo_t* moo, moo_ioloc_t* type_loc) GET_TOKEN (moo); - if (TOKEN_TYPE(moo) != MOO_IOTOK_NUMLIT && TOKEN_TYPE(moo) != MOO_IOTOK_RADNUMLIT) + if (TOKEN_TYPE(moo) != MOO_IOTOK_INTLIT && TOKEN_TYPE(moo) != MOO_IOTOK_RADINTLIT) { moo_setsynerr (moo, MOO_SYNERR_LITERAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); return -1; } - if (string_to_smooi(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT, &tmp) <= -1 || + if (string_to_smooi(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADINTLIT, &tmp) <= -1 || tmp < 0 || tmp > MOO_MAX_NAMED_INSTVARS) { /* the class type size has nothing to do with the name instance variables @@ -8690,11 +8695,19 @@ static moo_oop_t token_to_literal (moo_t* moo, int rdonly) MOO_ASSERT (moo, TOKEN_NAME_LEN(moo) == 1); return MOO_CHAR_TO_OOP(TOKEN_NAME_PTR(moo)[0]); - case MOO_IOTOK_NUMLIT: - case MOO_IOTOK_RADNUMLIT: + case MOO_IOTOK_INTLIT: + case MOO_IOTOK_RADINTLIT: { moo_oop_t lit; - lit = string_to_num(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT); + lit = string_to_int(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADINTLIT); + if (rdonly && lit && MOO_OOP_IS_POINTER(lit)) MOO_OBJ_SET_FLAGS_RDONLY (lit, 1); + return lit; + } + + case MOO_IOTOK_FPDECLIT: + { + moo_oop_t lit; + lit = string_to_fpdec(moo, TOKEN_NAME(moo)); if (rdonly && lit && MOO_OOP_IS_POINTER(lit)) MOO_OBJ_SET_FLAGS_RDONLY (lit, 1); return lit; } diff --git a/moo/lib/err.c b/moo/lib/err.c index 43f2bbd..9a3c4a6 100644 --- a/moo/lib/err.c +++ b/moo/lib/err.c @@ -60,8 +60,8 @@ static moo_ooch_t errstr_28[] = {'*','*','*',' ','u','n','d','e','f','i','n','e' static moo_ooch_t errstr_29[] = {'d','i','v','i','d','e',' ','b','y',' ','z','e','r','o','\0'}; static moo_ooch_t errstr_30[] = {'I','/','O',' ','e','r','r','o','r','\0'}; static moo_ooch_t errstr_31[] = {'e','n','c','o','d','i','n','g',' ','c','o','n','v','e','r','s','i','o','n',' ','e','r','r','o','r','\0'}; -static moo_ooch_t errstr_32[] = {'i','n','s','u','f','f','i','c','i','e','n','t',' ','d','a','t','a',' ','e','n','c','o','d','i','n','g',' ','c','o','n','v','e','r','s','i','o','n','\0'}; -static moo_ooch_t errstr_33[] = {'b','u','f','f','e','r',' ','f','u','l','l','\0'}; +static moo_ooch_t errstr_32[] = {'i','n','s','u','f','f','i','c','i','e','n','t',' ','d','a','t','a',' ','f','o','r',' ','e','n','c','o','d','i','n','g',' ','c','o','n','v','e','r','s','i','o','n','\0'}; +static moo_ooch_t errstr_33[] = {'b','u','f','f','e','r',' ','f','u','l','l','\0'}; static moo_ooch_t* errstr[] = { errstr_0, errstr_1, errstr_2, errstr_3, errstr_4, errstr_5, errstr_6, errstr_7, @@ -83,70 +83,71 @@ static moo_ooch_t synerrstr_7[] = {'w','r','o','n','g',' ','c','h','a','r','a',' 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[] = {'w','r','o','n','g',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_30[] = {'d','u','p','l','i','c','a','t','e',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_31[] = {'u','n','d','e','f','i','n','e','d',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_32[] = {'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_33[] = {'c','l','a','s','s',' ','n','o','t',' ','c','o','n','f','o','r','m','i','n','g',' ','t','o',' ','i','n','t','e','r','f','a','c','e','\0'}; -static moo_ooch_t synerrstr_34[] = {'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_35[] = {'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_36[] = {'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_37[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; -static moo_ooch_t synerrstr_38[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_39[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_40[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'}; -static moo_ooch_t synerrstr_41[] = {'m','e','t','h','o','d',' ','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',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'}; -static moo_ooch_t synerrstr_43[] = {'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_44[] = {'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_45[] = {'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_46[] = {'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_47[] = {'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_48[] = {'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_49[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'}; -static moo_ooch_t synerrstr_50[] = {'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_51[] = {'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_52[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'}; -static moo_ooch_t synerrstr_53[] = {'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_54[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'}; -static moo_ooch_t synerrstr_55[] = {'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_56[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; -static moo_ooch_t synerrstr_57[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'}; -static moo_ooch_t synerrstr_58[] = {'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_59[] = {'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_60[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'}; -static moo_ooch_t synerrstr_61[] = {'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_62[] = {'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_63[] = {'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_64[] = {'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_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','i','m','p','o','r','t',' ','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','i','m','p','o','r','t',' ','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_11[] = {'i','n','v','a','l','i','d',' ','i','n','t','e','g','e','r',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_12[] = {'i','n','v','a','l','i','d',' ','f','i','x','e','d','-','p','o','i','n','t',' ','d','e','c','i','m','a','l',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_13[] = {'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_14[] = {'w','r','o','n','g',' ','e','r','r','o','r',' ','l','i','t','e','r','a','l','\0'}; +static moo_ooch_t synerrstr_15[] = {'w','r','o','n','g',' ','s','m','p','t','r',' ','l','i','t','e','r','a','l','\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[] = {':','=',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_26[] = {'i','d','e','n','t','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_27[] = {'i','n','t','e','g','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_28[] = {'p','r','i','m','i','t','i','v','e',':',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_29[] = {'w','r','o','n','g',' ','d','i','r','e','c','t','i','v','e','\0'}; +static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_31[] = {'d','u','p','l','i','c','a','t','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_32[] = {'u','n','d','e','f','i','n','e','d',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_33[] = {'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_34[] = {'c','l','a','s','s',' ','n','o','t',' ','c','o','n','f','o','r','m','i','n','g',' ','t','o',' ','i','n','t','e','r','f','a','c','e','\0'}; +static moo_ooch_t synerrstr_35[] = {'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_36[] = {'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_37[] = {'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_38[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_39[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_40[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_41[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'}; +static moo_ooch_t synerrstr_42[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_43[] = {'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_44[] = {'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_45[] = {'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_46[] = {'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_47[] = {'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_48[] = {'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_49[] = {'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_50[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'}; +static moo_ooch_t synerrstr_51[] = {'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_52[] = {'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_53[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'}; +static moo_ooch_t synerrstr_54[] = {'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_55[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'}; +static moo_ooch_t synerrstr_56[] = {'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_57[] = {'t','o','o',' ','m','a','n','y',' ','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',' ','a','r','g','u','m','e','n','t','s','\0'}; +static moo_ooch_t synerrstr_59[] = {'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_60[] = {'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_61[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'}; +static moo_ooch_t synerrstr_62[] = {'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_63[] = {'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_64[] = {'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_65[] = {'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_66[] = {'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_67[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; +static moo_ooch_t synerrstr_68[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_69[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_70[] = {'w','r','o','n','g',' ','p','o','o','l','d','i','c','i','m','p','o','r','t',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_71[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l','d','i','c','i','m','p','o','r','t',' ','n','a','m','e','\0'}; +static moo_ooch_t synerrstr_72[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; +static moo_ooch_t synerrstr_73[] = {'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_74[] = {'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_75[] = {'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, @@ -158,7 +159,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_73, synerrstr_74 + synerrstr_72, synerrstr_73, synerrstr_74, synerrstr_75 }; #endif /* END: GENERATED WITH generr.moo */ diff --git a/moo/lib/logfmt.c b/moo/lib/logfmt.c index 1c70a51..df0b563 100644 --- a/moo/lib/logfmt.c +++ b/moo/lib/logfmt.c @@ -426,12 +426,19 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_ else if (c == moo->_large_positive_integer) { moo_oow_t i; - if (outbfmt (moo, mask, "16r") <= -1) return -1; + if (outbfmt(moo, mask, "16r") <= -1) return -1; for (i = MOO_OBJ_GET_SIZE(oop); i > 0;) { if (outbfmt(moo, mask, "%0*lX", (int)(MOO_SIZEOF(moo_liw_t) * 2), (unsigned long int)(MOO_OBJ_GET_LIWORD_SLOT(oop)[--i])) <= -1) return -1; } } + else if (c == moo->_fixed_point_decimal) + { +/* TODO: change this to a proper output.... */ + if (print_object(moo, mask, ((moo_oop_fpdec_t)oop)->value, outbfmt) <= -1) return -1; + if (outbfmt(moo, mask, "s") <= -1) return -1; + if (print_object(moo, mask, ((moo_oop_fpdec_t)oop)->scale, outbfmt) <= -1) return -1; + } else if (MOO_OBJ_GET_FLAGS_TYPE(oop) == MOO_OBJ_TYPE_CHAR) { if (c == moo->_symbol) diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 9808614..f9b7a7e 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -288,8 +288,9 @@ enum moo_iotok_type_t MOO_IOTOK_CHARLIT, MOO_IOTOK_STRLIT, MOO_IOTOK_SYMLIT, - MOO_IOTOK_NUMLIT, - MOO_IOTOK_RADNUMLIT, + MOO_IOTOK_INTLIT, + MOO_IOTOK_RADINTLIT, + MOO_IOTOK_FPDECLIT, MOO_IOTOK_ERRLIT, /* #\eNN */ MOO_IOTOK_SMPTRLIT, /* #\pXX */ diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 7aef821..3912063 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1811,7 +1811,8 @@ enum moo_synerrnum_t MOO_SYNERR_COLON, /* : expected */ MOO_SYNERR_STRING, /* string expected */ MOO_SYNERR_RADIXINVAL, /* invalid radix */ - MOO_SYNERR_RADNUMLITINVAL, /* invalid numeric literal with radix */ + MOO_SYNERR_RADINTLITINVAL, /* invalid integer literal with radix */ + MOO_SYNERR_FPDECLITINVAL, /* invalid fixed-point decimal literal */ MOO_SYNERR_BYTERANGE, /* byte too small or too large */ MOO_SYNERR_ERRLITINVAL, /* wrong error literal */ MOO_SYNERR_SMPTRLITINVAL, /* wrong smptr literal */