diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2014-12-05 20:35:11 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2014-12-05 20:35:11 +0800 |
commit | 1ac5429531c195755c7e1690912291e20e9a1717 (patch) | |
tree | c3462e2d16ccb07fc022874d094d837bfdb1fc67 /parse/common.hpp | |
parent | 7f6170e7cb156bab7b5ac39b1abbe2c5f4e26204 (diff) | |
download | mrust-1ac5429531c195755c7e1690912291e20e9a1717.tar.gz |
Pattern and impl parsing working
Diffstat (limited to 'parse/common.hpp')
-rw-r--r-- | parse/common.hpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/parse/common.hpp b/parse/common.hpp index 211fadee..0d6d550b 100644 --- a/parse/common.hpp +++ b/parse/common.hpp @@ -1,5 +1,6 @@ #ifndef PARSE_COMMON_HPP_INCLUDED
-#define PARSEERROR_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 {\
@@ -11,9 +12,39 @@ throw ParseError::Unexpected(tok, Token(exp));\
} while(0)
-extern AST::Path Parse_Path(TokenStream& lex, bool is_abs, bool generic_ok);
+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
|