]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Parser.cpp
lousy implementation of "array of identifiers" type
[l2e.git] / src / loader / Parser.cpp
index cba4f316f8d5251d1f878d7b2d612ce0f903655e..3f5f3446955ab8d78005912ad1d31df432c658e8 100644 (file)
@@ -259,17 +259,33 @@ Literal *Parser::ParseArray() {
        Token probe(GetToken());
 
        if (probe.type == Token::TYPE_NAME) {
-               vector<PropertyList *> values;
-               while (t.type != Token::BRACKET_CLOSE) {
-                       PropertyList *value(ParsePropertyList());
-                       values.push_back(value);
+               t = GetToken();
+               tok.Putback(t);
+               if (t.type == Token::ANGLE_BRACKET_OPEN) {
+                       vector<PropertyList *> values;
+                       while (t.type != Token::BRACKET_CLOSE) {
+                               PropertyList *value(ParsePropertyList());
+                               values.push_back(value);
 
-                       t = GetToken();
-                       if (t.type != Token::BRACKET_CLOSE && t.type != Token::COMMA) {
-                               throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+                               t = GetToken();
+                               if (t.type != Token::BRACKET_CLOSE && t.type != Token::COMMA) {
+                                       throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+                               }
+                       }
+                       return new Literal(probe.str, values);
+               } else {
+                       vector<string> values;
+                       while (t.type != Token::BRACKET_CLOSE) {
+                               string value(ParseIdentifier());
+                               values.push_back(value);
+
+                               t = GetToken();
+                               if (t.type != Token::BRACKET_CLOSE && t.type != Token::COMMA) {
+                                       throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+                               }
                        }
+                       return new Literal(probe.str, values);
                }
-               return new Literal(probe.str, values);
        } else {
                tok.Putback(probe);