39 lines
761 B
C++
39 lines
761 B
C++
#ifndef RSQL_PARSER_PARSER_HPP
|
|
#define RSQL_PARSER_PARSER_HPP
|
|
|
|
#include "token.hpp"
|
|
#include "token_type.hpp"
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace matador::rsql {
|
|
class node;
|
|
|
|
class parser {
|
|
public:
|
|
explicit parser(std::vector<token> t);
|
|
|
|
std::shared_ptr<node> parse();
|
|
|
|
private:
|
|
// OR level
|
|
std::shared_ptr<node> parse_or_expression();
|
|
|
|
// AND level
|
|
std::shared_ptr<node> parse_and_expression();
|
|
|
|
// Primary: parenthesis or condition
|
|
std::shared_ptr<node> parse_primary();
|
|
std::shared_ptr<node> parse_condition();
|
|
|
|
bool match(const std::vector<token_type>& types);
|
|
|
|
const token& previous() const;
|
|
|
|
private:
|
|
std::vector<token> tokens_;
|
|
size_t current_size_ = 0;
|
|
};
|
|
}
|
|
#endif //RSQL_PARSER_PARSER_HPP
|