X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParsedSource.h;h=6a7a2d4eed684fcaca5e42d01e40eaca97f02113;hb=8fd08e32d902b1340dd686ba0d7990fb1be3b861;hp=98ecd8423c401652f235c01a5ed7d68d40b1379b;hpb=ba714f2fe9064dd49b4c4a387502579b38a73223;p=l2e.git diff --git a/src/loader/ParsedSource.h b/src/loader/ParsedSource.h index 98ecd84..6a7a2d4 100644 --- a/src/loader/ParsedSource.h +++ b/src/loader/ParsedSource.h @@ -8,6 +8,8 @@ #ifndef LOADER_PARSEDSOURCE_H_ #define LOADER_PARSEDSOURCE_H_ +#include "fwd.h" + #include #include #include @@ -16,8 +18,39 @@ namespace loader { -class PropertyList; -class Value; +class ScriptToken { + +public: + enum Type { + COMMAND, + REGISTER, + IDENTIFIER, + LITERAL, + LABEL, + }; + + ScriptToken(const std::string &, Type); + explicit ScriptToken(Literal *); + ~ScriptToken(); +private: + ScriptToken(const ScriptToken &); + ScriptToken &operator =(const ScriptToken &); + +public: + Type GetType() const { return type; } + const std::string &RegisterName() const; + const std::string &CommandName() const; + const std::string &Identifier() const; + const std::string &Label() const; + const Literal *GetLiteral() const; + +private: + Literal *literal; + std::string str; + Type type; + +}; + class Literal { @@ -31,12 +64,13 @@ public: PATH, STRING, VECTOR, - OBJECT + OBJECT, + SCRIPT, }; public: explicit Literal(const std::vector &); - explicit Literal(const std::vector &); + Literal(const std::string &, const std::vector &); explicit Literal(bool); Literal(int r, int g, int b, int a = 255); explicit Literal(int number); @@ -44,6 +78,7 @@ public: Literal(const std::string &); Literal(int x, int y); Literal(const std::string &typeName, PropertyList *properties); + explicit Literal(const std::vector &); ~Literal(); private: Literal(const Literal &); @@ -51,6 +86,9 @@ private: public: Type GetType() const { return type; } + bool IsArray() const { return GetType() == ARRAY_VALUES || GetType() == ARRAY_PROPS; } + bool IsObject() const { return GetType() == OBJECT; } + int ArraySize() const { return GetType() == ARRAY_VALUES ? GetValues().size() : GetPropertyLists().size(); } const std::vector &GetValues() const; const std::vector &GetPropertyLists() const; @@ -65,12 +103,14 @@ public: int GetY() const; const std::string &GetTypeName() const; const PropertyList *GetProperties() const; + const std::vector &GetScript() const; private: PropertyList *props; - std::string str; + std::string typeName, str; std::vector values; std::vector propertyLists; + std::vector script; int i1, i2, i3, i4; bool b; Type type;