in progress removing the error target stuffs
This commit is contained in:
		@ -392,9 +392,6 @@ static void print_synerr (hak_t* hak)
 | 
			
		||||
		(hak_geterrmsg(hak) != hak_geterrstr(hak)? hak_geterrmsg(hak): hak_geterrstr(hak))
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	if (synerr.tgt.len > 0)
 | 
			
		||||
		hak_logbfmt(hak, HAK_LOG_STDERR, " - %.*js", synerr.tgt.len, synerr.tgt.val);
 | 
			
		||||
 | 
			
		||||
	hak_logbfmt(hak, HAK_LOG_STDERR, "\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -70,7 +70,6 @@ type Err struct {
 | 
			
		||||
	Colm uint
 | 
			
		||||
	File string
 | 
			
		||||
	Msg string
 | 
			
		||||
	Tgt string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type BitMask C.hak_bitmask_t
 | 
			
		||||
@ -127,8 +126,6 @@ func (hak *Hak) make_errinfo() *Err {
 | 
			
		||||
		var synerr C.hak_synerr_t
 | 
			
		||||
		C.hak_getsynerr(hak.c, &synerr)
 | 
			
		||||
		loc = synerr.loc
 | 
			
		||||
 | 
			
		||||
		err.Tgt = string(uchars_to_rune_slice(&synerr.tgt.val[0], uintptr(synerr.tgt.len)))
 | 
			
		||||
	} else {
 | 
			
		||||
		C.hak_geterrloc(hak.c, &loc)
 | 
			
		||||
	}
 | 
			
		||||
@ -475,9 +472,5 @@ func c_to_go(c *C.hak_t) *Hak {
 | 
			
		||||
// -----------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
func (err* Err) Error() string {
 | 
			
		||||
	if err.Tgt == "" {
 | 
			
		||||
		return fmt.Sprintf("%s[%d,%d] %s", err.File, err.Line, err.Colm, err.Msg)
 | 
			
		||||
	} else {
 | 
			
		||||
	}
 | 
			
		||||
		return fmt.Sprintf("%s[%d,%d] %s - %s", err.File, err.Line, err.Colm, err.Msg, err.Tgt)
 | 
			
		||||
	return fmt.Sprintf("%s[%d,%d] %s", err.File, err.Line, err.Colm, err.Msg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										74
									
								
								lib/comp.c
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								lib/comp.c
									
									
									
									
									
								
							@ -406,7 +406,7 @@ static int find_variable_backward_with_word (hak_t* hak, const hak_oocs_t* name,
 | 
			
		||||
					{
 | 
			
		||||
						/* instance variables are accessible only in an instance method defintion scope.
 | 
			
		||||
						 * it is in class initialization scope */
 | 
			
		||||
						hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, loc, name, "prohibited access to instance variable");
 | 
			
		||||
						hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, loc, HAK_NULL, "prohibited access to instance variable around '%.*js'", name->len, name->ptr);
 | 
			
		||||
						return -1;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
@ -416,7 +416,7 @@ static int find_variable_backward_with_word (hak_t* hak, const hak_oocs_t* name,
 | 
			
		||||
						if ((hak->c->funblk.info[--fi].fun_type & 0xFF) == FUN_CM)
 | 
			
		||||
						{
 | 
			
		||||
							/* the function where this variable is defined is a class method or an plain function block within a class method*/
 | 
			
		||||
							hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, loc, name, "prohibited access to instance variable in class method context");
 | 
			
		||||
							hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, loc, HAK_NULL, "prohibited access to instance variable in class method context around '%.*js'", name->len, name->ptr);
 | 
			
		||||
							return -1;
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
@ -1608,7 +1608,9 @@ static int collect_vardcl_for_class (hak_t* hak, hak_cnode_t* obj, hak_cnode_t**
 | 
			
		||||
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(dcl))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(dcl), HAK_CNODE_GET_TOK(dcl), "redundant cdr in %hs declaration", desc[enclosed]);
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(dcl), HAK_NULL,
 | 
			
		||||
				"redundant cdr in %hs declaration around '%.*js'",
 | 
			
		||||
				desc[enclosed], HAK_CNODE_GET_TOKLEN(dcl), HAK_CNODE_GET_TOKPTR(dcl));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -1670,7 +1672,9 @@ static int collect_vardcl (hak_t* hak, hak_cnode_t* obj, hak_cnode_t** nextobj,
 | 
			
		||||
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(dcl))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(dcl), HAK_CNODE_GET_TOK(dcl), "redundant cdr in %hs variable list", desc);
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(dcl), HAK_NULL,
 | 
			
		||||
				"redundant cdr in %hs variable list around '%.*js'",
 | 
			
		||||
				desc, HAK_CNODE_GET_TOKLEN(dcl), HAK_CNODE_GET_TOKPTR(dcl));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -1727,7 +1731,10 @@ static int check_if_plain_cnode (hak_t* hak, hak_cnode_t* obj, hak_cnode_t* prev
 | 
			
		||||
	}
 | 
			
		||||
	else if (!HAK_CNODE_IS_CONS(obj))
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(prev), HAK_CNODE_GET_TOK(obj), "redundant cdr where %.*js is expected in %.*js", bname, HAK_CNODE_GET_TOKLEN(container), HAK_CNODE_GET_TOKPTR(container));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(prev), HAK_NULL,
 | 
			
		||||
			"redundant cdr where %.*js is expected in %.*js around '%.*js'",
 | 
			
		||||
			bname, HAK_CNODE_GET_TOKLEN(container), HAK_CNODE_GET_TOKPTR(container),
 | 
			
		||||
			HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1833,7 +1840,8 @@ static int compile_and (hak_t* hak, hak_cnode_t* src)
 | 
			
		||||
	}
 | 
			
		||||
	else if (!HAK_CNODE_IS_CONS(obj))
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "redundant cdr in and");
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
			"redundant cdr in 'and' around '%.*js'", HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1862,7 +1870,8 @@ static HAK_INLINE int compile_and_p1 (hak_t* hak)
 | 
			
		||||
	obj = cf->operand;
 | 
			
		||||
	if (!HAK_CNODE_IS_CONS(obj))
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "redundant cdr in and");
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
			"redundant cdr in 'and' around '%.*js'", HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -4568,12 +4577,16 @@ static int compile_while (hak_t* hak, hak_cnode_t* src, int next_cop)
 | 
			
		||||
	if (!obj)
 | 
			
		||||
	{
 | 
			
		||||
		/* no value */
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_ARGCOUNT, HAK_CNODE_GET_LOC(src), HAK_NULL, "no loop condition specified in %.*js", HAK_CNODE_GET_TOKLEN(cmd), HAK_CNODE_GET_TOKPTR(cmd));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_ARGCOUNT, HAK_CNODE_GET_LOC(src), HAK_NULL,
 | 
			
		||||
			"no loop condition specified in %.*js", HAK_CNODE_GET_TOKLEN(cmd), HAK_CNODE_GET_TOKPTR(cmd));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	else if (!HAK_CNODE_IS_CONS(obj))
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "redundant cdr in %*.js", HAK_CNODE_GET_TOKLEN(cmd), HAK_CNODE_GET_TOKPTR(cmd));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
			"redundant cdr around '%.*js' in '%.%js'",
 | 
			
		||||
			HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj),
 | 
			
		||||
			HAK_CNODE_GET_TOKLEN(cmd), HAK_CNODE_GET_TOKPTR(cmd));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -5107,7 +5120,9 @@ static int compile_cons_mlist_expression (hak_t* hak, hak_cnode_t* obj, hak_ooi_
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(cdr))
 | 
			
		||||
		{
 | 
			
		||||
			/* (funname . 10) */
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(cdr), HAK_CNODE_GET_TOK(cdr), "redundant cdr in function call");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(cdr), HAK_NULL,
 | 
			
		||||
				"redundant cdr in function call around '%.*js'",
 | 
			
		||||
				HAK_CNODE_GET_TOKLEN(cdr), HAK_CNODE_GET_TOKPTR(cdr));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -5220,7 +5235,9 @@ static HAK_INLINE int compile_dsymbol (hak_t* hak, hak_cnode_t* obj)
 | 
			
		||||
				 *   }
 | 
			
		||||
				 * }
 | 
			
		||||
				 */
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "not allowed to prefix with self in out-of-class method context");
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
					"not allowed to prefix with self in out-of-class method context around '%.*js'",
 | 
			
		||||
					HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
			name.ptr = (hak_ooch_t*)(sep + 1);
 | 
			
		||||
