//
//  EXPDimensionElement.m
//  XMLTest
//
//  Created by Ashley on 09/06/2007.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "EXPDimensionElement.h"
#import "EXPDimensionItemElement.h"

@implementation EXPDimensionElement

- (void) setItemList:(id)itemList
{
	[itemList retain];
	[_itemList release];
	_itemList = itemList;
}

- (id) itemList
{	
	return _itemList;
}

- (void) addItem:(id)item
{
	[[self itemList] addObject:item];
}

- (BOOL) setElementFromParser:(EXPParser *)parser symbolTable:(EXPSymbolTable *)symbolTable inputs:(id)inputs
{
	BOOL success = YES;

	NSString *identifier = [[NSString alloc] initWithString:[parser symbol]];
	[parser readSymbol];
	[self setName:identifier];
			
	if (![parser checkSymbol:@"="]) {
		[identifier release];
		return NO;
	}
			
	if (![parser checkSymbol:@"{"]) {
		[identifier release];
		return NO;
	}
			
	for (;;) {
		if ([parser testSymbol:@"}"]) {
			break;
		}
		NSString *item = [[NSString alloc] initWithString:[parser symbol]];
		[parser readSymbol];
		[self addItem:item];
		success = [symbolTable declareSymbol:item];
		[item release];

		if (![parser checkSymbol:@","]) {
			break;
		}
		
	}

	[identifier release];

	if (![parser checkSymbol:@"}"]) {
		return NO;
	}
			
	return YES;
}

@end
