ArkScript
A small, fast, functional and scripting language for video games
Ark::JsonCompiler Class Reference

#include <JsonCompiler.hpp>

+ Collaboration diagram for Ark::JsonCompiler:

Public Member Functions

 JsonCompiler (unsigned debug, const std::vector< std::string > &libenv, uint16_t options=DefaultFeatures)
 Construct a new JsonCompiler object.
 
void feed (const std::string &code, const std::string &filename=ARK_NO_NAME_FILE)
 Feed the differents variables with information taken from the given source code file.
 
std::string compile ()
 Start the compilation.
 

Private Member Functions

std::string _compile (const internal::Node &node)
 Compile a single node and return its representation.
 
std::string toJsonList (const internal::Node &node, std::size_t start)
 Convert a NodeType::List to a JSON list.
 

Private Attributes

internal::Parser m_parser
 
internal::Optimizer m_optimizer
 
uint16_t m_options
 
unsigned m_debug
 the debug level of the compiler
 

Detailed Description

Definition at line 15 of file JsonCompiler.hpp.

Constructor & Destructor Documentation

◆ JsonCompiler()

Ark::JsonCompiler::JsonCompiler ( unsigned  debug,
const std::vector< std::string > &  libenv,
uint16_t  options = DefaultFeatures 
)

Construct a new JsonCompiler object.

Parameters
debugthe debug level
optionsthe compilers options

Definition at line 14 of file JsonCompiler.cpp.

Member Function Documentation

◆ _compile()

std::string Ark::JsonCompiler::_compile ( const internal::Node node)
private

◆ compile()

std::string Ark::JsonCompiler::compile ( )

Start the compilation.

Returns

Definition at line 28 of file JsonCompiler.cpp.

References _compile(), Ark::internal::Optimizer::ast(), and m_optimizer.

Referenced by main().

◆ feed()

void Ark::JsonCompiler::feed ( const std::string &  code,
const std::string &  filename = ARK_NO_NAME_FILE 
)

Feed the differents variables with information taken from the given source code file.

Parameters
codethe code of the file
filenamethe name of the file

Definition at line 19 of file JsonCompiler.cpp.

References Ark::internal::Parser::ast(), Ark::internal::MacroProcessor::ast(), Ark::internal::Optimizer::feed(), Ark::internal::MacroProcessor::feed(), Ark::internal::Parser::feed(), m_debug, m_optimizer, m_options, and m_parser.

Referenced by main().

◆ toJsonList()

std::string Ark::JsonCompiler::toJsonList ( const internal::Node node,
std::size_t  start 
)
private

Convert a NodeType::List to a JSON list.

Parameters
node
start
Returns
std::string

Definition at line 222 of file JsonCompiler.cpp.

References _compile(), and Ark::internal::Node::constList().

Referenced by _compile().

Member Data Documentation

◆ m_debug

unsigned Ark::JsonCompiler::m_debug
private

the debug level of the compiler

Definition at line 45 of file JsonCompiler.hpp.

Referenced by feed().

◆ m_optimizer

internal::Optimizer Ark::JsonCompiler::m_optimizer
private

Definition at line 43 of file JsonCompiler.hpp.

Referenced by compile(), and feed().

◆ m_options

uint16_t Ark::JsonCompiler::m_options
private

Definition at line 44 of file JsonCompiler.hpp.

Referenced by feed().

◆ m_parser

internal::Parser Ark::JsonCompiler::m_parser
private

Definition at line 42 of file JsonCompiler.hpp.

Referenced by feed().


The documentation for this class was generated from the following files: