class Literal {
enum Type {
- ARRAY,
+ ARRAY_VALUES,
+ ARRAY_PROPS,
BOOLEAN,
COLOR,
NUMBER,
public:
explicit Literal(const std::vector<Value *> &);
+ explicit Literal(const std::vector<PropertyList *> &);
explicit Literal(bool);
Literal(int r, int g, int b, int a = 255);
Literal(const std::string &);
PropertyList *props;
std::string str;
std::vector<Value *> values;
+ std::vector<PropertyList *> propertyLists;
int i1, i2, i3, i4;
bool b;
Type type;
Tokenizer::Token t(GetToken());
AssertTokenType(t.type, Tokenizer::Token::BRACKET_OPEN);
- vector<Value *> values;
-
- while (t.type != Tokenizer::Token::ANGLE_BRACKET_CLOSE) {
- Value *value(ParseValue());
- values.push_back(value);
-
- t = GetToken();
- if (t.type != Tokenizer::Token::BRACKET_CLOSE && t.type != Tokenizer::Token::COMMA) {
- throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+ Tokenizer::Token probe(GetToken());
+ tok.Putback(probe);
+
+ if (probe.type == Tokenizer::Token::ANGLE_BRACKET_OPEN) {
+ vector<PropertyList *> values;
+ while (t.type != Tokenizer::Token::BRACKET_CLOSE) {
+ PropertyList *value(ParsePropertyList());
+ values.push_back(value);
+
+ t = GetToken();
+ if (t.type != Tokenizer::Token::BRACKET_CLOSE && t.type != Tokenizer::Token::COMMA) {
+ throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+ }
}
+ return new Literal(values);
+ } else {
+ vector<Value *> values;
+ while (t.type != Tokenizer::Token::BRACKET_CLOSE) {
+ Value *value(ParseValue());
+ values.push_back(value);
+
+ t = GetToken();
+ if (t.type != Tokenizer::Token::BRACKET_CLOSE && t.type != Tokenizer::Token::COMMA) {
+ throw Error(file, tok.Line(), string("unexpected token ") + TokenTypeToString(t.type) + ", expected , or ]");
+ }
+ }
+ return new Literal(values);
}
-
- return new Literal(values);
}
Literal *Parser::ParseColor() {