diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2014-11-22 23:36:20 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2014-11-22 23:36:20 +0800 |
commit | 7ad1a8b4b40784e0a10bd453c75dd0dcf123d5f1 (patch) | |
tree | 0172ed546bdb00e86297d8d36d7cb0a0a1d111f3 /parse/preproc.cpp | |
download | mrust-7ad1a8b4b40784e0a10bd453c75dd0dcf123d5f1.tar.gz |
Initial commit, lexer structurally complete, parsing hacking up
Diffstat (limited to 'parse/preproc.cpp')
-rw-r--r-- | parse/preproc.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/parse/preproc.cpp b/parse/preproc.cpp new file mode 100644 index 00000000..ec64d731 --- /dev/null +++ b/parse/preproc.cpp @@ -0,0 +1,50 @@ +#include "preproc.hpp"
+#include <iostream>
+
+Preproc::Preproc(::std::string path):
+ m_cache_valid(false),
+ m_lex(path)
+{
+ //ctor
+}
+
+Preproc::~Preproc()
+{
+ //dtor
+}
+
+Token Preproc::getTokenInt()
+{
+ while(true)
+ {
+ Token tok = m_lex.getToken();
+ ::std::cout << "getTokenInt: tok = " << tok << ::std::endl;
+ switch(tok.type())
+ {
+ case TOK_WHITESPACE:
+ continue;
+ case TOK_COMMENT:
+ continue;
+ default:
+ return tok;
+ }
+ }
+}
+
+Token Preproc::getToken()
+{
+ if( m_cache_valid )
+ {
+ m_cache_valid = false;
+ return m_cache;
+ }
+ else
+ {
+ return this->getTokenInt();
+ }
+}
+void Preproc::putback(Token tok)
+{
+ m_cache_valid = true;
+ m_cache = tok;
+}
|