aboutsummaryrefslogtreecommitdiff
path: root/parser.h
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-04 09:40:43 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-04 09:40:43 +0800
commit9e834528d38a89eb4075b09b35fb7b6e7636740d (patch)
tree5826c2142c69b7c96515262fb4d3e9e6b0ed819c /parser.h
parentc66dc142d240ec2e2ae78201d9614de76535be38 (diff)
added more docs
Diffstat (limited to 'parser.h')
-rw-r--r--parser.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/parser.h b/parser.h
index 065ed2a..5c427ee 100644
--- a/parser.h
+++ b/parser.h
@@ -9,23 +9,41 @@ using std::string;
const int TOKEN_BUFF_SIZE = 65536;
const int PARSE_STACK_SIZE = 65536;
+/** @class Tokenizor
+ * Break down the input string stream into tokens
+ */
class Tokenizor {
private:
FILE *stream;
char *buff_ptr;
public:
Tokenizor();
+ /** Set the stream to be read from (without setting this, the default
+ * would be stdin) */
void set_stream(FILE *stream);
+ /** Extract the next token
+ * @param ret the extracted token
+ * @return false if nothing can be read further
+ * */
bool get_token(string &ret);
};
+/** @class ASTGenerator
+ * Read the tokens and build up an Abstract Syntax Tree (which is in effect a
+ * Cons)
+ */
class ASTGenerator {
private:
static EvalObj* to_float(const string &);
static EvalObj* to_int(const string &);
+ /** Convert the string to an internal object */
static EvalObj* to_obj(const string &);
public:
ASTGenerator();
+ /** Read tokens from Tokenizor tk, then return a AST
+ * @param tk pointer to a Tokenizor
+ * @return Abstract Syntax Tree
+ */
Cons *absorb(Tokenizor *tk);
};