40 lines
1004 B
C++
40 lines
1004 B
C++
/// AUTOGENERATED COPYRIGHT HEADER START
|
|
// Copyright (C) 2017-2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
|
#pragma once
|
|
#include "lexer.hpp"
|
|
#include "ast/ast.hpp"
|
|
#include "ast/value.hpp"
|
|
#include <fstream>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <stack>
|
|
|
|
namespace blitz {
|
|
class parser {
|
|
public:
|
|
parser(std::string file);
|
|
~parser();
|
|
|
|
std::unique_ptr<ast::expression> parse();
|
|
|
|
protected:
|
|
void log(const char* msg, ...);
|
|
void log_error(const char* msg, ...);
|
|
|
|
private:
|
|
std::pair<blitz::lexer::tokentype, std::string> next();
|
|
|
|
private:
|
|
std::unique_ptr<ast::expression> parse_expression();
|
|
std::unique_ptr<ast::NumberExpression> parse_number(blitz::lexer::tokentype token, std::string value);
|
|
std::unique_ptr<ast::DecimalExpression> parse_decimal(blitz::lexer::tokentype token, std::string value);
|
|
|
|
private:
|
|
lexer m_lexer;
|
|
std::stack<std::pair<std::string, std::shared_ptr<std::istream>>> m_files;
|
|
|
|
};
|
|
}
|