/*	Copyright  (c)	Günter Woigk 2010 - 2021
					mailto:kio@little-bat.de

	This file is free software.

	Permission to use, copy, modify, distribute, and sell this software
	and its documentation for any purpose is hereby granted without fee,
	provided that the above copyright notice appears in all copies and
	that both that copyright notice, this permission notice and the
	following disclaimer appear in supporting documentation.

	THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY,
	NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
	A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE COPYRIGHT HOLDER
	BE LIABLE FOR ANY DAMAGES ARISING FROM THE USE OF THIS SOFTWARE,
	TO THE EXTENT PERMITTED BY APPLICABLE LAW.
*/

#pragma once
#include "kio/kio.h"
#include "kio/exceptions.h"
#include "Templates/Array.h"
#include "types.h"


// ---------------------------------------------
//		compilation error base class
// ---------------------------------------------

class Error //: public RCObject
{
public:
	uint32 pos;		// offset in total source[]
	int	   err;
	cstr   msg;		// allocated

	Error (uint32 pos, int err);
	Error (cWord&, int err);
	Error (uint32 pos, int err, cstr fmt, ...)	__printflike(4,5);
	Error (cWord&, int err, cstr fmt, ...)		__printflike(4,5);
	Error (uint32 pos, const AnyError&);
	Error (cWord&, const AnyError&);
	~Error ();

	Error (cError&);
	Error (Error&&);
	Error& operator= (cError&);
	Error& operator= (Error&&);
};


// ---------------------------------------------
//		syntax error: count & resume
// ---------------------------------------------

class SyntaxError : public Error
{
public:
	SyntaxError(uint32 pos, cstr fmt, ...)		__printflike(3,4);
	SyntaxError(cWord& pos, cstr fmt, ...)		__printflike(3,4);
};


// ---------------------------------------------
//		warning: informational only
//		evtl. never thrown but always added to errors[] immediately
// ---------------------------------------------

class Warning : public Error
{
public:
	Warning(uint32 pos, cstr fmt, ...)			__printflike(3,4);
	Warning(cWord& pos, cstr fmt, ...)			__printflike(3,4);
};


// ---------------------------------------------
//		convenience: FileError
// ---------------------------------------------

class FileError : public Error
{
public:
	FileError (cWord&, int error, cstr filepath);
};































