ArkScript
A small, fast, functional and scripting language for video games
Ark::internal Namespace Reference

Namespaces

namespace  Builtins
 

Classes

class  BaseParser
 
struct  bytes_t
 
struct  CharPred
 
class  Closure
 Closure management. More...
 
class  ConditionalExecutor
 Handles Conditional macros. More...
 
struct  ExecutionContext
 
struct  FilePosition
 
class  FunctionExecutor
 Handles function macros. More...
 
class  Future
 
struct  Import
 
class  ImportSolver
 
struct  IsAlnum
 
struct  IsAlpha
 
struct  IsAny
 
struct  IsChar
 
struct  IsDigit
 
struct  IsEither
 
struct  IsHex
 
struct  IsInlineSpace
 
struct  IsLower
 
struct  IsNot
 
struct  IsPrint
 
struct  IsSpace
 
struct  IsSymbol
 
struct  IsUpper
 
class  MacroExecutor
 A class that applies macros in a Node. More...
 
class  MacroExecutorPipeline
 The class that initializes the MacroExecutors. More...
 
class  MacroProcessor
 The class handling the macros definitions and calls, given an AST. More...
 
class  MacroScope
 
struct  Module
 
class  Node
 A node of an Abstract Syntax Tree for ArkScript. More...
 
class  Optimizer
 The ArkScript AST optimizer. More...
 
class  Parser
 
class  Scope
 A class to handle the VM scope more efficiently. More...
 
class  SharedLibrary
 Handling a shared library as an ArkScript plugin. More...
 
class  SymbolExecutor
 Handles Symbol macros. More...
 
struct  type_uid
 
struct  type_uid_impl
 
class  utf8_char_t
 
struct  ValTableElem
 A Compiler Value class helper to handle multiple types. More...
 
struct  Word
 

Typedefs

using PageAddr_t = uint16_t
 

Enumerations

enum class  NodeType {
  Symbol , Capture , Keyword , String ,
  Number , List , Spread , Field ,
  Macro , Unused
}
 The different node types available. More...
 
enum class  Keyword {
  Fun , Let , Mut , Set ,
  If , While , Begin , Import ,
  Del
}
 The different keywords available. More...
 
enum  Instruction : uint8_t {
  NOP = 0x00 , SYM_TABLE_START = 0x01 , VAL_TABLE_START = 0x02 , NUMBER_TYPE = 0x01 ,
  STRING_TYPE = 0x02 , FUNC_TYPE = 0x03 , CODE_SEGMENT_START = 0x03 , FIRST_COMMAND = 0x01 ,
  LOAD_SYMBOL = 0x01 , LOAD_CONST = 0x02 , POP_JUMP_IF_TRUE = 0x03 , STORE = 0x04 ,
  LET = 0x05 , POP_JUMP_IF_FALSE = 0x06 , JUMP = 0x07 , RET = 0x08 ,
  HALT = 0x09 , CALL = 0x0a , CAPTURE = 0x0b , BUILTIN = 0x0c ,
  MUT = 0x0d , DEL = 0x0e , SAVE_ENV = 0x0f , GET_FIELD = 0x10 ,
  PLUGIN = 0x11 , LIST = 0x12 , APPEND = 0x13 , CONCAT = 0x14 ,
  APPEND_IN_PLACE = 0x15 , CONCAT_IN_PLACE = 0x16 , POP_LIST = 0x17 , POP_LIST_IN_PLACE = 0x18 ,
  POP = 0x19 , LAST_COMMAND = 0x19 , FIRST_OPERATOR = 0x20 , ADD = 0x20 ,
  SUB = 0x21 , MUL = 0x22 , DIV = 0x23 , GT = 0x24 ,
  LT = 0x25 , LE = 0x26 , GE = 0x27 , NEQ = 0x28 ,
  EQ = 0x29 , LEN = 0x2a , EMPTY = 0x2b , TAIL = 0x2c ,
  HEAD = 0x2d , ISNIL = 0x2e , ASSERT = 0x2f , TO_NUM = 0x30 ,
  TO_STR = 0x31 , AT = 0x32 , AND_ = 0x33 , OR_ = 0x34 ,
  MOD = 0x35 , TYPE = 0x36 , HASFIELD = 0x37 , NOT = 0x38 ,
  LAST_OPERATOR = 0x38 , LAST_INSTRUCTION = 0x38
}
 The different bytecodes are stored here. More...
 
