// This file is distributed under the BSD License. // See LICENSE.TXT for details. #ifndef LANGKIT_PARSER_HPP_ #define LANGKIT_PARSER_HPP_ #include #include "langkit_lexer.hpp" typedef std::vector::iterator Token_Iterator; struct Rule { int identifier; boost::function(Token_Iterator iter, Token_Iterator end, TokenPtr parent)> rule; std::pair operator()(Token_Iterator iter, Token_Iterator end, TokenPtr parent); Rule() : identifier(-1) {} Rule(int id) : identifier(id) {} }; std::pair String_Rule (Token_Iterator iter, Token_Iterator end, TokenPtr parent, const std::string &val, bool keep); std::pair Type_Rule (Token_Iterator iter, Token_Iterator end, TokenPtr parent, const int val, bool keep); std::pair Or_Rule (Token_Iterator iter, Token_Iterator end, TokenPtr parent, const Rule &lhs, const Rule &rhs, bool keep, int new_id); std::pair And_Rule (Token_Iterator iter, Token_Iterator end, TokenPtr parent, const Rule &lhs, const Rule &rhs, bool keep, int new_id); #endif /* LANGKIT_PARSER_HPP_ */