Rewrote preprocesser API
This C++ rewrite allows me to rewrite the actual API of the system. In particular, I'm no longer restricting myself to just using enums then figuring out a way to get proper error logging later down the line (through tracking tokens in the buffer internally, for example). Instead I can now design error structures which hold references to the token they occurred on as well as possible lexical errors (if they're a FILE_LEXICAL_ERROR which occurs due to the ~%USE~ macro). This means it's a lot easier to write error logging now at the top level.
This commit is contained in:
@@ -12,11 +12,12 @@
|
|||||||
#ifndef PREPROCESSER_HPP
|
#ifndef PREPROCESSER_HPP
|
||||||
#define PREPROCESSER_HPP
|
#define PREPROCESSER_HPP
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "./lexer.hpp"
|
#include "./lexer.hpp"
|
||||||
|
|
||||||
enum pp_err_t
|
enum pp_err_type_t
|
||||||
{
|
{
|
||||||
OK = 0,
|
OK = 0,
|
||||||
EXPECTED_NAME,
|
EXPECTED_NAME,
|
||||||
@@ -27,13 +28,30 @@ enum pp_err_t
|
|||||||
UNKNOWN_NAME,
|
UNKNOWN_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::pair<std::vector<token_t>, pp_err_t>
|
struct pp_err_t
|
||||||
preprocesser(const std::vector<token_t> &);
|
{
|
||||||
|
const token_t *reference;
|
||||||
|
pp_err_type_t type;
|
||||||
|
lerr_t lerr;
|
||||||
|
|
||||||
std::pair<std::vector<token_t>, pp_err_t>
|
pp_err_t(pp_err_type_t);
|
||||||
preprocess_macro_blocks(const std::vector<token_t> &);
|
pp_err_t(pp_err_type_t, const token_t *);
|
||||||
|
pp_err_t(pp_err_type_t, const token_t *, lerr_t);
|
||||||
|
};
|
||||||
|
|
||||||
std::pair<std::vector<token_t>, pp_err_t>
|
std::ostream &operator<<(std::ostream &, pp_err_t &);
|
||||||
preprocess_use_blocks(const std::vector<token_t> &);
|
|
||||||
|
std::pair<std::vector<token_t *>, pp_err_t>
|
||||||
|
preprocesser(std::vector<token_t *> &);
|
||||||
|
|
||||||
|
std::pair<std::vector<token_t *>, pp_err_t>
|
||||||
|
preprocess_const_blocks(std::vector<token_t *> &);
|
||||||
|
|
||||||
|
std::pair<std::vector<token_t *>, pp_err_t>
|
||||||
|
preprocess_use_blocks(std::vector<token_t *> &);
|
||||||
|
|
||||||
|
// TODO: Implement this
|
||||||
|
std::pair<std::vector<token_t *>, pp_err_t>
|
||||||
|
preprocess_macro_blocks(std::vector<token_t *> &);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user