@@ -1,6 +1,7 @@
|
|||||||
#ifndef FURC_FRONT_PARSER_HPP
|
#ifndef FURC_FRONT_PARSER_HPP
|
||||||
#define FURC_FRONT_PARSER_HPP
|
#define FURC_FRONT_PARSER_HPP
|
||||||
|
|
||||||
|
#include "furc/ast/declaration.hpp"
|
||||||
#include "furc/ast/fwd.hpp"
|
#include "furc/ast/fwd.hpp"
|
||||||
#include "furc/front/lexer.hpp"
|
#include "furc/front/lexer.hpp"
|
||||||
#include "furlang/arena.hpp"
|
#include "furlang/arena.hpp"
|
||||||
@@ -56,6 +57,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
ast::program_node_r parse() &;
|
ast::program_node_r parse() &;
|
||||||
private:
|
private:
|
||||||
|
ast::type_r parse_type();
|
||||||
|
|
||||||
ast::declaration_node_r parse_declaration();
|
ast::declaration_node_r parse_declaration();
|
||||||
ast::statement_node_r parse_statement();
|
ast::statement_node_r parse_statement();
|
||||||
ast::expression_node_r parse_expression(std::uint32_t precedence = 16);
|
ast::expression_node_r parse_expression(std::uint32_t precedence = 16);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "furc/ast/literal.hpp" // IWYU pragma: keep
|
#include "furc/ast/literal.hpp" // IWYU pragma: keep
|
||||||
#include "furc/ast/program.hpp" // IWYU pragma: keep
|
#include "furc/ast/program.hpp" // IWYU pragma: keep
|
||||||
#include "furc/ast/statement.hpp" // IWYU pragma: keep
|
#include "furc/ast/statement.hpp" // IWYU pragma: keep
|
||||||
|
#include "furc/front/token.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -46,6 +47,13 @@ ast::program_node_r parser::parse() & {
|
|||||||
return program != nullptr ? std::move(program) : ast::program_node_r(ast::error{ location{ m_filename } });
|
return program != nullptr ? std::move(program) : ast::program_node_r(ast::error{ location{ m_filename } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ast::type_r parser::parse_type() {
|
||||||
|
auto token = eat_token(token_t::Keyword);
|
||||||
|
if (token.has_error() || token.value()->keyword != keyword_token::Int32)
|
||||||
|
return ast::type_r(ast::error{ token.error().location });
|
||||||
|
return ast::type("" + token.value()->keyword);
|
||||||
|
}
|
||||||
|
|
||||||
ast::declaration_node_r parser::parse_declaration() {
|
ast::declaration_node_r parser::parse_declaration() {
|
||||||
const auto& first = peek_token();
|
const auto& first = peek_token();
|
||||||
switch (first->type) {
|
switch (first->type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user