//
//  MPParsedElement.h
//  MathPad
//
//  Created by Kim Wittenburg on 05.09.14.
//  Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MPParseError.h"

@interface MPParsedElement : NSObject <NSCopying>

@property (nonatomic, copy) NSString *definedVariable;
@property (nonatomic) NSUInteger afterVariableDefinitionIndex; // Only set if defineVariable != nil

@property (nonatomic) BOOL isFactor;

// If isFactor is YES this is the factor otherwise it is the independant summant
// of the element (may be 0).
@property (nonatomic) NSDecimalNumber *value;

@property (nonatomic, getter = isPrefixOperatorExplicit) BOOL prefixOperatorExplicit;
@property (nonatomic, getter = isPrefixValueExplicit) BOOL prefixValueExplicit;
@property (nonatomic) NSDecimalNumber *prefixMultiplicator;

@property (nonatomic, getter = isSuffixOperatorExplicit) BOOL suffixOperatorExplicit;
@property (nonatomic, getter = isSuffixValueExplicit) BOOL suffixValueExplicit;
@property (nonatomic) NSDecimalNumber *suffixMultiplicator;
@property (nonatomic) NSUInteger suffixIndex;

// No error checking done
- (NSDecimalNumber *)valueAtBeginning;
- (NSDecimalNumber *)valueAtEnd;
- (NSDecimalNumber *)standaloneValue;

// For error checking
- (BOOL)isValidElementAtBeginning:(MPParseError **)error;
- (BOOL)isValidStandaloneElement:(MPParseError **)error;
- (BOOL)isValidElementAtEnd:(MPParseError **)error;
- (BOOL)isValidVariableDefinition:(MPParseError **)error;

@end