enum class  ValTableElemType { Number , String , PageAddr }
 Enumeration to keep track of the type of a Compiler Value. More...
 
enum class  ErrorKind {
  VM , Module , Mutability , Scope ,
  Type , Index , Arity , DivisionByZero
}
 

Functions

const NodegetTrueNode ()
 
const NodegetFalseNode ()
 
const NodegetNilNode ()
 
const NodegetListNode ()
 
std::string typeToString (const Node &node) noexcept
 
bool operator< (const Closure &A, const Closure &B) noexcept
 
long countOpenEnclosures (const std::string &line, char open, char close)
 Count the open enclosure and its counterpart: (), {}, [].
 
void trimWhitespace (std::string &line)
 Remove whitespaces at the start and end of a string.
 
replxx::Replxx::completions_t hookCompletion (const std::string &context, int &length)
 
void hookColor (const std::string &context, replxx::Replxx::colors_t &colors)
 
replxx::Replxx::hints_t hookHint (const std::string &context, int &length, replxx::Replxx::Color &color)
 
bool operator== (const Node &A, const Node &B)
 
bool operator< (const Node &A, const Node &B)
 
bool operator! (const Node &A)
 
std::optional< std::filesystem::path > testExtensions (const std::filesystem::path &folder, const std::string &package_path)
 
bool operator== (const Scope &A, const Scope &B) noexcept
 
bool operator== (const Closure &A, const Closure &B) noexcept
 
std::size_t codepointLength (const std::string &str)
 
std::size_t contextLen (const std::string &prefix)
 

Variables

Ark::internal::IsSpace IsSpace
 
Ark::internal::IsInlineSpace IsInlineSpace
 
Ark::internal::IsDigit IsDigit
 
Ark::internal::IsHex IsHex
 
Ark::internal::IsUpper IsUpper
 
Ark::internal::IsLower IsLower
 
Ark::internal::IsAlpha IsAlpha
 
Ark::internal::IsAlnum IsAlnum
 
Ark::internal::IsPrint IsPrint
 
Ark::internal::IsSymbol IsSymbol
 
Ark::internal::IsAny IsAny
 
const IsChar IsMinus ('-')
 
constexpr std::array< std::string_view, 10 > nodeTypes
 
constexpr std::array< std::string_view, 9 > keywords
 List of available keywords in ArkScript.
 
constexpr std::array< std::string_view, 25 > operators
 
constexpr std::array< std::string_view, 8 > errorKinds
 
const std::vector< std::string > KeywordsDict
 
const std::vector< std::pair< std::string, replxx::Replxx::Color > > ColorsRegexDict
 

Typedef Documentation

◆ PageAddr_t

using Ark::internal::PageAddr_t = typedef uint16_t

Definition at line 30 of file Closure.hpp.

Enumeration Type Documentation

◆ ErrorKind

enum class Ark::internal::ErrorKind
strong
Enumerator
VM 
Module 
Mutability 
Scope 
Type 
Index 
Arity 
DivisionByZero 

Definition at line 9 of file ErrorKind.hpp.

◆ Instruction

The different bytecodes are stored here.

