ArkScript
A small, fast, functional and scripting language for video games
Pass.hpp
Go to the documentation of this file.
1/**
2 * @file Pass.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief Interface for a compiler pass (take in an AST, output an AST)
5 * @version 1.0
6 * @date 2024-07-21
7 *
8 * @copyright Copyright (c) 2024
9 *
10 */
11#ifndef ARK_COMPILER_PASS_HPP
12#define ARK_COMPILER_PASS_HPP
13
15#include <Ark/Logger.hpp>
16
17namespace Ark::internal
18{
19 /**
20 * @brief An interface to describe compiler passes
21 */
22 class Pass
23 {
24 public:
25 /**
26 * @brief Construct a new Pass object
27 *
28 * @param name the pass name, used for logging
29 * @param debug_level debug level
30 */
31 Pass(std::string name, unsigned debug_level);
32
33 virtual ~Pass() = default;
34
35 /**
36 * @brief Start processing the given AST
37 * @param ast
38 */
39 virtual void process(const Node& ast) = 0;
40
41 /**
42 * @brief Output of the compiler pass
43 *
44 * @return const Node& the modified AST
45 */
46 [[nodiscard]] virtual const Node& ast() const noexcept = 0;
47
48 protected:
50 };
51}
52
53#endif // ARK_COMPILER_PASS_HPP
Internal logger.
AST node used by the parser, optimizer and compiler.
A node of an Abstract Syntax Tree for ArkScript.
Definition Node.hpp:30
An interface to describe compiler passes.
Definition Pass.hpp:23
virtual const Node & ast() const noexcept=0
Output of the compiler pass.
virtual void process(const Node &ast)=0
Start processing the given AST.
Pass(std::string name, unsigned debug_level)
Construct a new Pass object.
Definition Pass.cpp:6
virtual ~Pass()=default