 |
Gorgon Game Engine
|
Go to the documentation of this file.
12 namespace Gorgon {
namespace Scripting {
32 virtual unsigned Compile(
const std::string &input,
unsigned long pline) = 0;
42 return scope!=
nullptr;
51 std::vector<Instruction>
List;
63 virtual unsigned Compile(
const std::string &input,
unsigned long pline)
override;
71 void storedfn(
const std::string &input,
int &ch);
73 void fncall(
const std::string &input,
int &ch,
bool allowmethod=
true);
75 void varassign(
const std::string &input,
int &ch);
77 void memberassign(
const std::string &input,
int &ch);
79 Value parsevalue(
const std::string &input,
int &ch);
81 unsigned long parsetemporary(
const std::string &input,
int &ch);
83 void eatwhite(
const std::string &input,
int &ch);
85 void jinst(std::string input,
int &ch);
93 virtual unsigned Compile(
const std::string &input,
unsigned long pline)
override;
102 ASTNode *parse(
const std::string &input);
103 void extractline(std::string &input, std::string &prepared);
105 void transformpos(
int ch,
int &oline,
int &och);
115 std::vector<charmarker> linemarkers;
virtual Data Parse(const std::string &) const =0
Parses a string into this data. This function is allowed to throw.
Library Math("Math", "Maths library.")
Definition: VirtualMachine.h:41
std::string ByteToString(const Gorgon::Byte &b)
Definition: Builtin.cpp:109
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
virtual void Finalize()=0
Finalizes the compilation.
constexpr Type Data
Data resource.
Definition: GID.h:164
virtual void AddMembers(std::initializer_list< StaticMember * > newmembers)
Adds a list of members to this namespace.
Definition: Reflection.h:1104
const Scripting::Type & Constant()
Programming dialect compiler.
Definition: Compilers.h:89
std::string Replace(std::string str, const std::string &find, const std::string &replace)
String replace that does not use regex.
Definition: String.h:349
long GetCount() const
Returns the number of elements in the map.
Definition: Hashmap.h:375
A new scope is created automatically when a new input source or a function like construct is created.
Definition: Scope.h:62
Scope * scope
The current scope the compiler is compiling, can be nullptr.
Definition: Compilers.h:55
virtual unsigned Compile(const std::string &input, unsigned long pline)=0
Asks the compiler to compile the given input.
Data describes a piece of data.
Definition: Data.h:22
std::vector< Parameter > ParameterList
Definition: Reflection.h:308
void SetOutput(std::ostream &out, bool deleteonchange=false)
Redirects the output stream to the given stream.
Definition: VirtualMachine.cpp:50
const StaticMemberList & Members
List of static members.
Definition: Reflection.h:1148
float Float
Represents floating point data type.
Definition: Types.h:16
The base class for compilers.
Definition: Compilers.h:21
Scope & GetScope() const
Returns the scope that compiler will compile.
Definition: Compilers.h:46
static VirtualMachine & Get()
Returns the current VM for this thread.
Definition: VirtualMachine.h:109
InstanceMember * MapFunctionToInstanceMember(F_ reader, const std::string &name, const std::string &help, const Type *membertype, const Type *parenttype)
This function will map a const data returning function to a read-only, non-ref, const instance member...
Definition: Embedding.h:1147
Utils::Logger log
Definition: Animation.cpp:11
const Scripting::Type & Namespace()
Definition: Reflection.h:315
const Type & GetType() const
Returns the type of the data.
Definition: Data.h:173
Library Keywords
Definition: VirtualMachine.h:41
Represents a node in abstract syntax tree.
Definition: AST.h:19
This class makes working with operators easier.
Definition: Embedding.h:635
bool isspace(Glyph g)
Definition: Font.cpp:96
std::string ToUpper(std::string str)
Converts the given string to uppercase.
Definition: String.h:426
This class stores information about types.
Definition: Reflection.h:1165
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a library.
Definition: Reflection.h:1596
uint32_t Char
Definition: Types.h:46
virtual void Finalize() override
Finalizes the compilation.
std::string Disassemble(const Instruction *)
Disassembles the given instruction.
Definition: Generator.cpp:55
@ RepeatTag
Marks an object as repeatable.
Definition: Reflection.h:73
virtual unsigned Compile(const std::string &input, unsigned long pline) override
Asks the compiler to compile the given input.
bool IsReference() const
Returns if this data contains a reference.
Definition: Data.cpp:212
ASTCompiler stores states for AST compiler.
Definition: AST.h:112
static Data Invalid()
Constructs an invalid data object.
Definition: Data.h:27
std::string ToLower(std::string str)
Converts the given string to lowercase.
Definition: String.h:416
std::string Trim(std::string str, const std::string &chars=" \t\n\r")
Strips whitespace around the given string both from start and end.
Definition: String.h:370
@ ReferenceTag
Marks the object as a reference.
Definition: Reflection.h:61
@ OptionalTag
Marks the object as optional.
Definition: Reflection.h:56
std::string Extract(std::string &original, const std::string &marker, bool trim=false)
Extracts the part of the string up to the given marker.
Definition: String.h:779
This class contains a parsed value.
Definition: Instruction.h:82
@ StretchTag
Used only in functions with console dialect.
Definition: Reflection.h:77
Base(Scope *scope)
Definition: Compilers.h:23
virtual Base & Duplicate(Scope *scope) const =0
@ KeywordTag
Marks object as a keyword.
Definition: Reflection.h:80
virtual Programming & Duplicate(Scope *scope) const override
Definition: Compilers.h:97
Scripting::Function::Overload * MapOperator(F_ fn, const Type *returntype, const Type *rhs)
Definition: Embedding.h:626
virtual ~Base()
Definition: Compilers.h:25
@ ConstTag
Marks a parameter or a function constant.
Definition: Reflection.h:95
void init_builtin()
Definition: Builtin.cpp:113
This class allows embedded types to become scripting types that are passed around as values.
Definition: Embedding.h:1300
Type * ArrayType()
Definition: Array.cpp:74
Any GetData() const
Returns the data contained in this data element.
Definition: Data.h:133
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
This class represents a function parameter description.
Definition: Reflection.h:137
std::vector< Instruction > List
The instructions that are compiled.
Definition: Compilers.h:51
bool HasScope() const
Returns if this compiler is bound to a scope.
Definition: Compilers.h:41
Type * TypeType()
Definition: Reflection.cpp:15
@ VariableTag
Makes this parameter a variable accepting parameter.
Definition: Reflection.h:102
void * Pointer() const
Returns the pointer without type information.
Definition: Any.h:332
void ResetOutput()
Resets the output stream to default stream that is given in the constructor.
Definition: VirtualMachine.h:155
std::vector< StaticMember * > ArrayFunctions()
Definition: Array.cpp:198
Library Reflection
Definition: Builtin.cpp:17
virtual void AddMember(StaticMember &member)
Adds a new member to this namespace.
Definition: Reflection.h:1088
Library Integrals
This library requires Initialize to be called.
Definition: VirtualMachine.h:41
Scripting::Function::Overload * MapFunction(F_ fn, const Type *returntype, ParameterList parameters, P_ ...tags)
Definition: Embedding.h:614
Exceptions This file contains string related exceptions.
void UnsetVariable(const std::string &name)
Definition: VirtualMachine.cpp:395
const Scripting::Type & Function()
Definition: Reflection.h:589
#define MAP_COMPARE(opname, op, mappedtype, cpptype)
Creates a comparison function.
Definition: Embedding.h:692
std::ostream & GetOutput() const
Returns the output stream.
Definition: VirtualMachine.h:145
const Scripting::Type & Type()
Definition: Reflection.h:316
Variable * getvarref(const std::string &var)
Internal, returns pointer to the variable. Can return nullptr. Only searches in VM variables.
Definition: VirtualMachine.cpp:320
A single instruction.
Definition: Instruction.h:150
@ ImplicitTag
Makes a constructor implicit.
Definition: Reflection.h:105
Programming(Scope *scope=nullptr)
Definition: Compilers.h:91
void InitReflection()
Definition: Reflection.cpp:30