From e462669c3c3cc04ea29420e14dbb589899d201ec Mon Sep 17 00:00:00 2001 From: Teddy Date: Sat, 3 Aug 2013 12:10:09 +0800 Subject: AST parser can now work! --- parser.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 parser.h (limited to 'parser.h') diff --git a/parser.h b/parser.h new file mode 100644 index 0000000..065ed2a --- /dev/null +++ b/parser.h @@ -0,0 +1,32 @@ +#ifndef PARSER_H +#define PARSER_H + +#include "model.h" +#include + +using std::string; + +const int TOKEN_BUFF_SIZE = 65536; +const int PARSE_STACK_SIZE = 65536; + +class Tokenizor { + private: + FILE *stream; + char *buff_ptr; + public: + Tokenizor(); + void set_stream(FILE *stream); + bool get_token(string &ret); +}; + +class ASTGenerator { + private: + static EvalObj* to_float(const string &); + static EvalObj* to_int(const string &); + static EvalObj* to_obj(const string &); + public: + ASTGenerator(); + Cons *absorb(Tokenizor *tk); +}; + +#endif -- cgit v1.2.3