@ -5231,7 +5248,9 @@ static HAK_INLINE int compile_dsymbol (hak_t* hak, hak_cnode_t* obj)
 | 
			
		||||
		{
 | 
			
		||||
			if (fbi->fun_type >> 8) /* if defined using A:xxx syntax */
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "not allowed to prefix with super in out-of-class method context");
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
					"not allowed to prefix with super in out-of-class method context around '%.*js'",
 | 
			
		||||
					HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
			name.ptr = (hak_ooch_t*)(sep + 1);
 | 
			
		||||
@ -5266,7 +5285,8 @@ static HAK_INLINE int compile_dsymbol (hak_t* hak, hak_cnode_t* obj)
 | 
			
		||||
		pfbase = hak_querymod(hak, HAK_CNODE_GET_TOKPTR(obj), HAK_CNODE_GET_TOKLEN(obj), &mod);
 | 
			
		||||
		if (!pfbase)
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_CNODE_GET_TOK(obj), "unknown dotted symbol");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, HAK_CNODE_GET_LOC(obj), HAK_NULL,
 | 
			
		||||
				"unknown dotted symbol '%.*js'", HAK_CNODE_GET_TOKLEN(obj), HAK_CNODE_GET_TOKPTR(obj));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -5500,7 +5520,7 @@ static hak_oop_t string_to_fpdec (hak_t* hak, hak_oocs_t* str, const hak_loc_t*
 | 
			
		||||
			scale = str->len - pos - 1;
 | 
			
		||||
			if (scale > HAK_SMOOI_MAX)
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_NUMRANGE, loc, str, "too many digits after decimal point");
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_NUMRANGE, loc, HAK_NULL, "too many digits after decimal point around '%.*js'", str->len, str->ptr);
 | 
			
		||||
				return HAK_NULL;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -5740,7 +5760,8 @@ redo:
 | 
			
		||||
					return -1;
 | 
			
		||||
 | 
			
		||||
				default:
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_INTERN, HAK_CNODE_GET_LOC(oprnd), HAK_NULL, "internal error - unknown list type %d", HAK_CNODE_CONS_CONCODE(oprnd));
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_INTERN, HAK_CNODE_GET_LOC(oprnd), HAK_NULL,
 | 
			
		||||
						"internal error - unknown list type %d", HAK_CNODE_CONS_CONCODE(oprnd));
 | 
			
		||||
					return -1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -5872,7 +5893,9 @@ static int compile_object_list (hak_t* hak)
 | 
			
		||||