Adding an operator
It must be referenced as well under include/Ark/Compiler/Common.hpp, in the operators table. The order of the operators below FIRST_OPERATOR must be the same as the one in the operators table from the aforementioned file.
Enumerator
NOP 
SYM_TABLE_START 
VAL_TABLE_START 
NUMBER_TYPE 
STRING_TYPE 
FUNC_TYPE 
CODE_SEGMENT_START 
FIRST_COMMAND 
LOAD_SYMBOL 
LOAD_CONST 
POP_JUMP_IF_TRUE 
STORE 
LET 
POP_JUMP_IF_FALSE 
JUMP 
RET 
HALT 
CALL 
CAPTURE 
BUILTIN 
MUT 
DEL 
SAVE_ENV 
GET_FIELD 
PLUGIN 
LIST 
APPEND 
CONCAT 
APPEND_IN_PLACE 
CONCAT_IN_PLACE 
POP_LIST 
POP_LIST_IN_PLACE 
POP 
LAST_COMMAND 
FIRST_OPERATOR 
ADD 
SUB 
MUL 
DIV 
GT 
LT 
LE 
GE 
NEQ 
EQ 
LEN 
EMPTY 
TAIL 
HEAD 
ISNIL 
ASSERT 
TO_NUM 
TO_STR 
AT 
AND_ 
OR_ 
MOD 
TYPE 
HASFIELD 
NOT 
LAST_OPERATOR 
LAST_INSTRUCTION 

Definition at line 25 of file Instructions.hpp.

◆ Keyword

enum class Ark::internal::Keyword
strong

The different keywords available.

Enumerator
Fun 
Let 
Mut 
Set 
If 
While 
Begin 
Import 
Del 

Definition at line 55 of file Common.hpp.

◆ NodeType

enum class Ark::internal::NodeType
strong

The different node types available.

Enumerator
Symbol 
Capture 
Keyword 
String 
Number 
List 
Spread 
Field 
Macro 
Unused 

Definition at line 27 of file Common.hpp.

◆ ValTableElemType

Enumeration to keep track of the type of a Compiler Value.

Enumerator
Number 
String 
PageAddr 

Definition at line 26 of file ValTableElem.hpp.

Function Documentation

◆ codepointLength()

std::size_t Ark::internal::codepointLength ( const std::string &  str)

Definition at line 22 of file Utils.cpp.

Referenced by hookColor(), hookCompletion(), and hookHint().

◆ contextLen()

std::size_t Ark::internal::contextLen ( const std::string &  prefix)

Definition at line 30 of file Utils.cpp.

Referenced by hookCompletion(), and hookHint().

◆ countOpenEnclosures()

long Ark::internal::countOpenEnclosures ( const std::string &  line,
char  open,
char  close 
)

Count the open enclosure and its counterpart: (), {}, [].

Parameters
linedata to operate on
openthe open char: (, { or [
closethe closing char: ), } or ]
Returns
positive if there are more open enclosures than closed. 0 when both are equal, negative otherwise

Definition at line 7 of file Utils.cpp.

Referenced by Ark::Repl::getCodeBlock().

◆ getFalseNode()

const Node & Ark::internal::getFalseNode ( )

Definition at line 287 of file Node.cpp.

References Symbol.

Referenced by Ark::internal::MacroProcessor::evaluate().

◆ getListNode()

const Node & Ark::internal::getListNode ( )

◆ getNilNode()

const Node & Ark::internal::getNilNode ( )

◆ getTrueNode()

const Node & Ark::internal::getTrueNode ( )

Definition at line 281 of file Node.cpp.

References Symbol.

Referenced by Ark::internal::MacroProcessor::evaluate().

◆ hookColor()

void Ark::internal::hookColor ( const std::string &  context,
replxx::Replxx::colors_t &  colors 
)

Definition at line 72 of file Utils.cpp.

References codepointLength(), and ColorsRegexDict.

Referenced by Ark::Repl::cuiSetup().

◆ hookCompletion()

replxx::Replxx::completions_t Ark::internal::hookCompletion ( const std::string &  context,
int &  length 
)

Definition at line 48 of file Utils.cpp.

References codepointLength(), contextLen(), and KeywordsDict.

Referenced by Ark::Repl::cuiSetup().

◆ hookHint()

replxx::Replxx::hints_t Ark::internal::hookHint ( const std::string &  context,
int &  length,
replxx::Replxx::Color &  color 
)

Definition at line 97 of file Utils.cpp.

References codepointLength(), contextLen(), and KeywordsDict.

Referenced by Ark::Repl::cuiSetup().

◆ operator!()

bool Ark::internal::operator! ( const Node A)

Definition at line 336 of file Node.cpp.

◆ operator<() [1/2]

bool Ark::internal::operator< ( const Closure A,
const Closure B 
)
inlinenoexcept

