![]() |
Gorgon Game Engine
|
This namespace contains compliers and any utilities related with it. More...
Classes | |
class | ASTCompiler |
ASTCompiler stores states for AST compiler. More... | |
class | ASTNode |
Represents a node in abstract syntax tree. More... | |
class | Base |
The base class for compilers. More... | |
class | Intermediate |
Intermediate language complier. More... | |
class | Programming |
Programming dialect compiler. More... | |
Functions | |
void | ASTToSVG (const std::string &line, ASTNode &tree, const std::vector< std::string > &compiled={}, bool show=false) |
Converts given AST to an SVG file. More... | |
template<class ... P_> | |
int | CheckInputFor (const std::string &input, int &ch, P_ ...args) |
Checks if the input string contains one of the given characters at current point. More... | |
Value | compilevalue (ASTNode &tree, std::vector< Instruction > *list, Byte &tempind, bool generateoutput=true) |
std::string | Disassemble (const Instruction &inst) |
Disassembles the given instruction. More... | |
std::string | Disassemble (const Instruction *) |
Disassembles the given instruction. More... | |
void | Disassemble (InputSource &source, std::ostream &out) |
Disassembles entire input source to the given stream. More... | |
void | Disassemble (Scope &scope, std::ostream &out) |
std::string | disassemblevalue (const Value &value) |
std::string | dottree (ASTNode &tree, int &ind) |
std::string | ExtractQuotes (const std::string &input, int &ch) |
Extracts a string that is in quotes. More... | |
int | GetPrecedence (const std::string &op) |
Returns the precedence of the given operator. More... | |
void | PrintAST (ASTNode &tree) |
Recursively prints an AST. More... | |
Variables | |
MappedReferenceType< std::vector< Instruction >, &ToEmptyString > | instructionlisttype ("#instructionlist", "") |
This namespace contains compliers and any utilities related with it.
void ASTToSVG | ( | const std::string & | line, |
ASTNode & | tree, | ||
const std::vector< std::string > & | compiled = {} , |
||
bool | show = false |
||
) |
Converts given AST to an SVG file.
This function requires GraphViz dot to be in path. The SVG will be saved as temp.dot.svg in the current directory.
line | the source code line |
tree | to be converted |
compiled | parameter can be used to add disassembly to the tree |
show | if set, the generated SVG will be opened |
References dottree(), Gorgon::OS::Open(), Gorgon::String::Replace(), and Gorgon::OS::Start().
int Gorgon::Scripting::Compilers::CheckInputFor | ( | const std::string & | input, |
int & | ch, | ||
P_ ... | args | ||
) |
Checks if the input string contains one of the given characters at current point.
If it does the index of the character found is returned and index is incremented. If not, an exception is thrown
Value Gorgon::Scripting::Compilers::compilevalue | ( | ASTNode & | tree, |
std::vector< Instruction > * | list, | ||
Byte & | tempind, | ||
bool | generateoutput = true |
||
) |
References ASSERT, Gorgon::Utils::ASSERT_FALSE(), ASTNode::Construct, Gorgon::Resource::GID::Data, ASTNode::FunctionCall, Gorgon::Scripting::FunctionCall, ASTNode::Identifier, Gorgon::Scripting::Identifier, ASTNode::Index, ASTNode::Leaves, ASTNode::Literal, Gorgon::Scripting::Literal, Value::Literal, ASTNode::LiteralValue, ASTNode::Member, ASTNode::MethodCall, Gorgon::Scripting::MethodCall, Value::Name, Instruction::Name, ASTNode::Operator, Instruction::Parameters, Value::Result, Instruction::RHS, Value::SetStringLiteral(), Instruction::Store, ASTNode::Text, ASTNode::Type, Value::Type, Instruction::Type, ASTNode::Variable, and Gorgon::Scripting::Variable.
std::string Gorgon::Scripting::Compilers::Disassemble | ( | const Instruction & | inst | ) |
Disassembles the given instruction.
References Disassemble().
std::string Disassemble | ( | const Instruction * | instruction | ) |
Disassembles the given instruction.
References ASSERT, Gorgon::Scripting::Assignment, disassemblevalue(), Gorgon::String::From(), Gorgon::Scripting::FunctionCall, Gorgon::Scripting::Jump, Instruction::JumpOffset, Gorgon::Scripting::MethodCall, Value::Name, Instruction::Name, Instruction::Parameters, Instruction::Reference, Instruction::RHS, Instruction::Store, and Instruction::Type.
void Gorgon::Scripting::Compilers::Disassemble | ( | InputSource & | source, |
std::ostream & | out | ||
) |
Disassembles entire input source to the given stream.
void Gorgon::Scripting::Compilers::Disassemble | ( | Scope & | scope, |
std::ostream & | out | ||
) |
References Disassemble(), and Scope::ReadInstruction().
std::string Gorgon::Scripting::Compilers::disassemblevalue | ( | const Value & | value | ) |
std::string Gorgon::Scripting::Compilers::dottree | ( | ASTNode & | tree, |
int & | ind | ||
) |
References ASTNode::Assignment, ASTNode::Construct, ASTNode::Empty, Gorgon::String::From(), ASTNode::FunctionCall, Member::GetName(), Data::GetType(), ASTNode::Identifier, ASTNode::Index, ASTNode::Keyword, ASTNode::Leaves, ASTNode::Literal, ASTNode::LiteralValue, ASTNode::Member, ASTNode::MethodCall, ASTNode::Operator, Gorgon::String::Replace(), ASTNode::Text, Data::ToString(), ASTNode::Type, and ASTNode::Variable.
std::string Gorgon::Scripting::Compilers::ExtractQuotes | ( | const std::string & | input, |
int & | ch | ||
) |
Extracts a string that is in quotes.
This function supports both single and double quotes. Additionally, this function transforms following escape sequences \", \', \n, and \xx, where xx is an hexadecimal digit. Notice that \0 is not valid, it should be given as \00.
References CheckInputFor().
int Gorgon::Scripting::Compilers::GetPrecedence | ( | const std::string & | op | ) |
Returns the precedence of the given operator.
If the given string is not an operator returns -1
void PrintAST | ( | ASTNode & | tree | ) |
Recursively prints an AST.
References ASTNode::Construct, ASTNode::FunctionCall, ASTNode::Index, ASTNode::Leaves, ASTNode::Text, and ASTNode::Type.
MappedReferenceType<std::vector<Instruction>, &ToEmptyString> instructionlisttype("#instructionlist", "") |