#ifndef wg_PARSER_HPP #define wg_PARSER_HPP #include "commons.hpp" #include "Node.hpp" namespace wg { WG_ERROR(syntax_error); class Parser { public: explicit Parser(); virtual ~Parser(); std::shared_ptr parse(std::vector> const& tokens); private: std::vector> m_tokens; size_t m_cursor; Loc loc() const; std::shared_ptr consume(NodeType type); std::shared_ptr consume(); bool type_is(NodeType type, int lookahead=0); bool type_isnt(NodeType type, int lookahead=0); std::shared_ptr make_node(NodeType type) const; std::shared_ptr parse_prog(); std::shared_ptr parse_instr(); std::shared_ptr parse_extern(); std::shared_ptr parse_fundecl(); std::shared_ptr parse_params(); std::shared_ptr parse_ret(); std::shared_ptr parse_block(); std::shared_ptr parse_dir(); std::shared_ptr parse_expr(); std::shared_ptr parse_addsub(); std::shared_ptr parse_muldivmod(); std::shared_ptr parse_literal(); std::shared_ptr parse_call(); std::shared_ptr parse_args(); }; } #endif