#endif
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(oprnd))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_CNODE_GET_TOK(oprnd), "redundant cdr in the object list");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_NULL,
 | 
			
		||||
				"redundant cdr in the object list around '%.*js'",
 | 
			
		||||
				HAK_CNODE_GET_TOKLEN(oprnd), HAK_CNODE_GET_TOKPTR(oprnd));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -5961,7 +5984,9 @@ static int compile_array_list (hak_t* hak)
 | 
			
		||||
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(oprnd))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_CNODE_GET_TOK(oprnd), "redundant cdr in the array list");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_NULL,
 | 
			
		||||
				"redundant cdr in the array list around '%.*js'",
 | 
			
		||||
				HAK_CNODE_GET_TOKLEN(oprnd), HAK_CNODE_GET_TOKPTR(oprnd));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -6008,7 +6033,9 @@ static int compile_pure_array_list (hak_t* hak)
 | 
			
		||||
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(oprnd))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_CNODE_GET_TOK(oprnd), "redundant cdr in the byte-array list");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_NULL,
 | 
			
		||||
				"redundant cdr in the byte-array list around '%.*js'",
 | 
			
		||||
				HAK_CNODE_GET_TOKLEN(oprnd), HAK_CNODE_GET_TOKPTR(oprnd));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -6060,7 +6087,8 @@ static int compile_dic_list (hak_t* hak)
 | 
			
		||||
 | 
			
		||||
		if (!HAK_CNODE_IS_CONS(oprnd))
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_CNODE_GET_TOK(oprnd), "redundant cdr in the dictionary list");
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, HAK_CNODE_GET_LOC(oprnd), HAK_NULL,
 | 
			
		||||
				"redundant cdr in the dictionary list around '%.*js'", HAK_CNODE_GET_TOKLEN(oprnd), HAK_CNODE_GET_TOKPTR(oprnd));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -6070,7 +6098,8 @@ static int compile_dic_list (hak_t* hak)
 | 
			
		||||
		SWITCH_TOP_CFRAME(hak, COP_COMPILE_OBJECT, car);
 | 
			
		||||
		if (!cdr)
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_UNBALKV, HAK_CNODE_GET_LOC(car), HAK_NULL, "no value for key %.*js", HAK_CNODE_GET_TOKLEN(car), HAK_CNODE_GET_TOKPTR(car));
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_UNBALKV, HAK_CNODE_GET_LOC(car), HAK_NULL,
 | 
			
		||||
				"no value for key %.*js", HAK_CNODE_GET_TOKLEN(car), HAK_CNODE_GET_TOKPTR(car));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -6660,7 +6689,7 @@ static HAK_INLINE int post_fun (hak_t* hak)
 | 
			
		||||
				 * but if it happens, it is a syntax error */
 | 
			
		||||
				hak_setsynerrbfmt(
 | 
			
		||||
					hak, HAK_SYNERR_BANNED, HAK_CNODE_GET_LOC(class_name), HAK_NULL,
 | 
			
		||||
					"class name '%.js' prohibited class initialization context",
 | 
			
		||||
					"class name '%.*js' prohibited class initialization context",
 | 
			
		||||
					HAK_CNODE_GET_TOKLEN(class_name), HAK_CNODE_GET_TOKPTR(class_name));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
@ -6694,7 +6723,8 @@ static HAK_INLINE int post_fun (hak_t* hak)
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAMEDUP, HAK_CNODE_GET_LOC(fun_name), HAK_CNODE_GET_TOK(fun_name), "duplicate method name");
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAMEDUP, HAK_CNODE_GET_LOC(fun_name), HAK_NULL,
 | 
			
		||||
					"duplicate method name '%.*js'", HAK_CNODE_GET_TOKLEN(fun_name), HAK_CNODE_GET_TOKPTR(fun_name));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										74
									
								
								lib/err.c
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								lib/err.c
									
									
									
									
									
								
							@ -654,14 +654,13 @@ void hak_getsynerr (hak_t* hak, hak_synerr_t* synerr)
 | 
			
		||||
	if (synerr) *synerr = hak->c->synerr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hak_getbsynerr (hak_t* hak, hak_bsynerr_t* synerr)
 | 
			
		||||
