Starting to stand up the parser using std::pair

This commit is contained in:
Jonathan Turner
2009-05-26 22:39:55 +00:00
parent 8f6f4b81db
commit 6a608f995a
4 changed files with 64 additions and 21 deletions

View File

@@ -11,7 +11,18 @@
typedef std::vector<Token>::iterator Token_Iterator;
struct Rule {
boost::function<Token_Iterator(Token_Iterator iter, Token_Iterator end)> rule;
int identifier;
boost::function<std::pair<Token_Iterator, Token>(Token_Iterator iter, Token_Iterator end)> rule;
std::pair<Token_Iterator, Token> operator()(Token_Iterator iter, Token_Iterator end);
Rule() : identifier(-1) {}
Rule(int id) : identifier(id) {}
};
std::pair<Token_Iterator, Token> String_Rule(Token_Iterator iter, Token_Iterator end, const std::string &val);
std::pair<Token_Iterator, Token> Type_Rule(Token_Iterator iter, Token_Iterator end, const int val);
std::pair<Token_Iterator, Token> Or_Rule(Token_Iterator iter, Token_Iterator end, const Rule &lhs, const Rule &rhs);
#endif /* LANGKIT_PARSER_HPP_ */