-/*
- * 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 <memory>
+#include <string>
+#include <vector>
-using std::auto_ptr;
+using std::unique_ptr;
using std::ifstream;
using std::string;
using std::vector;
Token t(GetToken());
tok.Putback(t);
if (BeginOfPropertyList(t)) {
- auto_ptr<PropertyList> propertyList(ParsePropertyList());
- auto_ptr<Definition> dfn(new Definition(typeName, identifier));
+ unique_ptr<PropertyList> propertyList(ParsePropertyList());
+ unique_ptr<Definition> dfn(new Definition(typeName, identifier));
dfn->SetValue(propertyList.release());
product.AddDefinition(dfn.get());
return dfn.release();
} else if (BeginningOfPrimitiveLiteral(t)) {
- auto_ptr<Literal> literal(ParseLiteral());
- auto_ptr<Definition> dfn(new Definition(typeName, identifier));
+ unique_ptr<Literal> literal(ParseLiteral());
+ unique_ptr<Definition> dfn(new Definition(typeName, identifier));
dfn->SetValue(literal.release());
product.AddDefinition(dfn.get());
return dfn.release();
Token t(GetToken());
AssertTokenType(t.type, Token::ANGLE_BRACKET_OPEN);
- auto_ptr<PropertyList> props(new PropertyList);
+ unique_ptr<PropertyList> props(new PropertyList);
while (t.type != Token::ANGLE_BRACKET_CLOSE) {
Token name(GetToken());
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);