This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues/pull-requests.
wongola/lib/Parser.hpp

59 lines
1.4 KiB
C++
Raw Normal View History

#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<Node> parse(std::vector<std::shared_ptr<Node>>
const& tokens);
private:
std::vector<std::shared_ptr<Node>> m_tokens;
size_t m_cursor;
Loc loc() const;
std::shared_ptr<Node> consume(NodeType type);
std::shared_ptr<Node> consume();
bool type_is(NodeType type, int lookahead=0);
bool type_isnt(NodeType type, int lookahead=0);
std::shared_ptr<Node> make_node(NodeType type) const;
std::shared_ptr<Node> parse_prog();
std::shared_ptr<Node> parse_instr();
std::shared_ptr<Node> parse_extern();
std::shared_ptr<Node> parse_fundecl();
std::shared_ptr<Node> parse_params();
std::shared_ptr<Node> parse_ret();
std::shared_ptr<Node> parse_block();
std::shared_ptr<Node> parse_dir();
std::shared_ptr<Node> parse_expr();
2023-09-29 18:11:39 +00:00
std::shared_ptr<Node> parse_or();
std::shared_ptr<Node> parse_and();
std::shared_ptr<Node> parse_eqne();
std::shared_ptr<Node> parse_cmp();
2023-09-27 21:05:04 +00:00
std::shared_ptr<Node> parse_addsub();
std::shared_ptr<Node> parse_muldivmod();
std::shared_ptr<Node> parse_literal();
std::shared_ptr<Node> parse_call();
std::shared_ptr<Node> parse_args();
2023-09-29 09:18:03 +00:00
std::shared_ptr<Node> parse_ns();
};
}
#endif