summaryrefslogtreecommitdiff
path: root/src/parse/parseerror.hpp
blob: 50ec19fffee758c968f45defbe4a29ccd4091a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef PARSEERROR_HPP_INCLUDED
#define PARSEERROR_HPP_INCLUDED

#include <stdexcept>
#include "lex.hpp"

namespace ParseError {

using CompileError::Generic;
using CompileError::BugCheck;
using CompileError::Todo;

class BadChar:
    public CompileError::Base
{
    char    m_char;
public:
    BadChar(char character);
    virtual ~BadChar() throw ();

};

class Unexpected:
    public CompileError::Base
{
    Token   m_tok;
public:
    Unexpected(const TokenStream& lex, Token tok);
    Unexpected(const TokenStream& lex, Token tok, Token exp);
    virtual ~Unexpected() throw ();

};

#define ASSERT(lex, cnd)    do { if( !(cnd) ) throw CompileError::BugCheck(lex, "Assertion failed: "#cnd); } while(0)

}

#endif // PARSEERROR_HPP_INCLUDED