Definition at line 90 of file Closure.hpp.

◆ operator<() [2/2]

bool Ark::internal::operator< ( const Node A,
const Node B 
)

Definition at line 317 of file Node.cpp.

◆ operator==() [1/3]

bool Ark::internal::operator== ( const Closure A,
const Closure B 
)
noexcept

Definition at line 43 of file Closure.cpp.

◆ operator==() [2/3]

bool Ark::internal::operator== ( const Node A,
const Node B 
)

Definition at line 306 of file Node.cpp.

◆ operator==() [3/3]

bool Ark::internal::operator== ( const Scope A,
const Scope B 
)
noexcept

Definition at line 84 of file Scope.cpp.

◆ testExtensions()

std::optional< std::filesystem::path > Ark::internal::testExtensions ( const std::filesystem::path &  folder,
const std::string &  package_path 
)

Definition at line 167 of file ImportSolver.cpp.

Referenced by Ark::internal::ImportSolver::findFile().

◆ trimWhitespace()

void Ark::internal::trimWhitespace ( std::string &  line)

Remove whitespaces at the start and end of a string.

Parameters
linestring modified in place

Definition at line 12 of file Utils.cpp.

Referenced by Ark::Repl::getLine().

◆ typeToString()

std::string Ark::internal::typeToString ( const Node node)
inlinenoexcept

Definition at line 200 of file Node.hpp.

References nodeTypes.

Referenced by Ark::internal::MacroProcessor::evaluate(), and Ark::internal::MacroProcessor::unify().

Variable Documentation

◆ ColorsRegexDict

const std::vector<std::pair<std::string, replxx::Replxx::Color> > Ark::internal::ColorsRegexDict

Definition at line 56 of file Utils.hpp.

Referenced by hookColor().

◆ errorKinds

constexpr std::array<std::string_view, 8> Ark::internal::errorKinds
constexpr
Initial value:
= {
"VMError",
"ModuleError",
"MutabilityError",
"ScopeError",
"TypeError",
"IndexError",
"ArityError",
"DivisionByZero"
}

Definition at line 21 of file ErrorKind.hpp.

Referenced by Ark::VM::throwVMError().

◆ IsAlnum

◆ IsAlpha

◆ IsAny

◆ IsDigit

◆ IsHex

◆ IsInlineSpace

◆ IsLower

◆ IsMinus

const IsChar Ark::internal::IsMinus('-') ( '-'  )

◆ IsPrint

◆ IsSpace

◆ IsSymbol

◆ IsUpper

◆ keywords

constexpr std::array<std::string_view, 9> Ark::internal::keywords
constexpr
Initial value:
= {
"fun",
"let",
"mut",
"set",
"if",
"while",
"begin",
"import",
"del"
}

List of available keywords in ArkScript.

Definition at line 69 of file Common.hpp.

Referenced by Formatter::format(), Formatter::formatVariable(), and Ark::internal::Node::repr().

◆ KeywordsDict

const std::vector<std::string> Ark::internal::KeywordsDict

Definition at line 22 of file Utils.hpp.

Referenced by hookCompletion(), and hookHint().

◆ nodeTypes

constexpr std::array<std::string_view, 10> Ark::internal::nodeTypes
constexpr
Initial value:
= {
"Symbol",
"Capture",
"Keyword",
"String",
"Number",
"List",
"Spread",
"Field",
"Macro",
"Unused"
}

Definition at line 41 of file Common.hpp.

Referenced by JsonCompiler::_compile(), and typeToString().

◆ operators

constexpr std::array<std::string_view, 25> Ark::internal::operators
constexpr
Initial value:
= {
"+", "-", "*", "/",
">", "<", "<=", ">=", "!=", "=",
"len", "empty?", "tail", "head",
"nil?", "assert",
"toNumber", "toString",
"@", "and", "or", "mod",
"type", "hasField",
"not"
}

Definition at line 84 of file Common.hpp.

Referenced by Ark::Compiler::getOperator(), Ark::Compiler::handleCalls(), and Ark::internal::MacroProcessor::isConstEval().