#ifndef fk_PARSER_HPP #define fk_PARSER_HPP #include "commons.hpp" #include "Lexer.hpp" namespace fk { FK_ERROR(syntax_error); class Parser { public: explicit Parser(Lexer& lexer); virtual ~Parser(); std::shared_ptr parse(std::string const& source); private: Lexer& m_lexer; std::vector> m_tokens; size_t m_cursor = 0; std::shared_ptr parse_module(); std::shared_ptr parse_expr(); std::shared_ptr parse_call(); std::shared_ptr parse_lambda(); std::shared_ptr parse_params(); std::shared_ptr parse_body(); std::shared_ptr parse_fundecl(); std::shared_ptr parse_vardecl(); std::shared_ptr parse_ns(); std::shared_ptr parse_import(); std::shared_ptr parse_short_import(); std::shared_ptr make_node(NodeType type); Loc loc() const; bool type_is(NodeType type) const; bool type_isnt(NodeType type) const; bool type_all(std::vector types) const; bool type_any(std::vector types) const; std::shared_ptr consume(); std::shared_ptr consume(NodeType type); }; } #endif