]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Parser.cpp
removed lazy fwd headers
[l2e.git] / src / loader / Parser.cpp
index 9641fadfae828db61439dee05683a017e71afba9..89e3931e9529ccdf2dd4ce3c6a5fae6544a1cd35 100644 (file)
@@ -1,16 +1,12 @@
-/*
- * Parser.cpp
- *
- *  Created on: Aug 26, 2012
- *      Author: holy
- */
-
 #include "Parser.h"
 
+#include "ParsedSource.h"
 #include "utility.h"
 
 #include <auto_ptr.h>
 #include <fstream>
+#include <string>
+#include <vector>
 
 using std::auto_ptr;
 using std::ifstream;
@@ -266,17 +262,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);