X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParsedSource.cpp;h=90597475726663807fdc2beaa5b8f1d7fc627c98;hb=5228f225de7e2c047d3ddf0b9edfc9a05c4ea167;hp=6b2fc80413207811b90631c1bfc493982c95c5ee;hpb=3a30342daecdb9ee050ab20fcb50819a599d6343;p=l2e.git diff --git a/src/loader/ParsedSource.cpp b/src/loader/ParsedSource.cpp index 6b2fc80..9059747 100644 --- a/src/loader/ParsedSource.cpp +++ b/src/loader/ParsedSource.cpp @@ -1,10 +1,3 @@ -/* - * ParsedSource.cpp - * - * Created on: Aug 26, 2012 - * Author: holy - */ - #include "ParsedSource.h" #include "utility.h" @@ -207,6 +200,17 @@ Literal::Literal(const string &typeName, const vector &pls) } +Literal::Literal(const string &typeName, const vector &ids) +: props(0) +, typeName(typeName) +, identifiers(ids) +, i1(0), i2(0) +, i3(0), i4(0) +, b(false) +, type(ARRAY_IDENTS) { + +} + Literal::Literal(bool b) : props(0) , typeName("Boolean") @@ -331,6 +335,14 @@ const vector &Literal::GetPropertyLists() const { } } +const vector &Literal::GetIdentifiers() const { + if (type == ARRAY_IDENTS) { + return identifiers; + } else { + throw runtime_error("tried to access identifiers of non-array literal"); + } +} + bool Literal::GetBoolean() const { if (type == BOOLEAN) { return b; @@ -485,7 +497,7 @@ const string &ScriptToken::CommandName() const { } } -const string &ScriptToken::GetIdentifier() const { +const string &ScriptToken::Identifier() const { if (type == IDENTIFIER) { return str; } else { @@ -493,6 +505,14 @@ const string &ScriptToken::GetIdentifier() const { } } +const string &ScriptToken::Label() const { + if (type == LABEL) { + return str; + } else { + throw runtime_error("access to label of non-label script token"); + } +} + const Literal *ScriptToken::GetLiteral() const { if (type == LITERAL) { return literal; @@ -534,6 +554,9 @@ ostream &operator <<(ostream &out, const loader::Literal &l) { case loader::Literal::ARRAY_PROPS: out << "array of property lists"; break; + case loader::Literal::ARRAY_IDENTS: + out << "array of identifiers"; + break; case loader::Literal::BOOLEAN: out << "boolean, " << (l.GetBoolean() ? "true" : "false"); break;