Archived
1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mathpad/MathPad/MPExpressionTree.h
2014-11-10 21:45:50 +01:00

80 lines
2.8 KiB
Objective-C

//
// MPExpressionTree.h
// MathPad
//
// Created by Kim Wittenburg on 09.10.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPExpressionTreeElement.h"
@class MPExpressionTree;
/*!
@class MPExpressionTree
@brief The @c MPExpressionTree class is the main interface for working
with the mathematical representation of an expression.
@discussion Expressions are represented as a tree structure of elements (all
of which must conform to the @c MPExpressionTreeElement
protocol). Most messages sent to instances of the @c
MPExpressionTree class are cascaded down different parts of an
expression in some way.
*/
@interface MPExpressionTree : NSObject <MPExpressionTreeElement>
/*!
@property definedVariable
@brief The variable this expression defines.
@discussion A variable definition must be at the beginning of an expression.
If it defines a variable it must start with a single letter
followed by an equals sign. The single letter is the name of the
variable that is defined.
*/
@property (nonatomic, copy) NSString *definedVariable;
/*!
@property summands
@brief The summands that make up the receiver.
@discussion A expression mathematically can be interpreted as a series of
summands. Summands are the different pars of an expression that
are separated by + or - symbols. Every object in the returned
array is guaranteed to conform to the @c MPExpressionTreeElement
protocol.
*/
@property (readonly, nonatomic, strong) NSArray *summands;
/*!
@method validateExpectingVariableDefinition:error:
@brief Validates the receiver.
@discussion Using this method you can validate an expression that contains a
variable definition. If a variable definition is expected but not
found this method returns @c NO. Likewise @c NO is returned if
you do not expect a variable definition but one is found.
@param flag
Specifies wether or not to expect a variable definition at the
beginning of the expression.
@param error
If there is a syntax error in the receiver this parameter will be
set to an appropriate value. If you are not interested in the
type of syntax error pass @c NULL.
@return @c YES if the receiver is valid, @c NO otherwise. If @c NO is
returned the @c error parameter should be set to an appropriate
value.
*/
- (BOOL)validateExpectingVariableDefinition:(BOOL)flag
error:(NSError *__autoreleasing *)error;
@end