upd: set up file structure
This commit is contained in:
@ -2,18 +2,21 @@
|
||||
#ifndef PYTHON_INTERPRETER_EVALVISITOR_H
|
||||
#define PYTHON_INTERPRETER_EVALVISITOR_H
|
||||
|
||||
#include "Python3ParserBaseVisitor.h"
|
||||
#include "int2048/int2048.h"
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
class EvalVisitor : public Python3ParserBaseVisitor
|
||||
{
|
||||
#include "Python3ParserBaseVisitor.h"
|
||||
#include "int2048/int2048.h"
|
||||
#include "namescope.h"
|
||||
#include "utils.h"
|
||||
|
||||
class EvalVisitor : public Python3ParserBaseVisitor {
|
||||
// TODO: override all methods of Python3ParserBaseVisitor
|
||||
std::any visitFile_input(Python3Parser::File_inputContext *ctx) override;
|
||||
std::any visitFuncdef(Python3Parser::FuncdefContext *ctx) override;
|
||||
std::any visitParameters(Python3Parser::ParametersContext *ctx) override;
|
||||
std::any visitTypedargslist(Python3Parser::TypedargslistContext *ctx) override;
|
||||
std::any visitTypedargslist(
|
||||
Python3Parser::TypedargslistContext *ctx) override;
|
||||
std::any visitTfpdef(Python3Parser::TfpdefContext *ctx) override;
|
||||
std::any visitStmt(Python3Parser::StmtContext *ctx) override;
|
||||
std::any visitSimple_stmt(Python3Parser::Simple_stmtContext *ctx) override;
|
||||
@ -22,9 +25,11 @@ class EvalVisitor : public Python3ParserBaseVisitor
|
||||
std::any visitAugassign(Python3Parser::AugassignContext *ctx) override;
|
||||
std::any visitFlow_stmt(Python3Parser::Flow_stmtContext *ctx) override;
|
||||
std::any visitBreak_stmt(Python3Parser::Break_stmtContext *ctx) override;
|
||||
std::any visitContinue_stmt(Python3Parser::Continue_stmtContext *ctx) override;
|
||||
std::any visitContinue_stmt(
|
||||
Python3Parser::Continue_stmtContext *ctx) override;
|
||||
std::any visitReturn_stmt(Python3Parser::Return_stmtContext *ctx) override;
|
||||
std::any visitCompound_stmt(Python3Parser::Compound_stmtContext *ctx) override;
|
||||
std::any visitCompound_stmt(
|
||||
Python3Parser::Compound_stmtContext *ctx) override;
|
||||
std::any visitIf_stmt(Python3Parser::If_stmtContext *ctx) override;
|
||||
std::any visitWhile_stmt(Python3Parser::While_stmtContext *ctx) override;
|
||||
std::any visitSuite(Python3Parser::SuiteContext *ctx) override;
|
||||
@ -46,34 +51,26 @@ class EvalVisitor : public Python3ParserBaseVisitor
|
||||
std::any visitArglist(Python3Parser::ArglistContext *ctx) override;
|
||||
std::any visitArgument(Python3Parser::ArgumentContext *ctx) override;
|
||||
};
|
||||
class InterpretException : public std::exception
|
||||
{
|
||||
public:
|
||||
class InterpretException : public std::exception {
|
||||
public:
|
||||
InterpretException() {}
|
||||
InterpretException(const char *message) : m_message(message) {}
|
||||
|
||||
const char *what() const noexcept override
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
const char *what() const noexcept override { return m_message; }
|
||||
|
||||
~InterpretException() noexcept override {}
|
||||
|
||||
private:
|
||||
private:
|
||||
const char *m_message;
|
||||
};
|
||||
|
||||
class FatalError : public std::exception
|
||||
{
|
||||
public:
|
||||
class FatalError : public std::exception {
|
||||
public:
|
||||
FatalError(const char *message) : m_message(message) {}
|
||||
|
||||
const char *what() const noexcept override
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
const char *what() const noexcept override { return m_message; }
|
||||
|
||||
private:
|
||||
private:
|
||||
const char *m_message;
|
||||
};
|
||||
#endif // PYTHON_INTERPRETER_EVALVISITOR_H
|
||||
#endif // PYTHON_INTERPRETER_EVALVISITOR_H
|
||||
|
12
include/namescope.h
Normal file
12
include/namescope.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef NAMESCOPE_H
|
||||
#define NAMESCOPE_H
|
||||
|
||||
#include <any>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class NameScopeClass {
|
||||
;
|
||||
};
|
||||
#endif
|
0
include/utils.h
Normal file
0
include/utils.h
Normal file
Reference in New Issue
Block a user