namespace axl::lex

namespace lex {

// typedefs

typedef RagelToken<int, StdTokenData> StdRagelToken;

// enums

enum ParseErrorCode;
enum TokenChannelMask;

// structs

struct LineCol;
struct LineColOffset;
struct SrcPos;
struct StdTokenData;

template <
    typename TokenKind0,
    typename Name0,
    typename Data0 = StdTokenData,
    typename Pos0 = LineCol
    >
struct Token;

// classes

template <
    typename T,
    typename Token0
    >
class Lexer;

class ParseErrorProvider;
class Ragel;

template <
    typename T,
    typename Token = StdRagelToken
    >
class RagelLexer;

template <
    typename Enum,
    typename GetName,
    typename Data = StdTokenData
    >
class RagelToken;

class RagelTokenPos;

// global functions

AXL_SL_DEFINE_GUID(
    g_parseErrorGuid,
    0x56fc601e,
    0x5d2c,
    0x4bbe,
    0xb4,
    0x55,
    0x3d,
    0x8b,
    0x81,
    0xaa,
    0xd8,
    0xff
    );

void
registerParseErrorProvider();

size_t
pushSrcPosError(
    const sl::StringRef& filePath,
    int line,
    int col = 0
    );

size_t
pushSrcPosError(
    const sl::StringRef& filePath,
    const LineCol& lineCol
    );

size_t
pushSrcPosError(const SrcPos& srcPos);

bool
isSrcPosError(const err::ErrorHdr* error);

void
decodeSrcPosError(
    sl::StringRef* filePath,
    LineCol* lineCol,
    const err::ErrorHdr* error
    );

void
decodeSrcPosError(
    LineCol* lineCol,
    const err::ErrorHdr* error
    );

void
decodeSrcPosError(
    SrcPos* srcPos,
    const err::ErrorHdr* error
    );

bool
isLastSrcPosError();

void
ensureSrcPosError(
    const sl::StringRef& filePath,
    int line,
    int col = 0
    );

void
ensureSrcPosError(
    const sl::StringRef& filePath,
    const LineCol& lineCol
    );

void
ensureSrcPosError(const SrcPos& srcPos);

size_t
setSyntaxError();

size_t
setSyntaxError(const sl::StringRef& location);

size_t
setExpectedTokenError(
    const sl::StringRef& expectedToken,
    const sl::StringRef& actualToken
    );

size_t
setUnexpectedTokenError(const sl::StringRef& token);

size_t
setUnexpectedTokenError(
    const sl::StringRef& token,
    const sl::StringRef& location
    );

} // namespace lex