void hak_getsynerrb (hak_t* hak, hak_synerrb_t* synerr)
 | 
			
		||||
{
 | 
			
		||||
	HAK_ASSERT(hak, hak->c != HAK_NULL);
 | 
			
		||||
	if (synerr)
 | 
			
		||||
	{
 | 
			
		||||
	#if defined(HAK_OOCH_IS_UCH)
 | 
			
		||||
		hak_synerr_t* s;
 | 
			
		||||
		const hak_ooch_t* msg;
 | 
			
		||||
		hak_oow_t wcslen, mbslen;
 | 
			
		||||
 | 
			
		||||
		s = &hak->c->synerr;
 | 
			
		||||
@ -675,32 +674,13 @@ void hak_getbsynerr (hak_t* hak, hak_bsynerr_t* synerr)
 | 
			
		||||
			hak_conv_ucstr_to_bcstr_with_cmgr(s->loc.file, &wcslen, hak->errmsg.xerrlocfile, &mbslen, hak->_cmgr);
 | 
			
		||||
			synerr->loc.file = hak->errmsg.xerrlocfile; /* this can be truncated and is transient */
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
		msg = (hak->errmsg.buf[0] == '\0')? hak_errnum_to_errstr(hak->errnum): hak->errmsg.buf;
 | 
			
		||||
		mbslen = HAK_COUNTOF(synerr->tgt.val);
 | 
			
		||||
		hak_conv_ucstr_to_bcstr_with_cmgr(msg, &wcslen, errinf->msg, &mbslen, hak->_cmgr);
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
		synerr->
 | 
			
		||||
 | 
			
		||||
     hak_synerrnum_t num;
 | 
			
		||||
     hak_bloc_t      loc;
 | 
			
		||||
     struct
 | 
			
		||||
     {
 | 
			
		||||
		hak_bch_t val[256];
 | 
			
		||||
		hak_oow_t len;
 | 
			
		||||
	} tgt;
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
	#else
 | 
			
		||||
		*synerr = hak->c->synerr;
 | 
			
		||||
	#endif
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hak_getusynerr (hak_t* hak, hak_usynerr_t* synerr)
 | 
			
		||||
void hak_getsynerru (hak_t* hak, hak_synerru_t* synerr)
 | 
			
		||||
{
 | 
			
		||||
	HAK_ASSERT(hak, hak->c != HAK_NULL);
 | 
			
		||||
	if (synerr)
 | 
			
		||||
@ -708,6 +688,20 @@ void hak_getusynerr (hak_t* hak, hak_usynerr_t* synerr)
 | 
			
		||||
	#if defined(HAK_OOCH_IS_UCH)
 | 
			
		||||
		*synerr = hak->c->synerr;
 | 
			
		||||
	#else
 | 
			
		||||
		hak_synerr_t* s;
 | 
			
		||||
		hak_oow_t wcslen, mbslen;
 | 
			
		||||
 | 
			
		||||
		s = &hak->c->synerr;
 | 
			
		||||
		HAK_MEMSET(synerr, 0, HAK_SIZEOF(*synerr));
 | 
			
		||||
		synerr->num = s->num;
 | 
			
		||||
		synerr->loc.line = s->loc.line;
 | 
			
		||||
		synerr->loc.colm = s->loc.colm;
 | 
			
		||||
		if (s->loc.file)
 | 
			
		||||
		{
 | 
			
		||||
			wcslen = HAK_COUNTOF(hak->errmsg.xerrlocfile);
 | 
			
		||||
			hak_conv_bcstr_to_ucstr_with_cmgr(s->loc.file, &mbslen, hak->errmsg.xerrlocfile, &wcslen, hak->_cmgr);
 | 
			
		||||
			synerr->loc.file = hak->errmsg.xerrlocfile; /* this can be truncated and is transient */
 | 
			
		||||
		}
 | 
			
		||||
	#endif
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -757,24 +751,6 @@ void hak_setsynerrbfmt (hak_t* hak, hak_synerrnum_t num, const hak_loc_t* loc, c
 | 
			
		||||
	{
 | 
			
		||||
		hak->c->synerr.loc = hak->c->tok.loc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (tgt)
 | 
			
		||||
	{
 | 
			
		||||
		hak_oow_t n;
 | 
			
		||||
		n = hak_copy_oochars_to_oocstr(hak->c->synerr.tgt.val, HAK_COUNTOF(hak->c->synerr.tgt.val), tgt->ptr, tgt->len);
 | 
			
		||||
		if (n < tgt->len)
 | 
			
		||||
		{
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 1] = '.';
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 2] = '.';
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 3] = '.';
 | 
			
		||||
		}
 | 
			
		||||
		hak->c->synerr.tgt.len = n;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak->c->synerr.tgt.val[0] = '\0';
 | 
			
		||||
		hak->c->synerr.tgt.len = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hak_setsynerrufmt (hak_t* hak, hak_synerrnum_t num, const hak_loc_t* loc, const hak_oocs_t* tgt, const hak_uch_t* msgfmt, ...)
 | 
			
		||||
@ -816,23 +792,5 @@ void hak_setsynerrufmt (hak_t* hak, hak_synerrnum_t num, const hak_loc_t* loc, c
 | 
			
		||||
	{
 | 
			
		||||
		hak->c->synerr.loc = hak->c->tok.loc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (tgt)
 | 
			
		||||
	{
 | 
			
		||||
		hak_oow_t n;
 | 
			
		||||
		n = hak_copy_oochars_to_oocstr(hak->c->synerr.tgt.val, HAK_COUNTOF(hak->c->synerr.tgt.val), tgt->ptr, tgt->len);
 | 
			
		||||
		if (n < tgt->len)
 | 
			
		||||
		{
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 1] = '.';
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 2] = '.';
 | 
			
		||||
			hak->c->synerr.tgt.val[n - 3] = '.';
 | 
			
		||||
		}
 | 
			
		||||
		hak->c->synerr.tgt.len = n;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak->c->synerr.tgt.val[0] = '\0';
 | 
			
		||||
		hak->c->synerr.tgt.len = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										38
									
								
								lib/hak.h
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								lib/hak.h
									
									
									
									
									
								
							@ -1621,48 +1621,38 @@ typedef struct hak_sem_tuple_t hak_sem_tuple_t;
 | 
			
		||||
/* =========================================================================
 | 
			
		||||
 * HAK VM
 | 
			
		||||
 * ========================================================================= */
 | 
			
		||||
/*
 | 
			
		||||
typedef struct hak_synerr_t hak_synerr_t;
 | 
			
		||||
struct hak_synerr_t
 | 
			
		||||
{
 | 
			
		||||
	hak_synerrnum_t num;
 | 
			
		||||
	hak_loc_t       loc;
 | 
			
		||||
	struct
 | 
			
		||||
	{
 | 
			
		||||
		hak_ooch_t val[256];
 | 
			
		||||
		hak_oow_t  len;
 | 
			
		||||
	} tgt;
 | 
			
		||||
};
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
typedef struct hak_bsynerr_t hak_bsynerr_t;
 | 
			
		||||
struct hak_bsynerr_t
 | 
			
		||||
typedef struct hak_synerrb_t hak_synerrb_t;
 | 
			
		||||
struct hak_synerrb_t
 | 
			
		||||
{
 | 
			
		||||
	hak_synerrnum_t num;
 | 
			
		||||
	hak_bloc_t      loc;
 | 
			
		||||
/*
 | 
			
		||||
	struct
 | 
			
		||||
	{
 | 
			
		||||
		hak_bch_t val[256];
 | 
			
		||||
		hak_oow_t len;
 | 
			
		||||
	} tgt;
 | 
			
		||||
*/
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct hak_usynerr_t hak_usynerr_t;
 | 
			
		||||
struct hak_usynerr_t
 | 
			
		||||
typedef struct hak_synerru_t hak_synerru_t;
 | 
			
		||||
struct hak_synerru_t
 | 
			
		||||
{
 | 
			
		||||
	hak_synerrnum_t num;
 | 
			
		||||
	hak_uloc_t      loc;
 | 
			
		||||
/*
 | 
			
		||||
	struct
 | 
			
		||||
	{
 | 
			
		||||
		hak_uch_t val[256];
 | 
			
		||||
		hak_oow_t len;
 | 
			
		||||
	} tgt;
 | 
			
		||||
*/
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if defined(HAK_OOCH_IS_UCH)
 | 
			
		||||
typedef hak_usynerr_t hak_synerr_t;
 | 
			
		||||
typedef hak_synerru_t hak_synerr_t;
 | 
			
		||||
#else
 | 
			
		||||
typedef hak_bsynerr_t hak_synerr_t;
 | 
			
		||||
typedef hak_synerrb_t hak_synerr_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef struct hak_dbgi_t hak_dbgi_t;
 | 
			
		||||
@ -2739,14 +2729,14 @@ static HAK_INLINE hak_ooi_t hak_getip (hak_t* hak) { return hak->ip; }
 | 
			
		||||
/* =========================================================================
 | 
			
		||||
 * SYNTAX ERROR HANDLING
 | 
			
		||||
 * ========================================================================= */
 | 
			
		||||
HAK_EXPORT void hak_getbsynerr (
 | 
			
		||||
HAK_EXPORT void hak_getsynerrb (
 | 
			
		||||
	hak_t*             hak,
 | 
			
		||||
	hak_bsynerr_t*     synerr
 | 
			
		||||
	hak_synerrb_t*     synerr
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
HAK_EXPORT void hak_getusynerr (
 | 
			
		||||
HAK_EXPORT void hak_getsynerru (
 | 
			
		||||
	hak_t*             hak,
 | 
			
		||||
	hak_usynerr_t*     synerr
 | 
			
		||||
	hak_synerru_t*     synerr
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
HAK_EXPORT void hak_getsynerr (
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										80
									
								
								lib/read.c
									
									
									
									
									
								
							
							
						
						
									
										80
									
								
								lib/read.c
									
									
									
									
									
								
							@ -1236,7 +1236,8 @@ static int chain_to_list (hak_t* hak, hak_cnode_t* obj, hak_loc_t* loc)
 | 
			
		||||
		 * can only be triggered by a wrong qlist where a period is
 | 
			
		||||
		 * allowed. so i can safely hard-code the error code to
 | 
			
		||||
		 * HAK_SYNERR_RPAREN */
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_RPAREN, TOKEN_LOC(hak), HAK_NULL, ") expected around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_RPAREN, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			") expected around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	else if (flagv & DOTTED)
 | 
			
		||||
@ -1525,7 +1526,8 @@ static int auto_forge_xlist_if_at_block_beginning (hak_t* hak, hak_frd_t* frd)
 | 
			
		||||
		/* this portion is similar to the code below the start_list label */
 | 
			
		||||
		if (frd->level >= HAK_TYPE_MAX(int)) /* the nesting level too deep */
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerr(hak, HAK_SYNERR_NESTING, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_NESTING, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
				"nesting level too deep around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -1701,20 +1703,23 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
		if (TOKEN_TYPE(hak) == HAK_TOK_EOL) goto ok; /* ignore EOL inside vlist */
 | 
			
		||||
 | 
			
		||||
		/* vlist also has special requirement that it can only contain variable names. */
 | 
			
		||||
		hak_setsynerr(hak, HAK_SYNERR_VARNAME, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_VARNAME, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid variable name '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch (TOKEN_TYPE(hak))
 | 
			
		||||
	{
 | 
			
		||||
		default:
 | 
			
		||||
			hak_setsynerr(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
				"illegal token '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
			goto oops;
 | 
			
		||||
 | 
			
		||||
		case HAK_TOK_EOF:
 | 
			
		||||
			if (hak_feedpending(hak))
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_EOF, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_EOF, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"premature end of input '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
@ -1759,8 +1764,9 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
				 */
 | 
			
		||||
				if (hak->c->r.st && (hak->c->r.st->flagv & DATA_LIST))
 | 
			
		||||
				{
 | 
			
		||||
					/* if the outer list is a data list */
 | 
			
		||||
					hak_setsynerr(hak, HAK_SYNERR_VBARBANNED, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
					/* if the outer list is a data list e.g. ${ | a | } */
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_VBARBANNED, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
						"prohibited vertical bar around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
					goto oops;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@ -1849,7 +1855,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
			if (frd->level >= HAK_TYPE_MAX(int))
 | 
			
		||||
			{
 | 
			
		||||
				/* the nesting level has become too deep */
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_NESTING, TOKEN_LOC(hak), TOKEN_NAME(hak));
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_NESTING, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"nesting level too deep around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -1869,7 +1876,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
				 *   1. at the top frd->level - not inside ()
 | 
			
		||||
				 *   2. at the beginning of a list
 | 
			
		||||
				 *   3. inside an array, byte-array, dictionary, xlist */
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_DOTBANNED, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_DOTBANNED, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"prohibited dot around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
			goto ok;
 | 
			
		||||
@ -1879,7 +1887,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
			int n;
 | 
			
		||||
			if (frd->level <= 0 || !(n = can_colon_list(hak)))
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_COLONBANNED, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_COLONBANNED, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"prohibited colon around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
			if (n == 2)
 | 
			
		||||
@ -1896,7 +1905,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
		case HAK_TOK_COLONEQ:
 | 
			
		||||
			if (frd->level <= 0 || !can_coloneq_list(hak))
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_COLONEQBANNED, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_COLONEQBANNED, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"prohibited assignment around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
			goto ok;
 | 
			
		||||
@ -1928,7 +1938,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
		case HAK_TOK_COMMA:
 | 
			
		||||
			if (frd->level <= 0 || !can_comma_list(hak))
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_COMMABANNED, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_COMMABANNED, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"prohibited comma around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
			goto ok;
 | 
			
		||||
@ -1952,7 +1963,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
				if (TOKEN_TYPE(hak) == HAK_TOK_EOL) goto ok;
 | 
			
		||||
				if (concode == HAK_CONCODE_BLOCK) goto ok;
 | 
			
		||||
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_SEMICOLON, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_SEMICOLON, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"unexpected semicolon '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -1985,7 +1997,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
 | 
			
		||||
			if (frd->level <= 0)
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerr(hak, HAK_SYNERR_UNBALPBB, TOKEN_LOC(hak), HAK_NULL);
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_UNBALPBB, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"unbalanced closer token '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -1996,7 +2009,8 @@ static int feed_process_token (hak_t* hak)
 | 
			
		||||
				{
 | 
			
		||||
				#if 0
 | 
			
		||||
					/* the auto-forged list has not been terminated. it must be terminated closed first */
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_SEMICOLON, TOKEN_LOC(hak), TOKEN_NAME(hak), "semicolon expected");
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_SEMICOLON, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
						"semicolon expected around %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
					goto oops;
 | 
			
		||||
				#else
 | 
			
		||||
					/* if the expression inside {} is an auto-forged xlist expression and there is no semicolon provided,
 | 
			
		||||
@ -2617,7 +2631,8 @@ static int flx_backslashed (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
		return 1; /* consumed */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	hak_setsynerrbfmt(hak, HAK_SYNERR_BACKSLASH, TOKEN_LOC(hak), TOKEN_NAME(hak), "stray backslash");
 | 
			
		||||
	hak_setsynerrbfmt(hak, HAK_SYNERR_BACKSLASH, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
		"stray backslash around %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2733,7 +2748,7 @@ static int flx_dollared_ident (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
 | 
			
		||||
		if (get_directive_token_type(hak, &tok_type) <= -1)
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), TOKEN_NAME(hak),
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
				"invalid dollar-prefixed identifier '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
@ -2763,10 +2778,9 @@ static int flx_dollared_ident (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(
 | 
			
		||||
			hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid dollar-prefixed identifier character '%jc' after '%.*js'", c,
 | 
			
		||||
			TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid dollar-prefixed identifier character '%jc' after '%.*js'",
 | 
			
		||||
			c, TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -2887,7 +2901,7 @@ static int flx_hmarked_char (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
	{
 | 
			
		||||
		if (hc->char_count == 0)
 | 
			
		||||
		{
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), TOKEN_NAME(hak),
 | 
			
		||||
			hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
				"no valid character in character literal %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
@ -2904,7 +2918,7 @@ static int flx_hmarked_char (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
			hexcharlit:
 | 
			
		||||
				if (TOKEN_NAME_LEN(hak) - 3 > max_digit_count)
 | 
			
		||||
				{
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), TOKEN_NAME(hak),
 | 
			
		||||
					hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
						"invalid hexadecimal character character literal %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
					return -1;
 | 
			
		||||
				}
 | 
			
		||||
@ -2913,7 +2927,7 @@ static int flx_hmarked_char (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
				{
 | 
			
		||||
					if (!is_xdigit_char(TOKEN_NAME_CHAR(hak, i)))
 | 
			
		||||
					{
 | 
			
		||||
						hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), TOKEN_NAME(hak),
 | 
			
		||||
						hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
							"invalid hexadecimal character character literal %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
						return -1;
 | 
			
		||||
					}
 | 
			
		||||
@ -2946,7 +2960,7 @@ static int flx_hmarked_char (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
			else if (does_token_name_match(hak, VOCA_CHAR_VTAB))      c = '\v';
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), TOKEN_NAME(hak),
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_CHARLIT, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"invalid character literal %.*js", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
@ -3020,8 +3034,7 @@ static int flx_hmarked_binop (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_SYMLIT,
 | 
			
		||||
			TOKEN_LOC(hak), HAK_NULL /* no token name as incomplete */,
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_SYMLIT, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid binary selector character '%jc' after #%.*js",
 | 
			
		||||
			c, TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		return -1;
 | 
			
		||||
@ -3070,10 +3083,9 @@ static int flx_hmarked_ident (hak_t* hak, hak_ooci_t c)
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(
 | 
			
		||||
			hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid symbol character '%jc' after '%.*js'", c,
 | 
			
		||||
			TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid symbol character '%jc' after '%.*js'",
 | 
			
		||||
			c, TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -3148,7 +3160,8 @@ static int flx_plain_ident (hak_t* hak, hak_ooci_t c) /* identifier */
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), TOKEN_NAME(hak), "wrong multi-segment identifier");
 | 
			
		||||
				hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
					"wrong multi-segment identifier '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -3186,8 +3199,7 @@ static int flx_plain_ident (hak_t* hak, hak_ooci_t c) /* identifier */
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		hak_setsynerrbfmt(
 | 
			
		||||
			hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
		hak_setsynerrbfmt(hak, HAK_SYNERR_ILTOK, TOKEN_LOC(hak), HAK_NULL,
 | 
			
		||||
			"invalid identifier character '%jc' after '%.*js'", c,
 | 
			
		||||
			TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										48
									
								
								pas/hak.pas
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								pas/hak.pas
									
									
									
									
									
								
							@ -105,34 +105,36 @@ type
 | 
			
		||||
		function Read(): System.SizeUint; virtual; abstract;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	Location = record
 | 
			
		||||
	LocationB = record
 | 
			
		||||
		line: System.SizeUint;
 | 
			
		||||
		colm: System.SizeUint;
 | 
			
		||||
		filp: PBchar;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	LocationU = record
 | 
			
		||||
		line: System.SizeUint;
 | 
			
		||||
		colm: System.SizeUint;
 | 
			
		||||
		filp: PUchar;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	SynerrPtr = ^Synerr;
 | 
			
		||||
	Synerr = record
 | 
			
		||||
	SynerrBPtr = ^SynerrB;
 | 
			
		||||
	SynerrB = record
 | 
			
		||||
		num: integer;
 | 
			
		||||
		loc: Location;
 | 
			
		||||
		tgt: record
 | 
			
		||||
			val: array[0..255] of Uchar;
 | 
			
		||||
			len: System.SizeUint;
 | 
			
		||||
		end;
 | 
			
		||||
		loc: LocationB;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	ErrbinfPtr = ^Errbinf;
 | 
			
		||||
	Errbinf = record
 | 
			
		||||
		num: integer;
 | 
			
		||||
		msg: array[0..2047] of Bchar;
 | 
			
		||||
		loc: Location;
 | 
			
		||||
		loc: LocationB;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	ErruinfPtr = ^Errbinf;
 | 
			
		||||
	Erruinf = record
 | 
			
		||||
		num: integer;
 | 
			
		||||
		msg: array[0..2047] of Uchar;
 | 
			
		||||
		loc: Location;
 | 
			
		||||
		loc: LocationU;
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	Errinf = Erruinf;
 | 
			
		||||
@ -174,7 +176,7 @@ function hak_compile(handle: pointer; cnode: pointer; flags: integer): integer;
 | 
			
		||||
function hak_execute(handle: pointer): pointer; cdecl; external;
 | 
			
		||||
procedure hak_abort(handle: pointer) cdecl; external;
 | 
			
		||||
 | 
			
		||||
procedure hak_getsynerr(handle: pointer; synerr: SynerrPtr) cdecl; external;
 | 
			
		||||
procedure hak_getsynerrb(handle: pointer; synerr: SynerrBPtr) cdecl; external;
 | 
			
		||||
function hak_syserrstrb(handle: pointer; syserr_type: integer; syserr_code: integer; buf: PBchar; len: System.SizeUint): integer; cdecl; external;
 | 
			
		||||
function hak_count_ucstr(ptr: PUchar): System.SizeUint; cdecl; external;
 | 
			
		||||
(*----- end external hak function -----*)
 | 
			
		||||
@ -275,30 +277,16 @@ function Interp.FetchErrorMsg(): string;
 | 
			
		||||
var
 | 
			
		||||
	num: integer;
 | 
			
		||||
	bmsg: PBchar;
 | 
			
		||||
	serr: Synerr;
 | 
			
		||||
	filp: PUchar;
 | 
			
		||||
	(*tgt: array[0..255] of Uchar;*)
 | 
			
		||||
	tgt: string;
 | 
			
		||||
	serr: SynerrB;
 | 
			
		||||
	filp: PBchar;
 | 
			
		||||
begin
 | 
			
		||||
	num := hak_geterrnum(self.handle);
 | 
			
		||||
	if hak_errnum_is_synerr(num) then begin
 | 
			
		||||
		hak_getsynerr(self.handle, @serr);
 | 
			
		||||
		bmsg := hak_geterrbmsg(self.handle);
 | 
			
		||||
		filp := PUchar(WideString(''));
 | 
			
		||||
		hak_getsynerrb(self.handle, @serr);
 | 
			
		||||
		filp := PBchar('');
 | 
			
		||||
		if serr.loc.filp <> nil then filp := serr.loc.filp;
 | 
			
		||||
		if serr.tgt.len > 0 then begin
 | 
			
		||||
{$if defined(HAK_WIDE_CHAR_SIZE_IS_4)}
 | 
			
		||||
			tgt := System.UTF8Encode(PUCS4CharToWideString(serr.tgt.val));
 | 
			
		||||
{$elseif defined(HAK_WIDE_CHAR_SIZE_IS_2)}
 | 
			
		||||
			tgt := System.UTF8Encode(serr.tgt.val);
 | 
			
		||||
{$else}
 | 
			
		||||
			tgt := string(serr.tgt.val);
 | 
			
		||||
{$endif}
 | 
			
		||||
			exit(SysUtils.Format('%s at %s[%u:%u] - %s', [string(bmsg), string(filp), serr.loc.line, serr.loc.colm, tgt]));
 | 
			
		||||
		end
 | 
			
		||||
		else begin
 | 
			
		||||
			exit(SysUtils.Format('%s at %s[%u:%u]', [string(bmsg), string(filp), serr.loc.line, serr.loc.colm]));
 | 
			
		||||
		end;
 | 
			
		||||
		exit(SysUtils.Format('%s at %s[%u:%u]', [string(bmsg), string(filp), serr.loc.line, serr.loc.colm]));
 | 
			
		||||
	end
 | 
			
		||||
	else begin
 | 
			
		||||
		bmsg := hak_geterrbmsg(self.handle);
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ var
 | 
			
		||||
begin
 | 
			
		||||
	(* System.ParamCount() returns only the number of argumetns except System.ParamStr(0). It is the upper bound to System.ParamStr(). *)
 | 
			
		||||
	if System.ParamCount() <> 1 then begin
 | 
			
		||||
		writeln (System.Stderr, SysUtils.Format('Usage: %s <filename>', [SysUtils.ExtractFileName(System.ParamStr(0))]));
 | 
			
		||||
		writeln(System.Stderr, SysUtils.Format('Usage: %s <filename>', [SysUtils.ExtractFileName(System.ParamStr(0))]));
 | 
			
		||||
		System.Halt(-1);
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
@ -34,10 +34,10 @@ begin
 | 
			
		||||
		x.Execute(); // check if exception...
 | 
			
		||||
	except
 | 
			
		||||
		on e: Exception do
 | 
			
		||||
			writeln ('exception: ', e.Message);
 | 
			
		||||
			writeln('exception: ', e.Message);
 | 
			
		||||
		else
 | 
			
		||||
			writeln ('unknonw exception');
 | 
			
		||||
			writeln('unknonw exception');
 | 
			
		||||
	end;
 | 
			
		||||
 | 
			
		||||
	if x <> nil then x.Destroy();
 | 
			
		||||
end.
 | 
			
		||||
end.
 | 
			
		||||
 | 
			
		||||
@ -95,7 +95,7 @@ t1 := (B:newA) ##ERROR: exception not handled - "unable to send newA to B - 'new
 | 
			
		||||
 | 
			
		||||
class B {
 | 
			
		||||
	var x
 | 
			
		||||
	if (x > 0) { ##ERROR: syntax error - prohibited access to instance variable - x
 | 
			
		||||
	if (x > 0) { ##ERROR: syntax error - prohibited access to instance variable around 'x'
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,7 @@ x := (10 +); ##ERROR: syntax error - no operand after binary selector
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
## you can't have another colon before the method..
 | 
			
		||||
(obj: :method) ##ERROR: syntax error - : disallowed
 | 
			
		||||
(obj: :method) ##ERROR: syntax error - prohibited colon around ':'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
@ -162,15 +162,15 @@ abc. := 20 ##ERROR: syntax error - blank segment after 'abc.'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
abc.? := 20 ##ERROR: syntax error - wrong multi-segment identifier - abc.?
 | 
			
		||||
abc.? := 20 ##ERROR: syntax error - wrong multi-segment identifier 'abc.?'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
- := 20 ##ERROR: syntax error - bad lvalue - invalid identifier - -
 | 
			
		||||
- := 20 ##ERROR: syntax error - bad lvalue - invalid identifier '-'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
+++ := 20 ##ERROR: syntax error - bad lvalue - invalid identifier - +++
 | 
			
		||||
+++ := 20 ##ERROR: syntax error - bad lvalue - invalid identifier '+++'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -58,12 +58,12 @@ class A ( + ) { ##ERROR: syntax error - not variable name '+'
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
fun xxx(x :: p q) { p := (x + 1); q := (x + 2) }
 | 
			
		||||
[a,[b]] := (xxx 20) ##ERROR: syntax error - bad lvalue - invalid identifier in tuple
 | 
			
		||||
[a,[b]] := (xxx 20) ##ERROR: syntax error - bad lvalue - invalid token in tuple
 | 
			
		||||
printf "%d %d\n" a b
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
20 := 90 ##ERROR: syntax error - bad lvalue - invalid identifier - 20
 | 
			
		||||
20 := 90 ##ERROR: syntax error - bad lvalue - invalid identifier '20'
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@ fun x (... a) { ##ERROR: syntax error - unexpected token 'a' after '...' for 'fu
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
fun x (... : a) { ##ERROR: syntax error - : disallowed
 | 
			
		||||
fun x (... : a) { ##ERROR: syntax error - prohibited colon around ':'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user