ArkScript
A small, fast, functional and scripting language for video games
Repl.hpp
Go to the documentation of this file.
1 /**
2  * @file Repl.hpp
3  * @author Alexandre Plateau (lexplt.dev@gmail.com)
4  * @brief ArkScript REPL - Read Eval Print Loop
5  * @version 0.1
6  * @date 2020-10-27
7  *
8  * @copyright Copyright (c) 2020-2021
9  *
10  */
11 
12 #ifndef ARK_REPL_REPL_HPP
13 #define ARK_REPL_REPL_HPP
14 
15 #include <iostream>
16 
17 #include <Ark/Constants.hpp>
19 #include <Ark/VM/VM.hpp>
20 #include <Ark/VM/State.hpp>
22 
23 namespace Ark
24 {
25  class Repl
26  {
27  public:
28  /**
29  * @brief Construct a new Repl object
30  *
31  * @param options the REPL options
32  * @param libenv search path for the std library
33  */
34  Repl(uint16_t options, const std::vector<std::string>& libenv);
35 
36  /**
37  * @brief Start the REPL
38  *
39  */
40  int run();
41 
42  private:
43  uint16_t m_options;
45  unsigned m_lines;
46  int m_old_ip;
47  std::vector<std::string> m_libenv;
48 
49  inline void print_repl_header();
50  int count_open_parentheses(const std::string& line);
51  int count_open_braces(const std::string& line);
52  void trim_whitespace(std::string& line);
53  void cui_setup();
54  };
55 }
56 
57 #endif
ArkScript compiler is in charge of transforming the AST into bytecode.
Colors per token used by replxx.
replxx::Replxx Replxx
Constants used by ArkScript.
State used by the virtual machine: it loads the bytecode, can compile it if needed,...
The ArkScript virtual machine.
void cui_setup()
Definition: Repl.cpp:161
int run()
Start the REPL.
Definition: Repl.cpp:15
Repl(uint16_t options, const std::vector< std::string > &libenv)
Construct a new Repl object.
Definition: Repl.cpp:11
std::vector< std::string > m_libenv
Definition: Repl.hpp:47
int count_open_braces(const std::string &line)
Definition: Repl.cpp:135
uint16_t m_options
Definition: Repl.hpp:43
void trim_whitespace(std::string &line)
Definition: Repl.cpp:151
int count_open_parentheses(const std::string &line)
Definition: Repl.cpp:119
int m_old_ip
Definition: Repl.hpp:46
Replxx m_repl
Definition: Repl.hpp:44
unsigned m_lines
Definition: Repl.hpp:45
void print_repl_header()
Definition: Repl.cpp:109
Definition: Builtins.hpp:21