blob: 950a204d0bb03f7b821b8796d0e5b4a8f62ed536 (
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
39
40
41
42
43
44
45
46
47
48
49
50
|
#ifndef PARSE_COMMON_HPP_INCLUDED
#define PARSE_COMMON_HPP_INCLUDED
#include <iostream>
#define GET_TOK(tok, lex) ((tok = lex.getToken()).type())
#define GET_CHECK_TOK(tok, lex, exp) do {\
if((tok = lex.getToken()).type() != exp) \
throw ParseError::Unexpected(lex, tok, Token(exp));\
} while(0)
#define CHECK_TOK(tok, exp) do {\
if(tok.type() != exp) \
throw ParseError::Unexpected(lex, tok, Token(exp));\
} while(0)
enum eParsePathGenericMode
{
PATH_GENERIC_NONE,
PATH_GENERIC_EXPR,
PATH_GENERIC_TYPE
};
extern AST::Path Parse_Path(TokenStream& lex, bool is_abs, eParsePathGenericMode generic_mode);
extern TypeRef Parse_Type(TokenStream& lex);
extern AST::Expr Parse_Expr(TokenStream& lex, bool const_only);
extern AST::Expr Parse_ExprBlock(TokenStream& lex);
class TraceLog
{
static unsigned int depth;
const char* m_tag;
public:
TraceLog(const char* tag): m_tag(tag) { indent(); ::std::cout << ">> " << m_tag << ::std::endl; }
~TraceLog() { outdent(); ::std::cout << "<< " << m_tag << ::std::endl; }
private:
void indent()
{
for(unsigned int i = 0; i < depth; i ++)
::std::cout << " ";
depth ++;
}
void outdent()
{
depth --;
for(unsigned int i = 0; i < depth; i ++)
::std::cout << " ";
}
};
#define TRACE_FUNCTION TraceLog _tf_(__func__)
#endif // PARSE_COMMON_HPP_INCLUDED
|