X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParser.cpp;h=89e3931e9529ccdf2dd4ce3c6a5fae6544a1cd35;hb=d93a406fe997af6035ace4fa8720a5bde1743456;hp=9ddae34c5bdd4b2ac2a688c6765c925c05013917;hpb=7c43158af1abf38fa896a442cb3c6d8a5bc630e7;p=l2e.git diff --git a/src/loader/Parser.cpp b/src/loader/Parser.cpp index 9ddae34..89e3931 100644 --- a/src/loader/Parser.cpp +++ b/src/loader/Parser.cpp @@ -1,16 +1,12 @@ -/* - * Parser.cpp - * - * Created on: Aug 26, 2012 - * Author: holy - */ - #include "Parser.h" +#include "ParsedSource.h" #include "utility.h" #include #include +#include +#include using std::auto_ptr; using std::ifstream; @@ -266,17 +262,33 @@ Literal *Parser::ParseArray() { Token probe(GetToken()); if (probe.type == Token::TYPE_NAME) { - vector 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 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 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); @@ -371,7 +383,13 @@ Literal *Parser::ParseScript() { break; } case Token::IDENTIFIER: { - script.push_back(new ScriptToken(t.str, ScriptToken::IDENTIFIER)); + Token t2(GetToken()); + if (t2.type == Token::COLON) { + script.push_back(new ScriptToken(t.str, ScriptToken::LABEL)); + } else { + tok.Putback(t2); + script.push_back(new ScriptToken(t.str, ScriptToken::IDENTIFIER)); + } break; } case Token::REGISTER: {