diff --git a/MathKit/MPExpression.h b/MathKit/MPExpression.h index 459c200..a32718f 100644 --- a/MathKit/MPExpression.h +++ b/MathKit/MPExpression.h @@ -7,6 +7,7 @@ // + /*! @header The MPExpression class is used to represent a mathematical @@ -21,22 +22,24 @@ elements. String elements are represented by the NSString class. In a valid expression string elements can only contain ASCII valid characters. (and some other special characters) that make sense in a mathematical context. - Functions are represented by the MPFunction class. Functions - represent everything beyond simple text (such as powers, parenthesis and roots). + Functions are represented by the @link + //apple_ref/occ/cl/MPFunction@/link class. Functions represent everything + beyond simple text (such as powers, parenthesis and roots). An expression should be pictured as a sequence of symbols that can either be characters or functions. For the purposes of easier processing of expressions it is possible to access complete string or function elements. Also there is a third way of accessing an expression's contents: You can query individual tokens of an expression. Tokens represent logical units inside an expression. For more - information on tokens see the MPToken class. + information on tokens see the documentation for @link + //apple_ref/doc/header/MPToken.h MPToken@/link.

The Expression Tree

Like expressions functions can likewise have expressions as elements (also called children in this context). Both expressions and functions are mutable. Through this organization expression are organized in a tree-like - structure called the expression tree. See MPFunction for - details. + structure called the expression tree. See @link + //apple_ref/occ/cl/MPFunction@/link for details.

Terminology

@@ -44,17 +47,19 @@ expression's contents: Element:
- An element is either an instance of the NSString or - MPFunction class. String elements can be multiple characters long. For - example the expression 4+2² consists of one string element - ("4+2") and one function element (the square function). All - elements conform to the MPExpressionElement protocol. + An element is either an instance of the NSString or @link + //apple_ref/occ/cl/MPFunction@/link class. String elements can be + multiple characters long. For example the expression 4+2² consists + of one string element ("4+2") and one function element (the square + function). All elements conform to the MPExpressionElement + protocol. Token:
Tokens are logical units within an expression. For example the expression 4+2² consists of 4 tokens: A number token (4), a plus sign token (+), another number (2) and a power token - (the square function). All tokens conform to the MPToken protocol. + (the square function). All tokens conform to the @link + //apple_ref/occ/intf/MPToken@/link protocol. Symbol:
Symbols are the smallest possible part of an expression. A symbol is either a @@ -72,7 +77,7 @@ A reference frame is a way to specify what an item is supposed to mean in a specific context. It can either be an element, a symbol or a token. For more information about reference frames see - MPReferenceFrame. + @link MPReferenceFrame@/link. Children:
Children are sub-elements of functions. The term children normally refers @@ -81,29 +86,84 @@ This terminology is consistent within the MathKit Expression System. Because symbols are the smalles possible unit of measurement elements and tokens both consist of one or more symbols. Similarly elements consist of one or more - tokens. You can convert between different reference frames using one the - following methods: -
- @textblock
-- convertIndexFromReferenceFrame:toReferenceFrame:
-- convertIndexFromReferenceFrame:toReferenceFrame:offset:
- @/textblock
- 
+ tokens. You can convert between different reference frames using the following + methods: +

Evaluating Expressions

A MPExpression instance can not evaluate itself. There are however - the -parse: and - -parseExpectingVariableDefinition:errors: methods. These parse and - thereby convert a MPExpression instance into a - MPParsedExpression instance that can be evaluated. For more - information on evaluation see the MPParsedExpression and - MPTerm class as well as the previously mentioned methods. -*/ + the @link parse:@/link and + @link parseExpectingVariable:errors:@/link methods. These parse and + thereby convert a MPExpression instance into a @link + //apple_ref/occ/cl/MPParsedExpression@/link instance that can be + evaluated. For more information on evaluation see the @link + //apple_ref/occ/cl/MPParsedExpression@/link and @link + //apple_ref/occ/cl/MPTerm@/link class as well as the previously mentioned + methods. + */ + + +/*! + @protocol MPExpressionElement + @abstract This protocol defines the functionality an element in an + expression must have. + */ +@protocol MPExpressionElement + +/*! + @method isString + @abstract Returns wether the receiver is a string. + + @discussion A string is defined by being an instance of + NSString. If this method returns YES + you can be sure the receiver is an NSString + instance. + + @return YES if the receiver is a string, NO + otherwise. + */ +- (BOOL)isString; + + +/*! + @method isFunction + @abstract Returns wether the receiver is a function. + + @discussion A function is defined by being an instance of + @link //apple_ref/occ/cl/MPFunction@/link. If this + method returns YES you can be sure the receiver is a + @link //apple_ref/occ/cl/MPFunction@/link instance. + + @return YES if the receiver is a function, NO + otherwise. + */ +- (BOOL)isFunction; + + +/*! + @method length + @abstract Calculates the length of the receiver. + + @discussion The length of a MPExpressionElement is the number of + symbols it consists of. For strings this is the number of + characters in it. Functions have a length of 1. + + @return The receiver's length. + */ +- (NSUInteger)length; + +@end + /*! @const MPIllegalElementException - @brief Name for an exception that is raised if an invalid element is + @abstract Name for an exception that is raised if an invalid element is added to an expression. @discussion This exception may be raised during initialization of an @@ -117,7 +177,7 @@ FOUNDATION_EXPORT NSString *const MPIllegalElementException; /*! @const MPIllegalElementExceptionElementKey - @brief Predefined key for an invalid element that caused a + @abstract Predefined key for an invalid element that caused a MPIllegalElementException to be raised. @discussion The invalid element can be of any type. Numbers and structs are @@ -129,7 +189,7 @@ FOUNDATION_EXPORT NSString *const MPIllegalElementExceptionElementKey; /*! @typedef MPReferenceFrame - @brief A reference frame specifies the way an item is to be + @abstract A reference frame specifies the way an item is to be interpreted. @constant MPElementReferenceFrame @@ -155,17 +215,14 @@ typedef enum { /*! @class MPExpression - @brief A MPExpression instance represents a mathematical + @abstract A MPExpression instance represents a mathematical expression. - @discussion Every expression consists of string elements (represented by the - NSString class) and function elements (represented - by the MPFunction class). Functions and expressions - make up the expression tree. + @discussion A expression consists of string elements and function elements. + Functions and expressions together make up the expression tree. */ @interface MPExpression : NSObject - #pragma mark Creation Methods /*! @methodgroup Creation Methods @@ -174,7 +231,7 @@ typedef enum { /*! @method init - @brief Initlializes a new expression. + @abstract Initlializes a new expression. @discussion This method is a convenience initializer to initialize an expression with 0 elements. @@ -186,7 +243,7 @@ typedef enum { /*! @method initWithElement: - @brief Initializes a new expression with the specified + @abstract Initializes a new expression with the specified element. @discussion This method is a convenience initializer to initialize an @@ -203,22 +260,23 @@ typedef enum { /*! @method initWithElements: - @brief Initializes a new expression with the specified + @abstract Initializes a new expression with the specified elements. - @discussion All elements must conform to the MPExpressionElement - protocol. If one or more objects do not conform to that protocol - a MPIllegalElementException is raised. + @discussion All elements must conform to the @link + MPExpressionElement@/link protocol. If one or more objects + do not conform to that protocol a @link + MPIllegalElementException@/link is raised. This method is the designated initializer for the MPExpression class. @param elements The elements that should be added to the expression. Every - element must conform to the MPExpressionElement - protocol. Each element is copied and the copy is then added to - the expression. The object in the elements array is - not modified. + element must conform to the @link + MPExpressionElement@/link protocol. Each element is copied + and the copy is then added to the expression. The object in the + elements array is not modified. @return An expression containing elements. */ @@ -233,13 +291,15 @@ typedef enum { /*! @property parent - @brief The receiver's parent. + @abstract The receiver's parent. @discussion The receiver's parent is the function in the expression tree that contains the receiver. @warning You should never set this property manually. If you are - implementing a custom subclass of MPFunction use the - MPFunctionAccessorImplementation macro. + implementing a custom subclass of @link + //apple_ref/occ/cl/MPFunction@/link use the @link + //apple_ref/occ/macro/MPFunctionAccessorImplementation@/link + macro. @return The parent of the receiver or nil if the receiver is the root expression. @@ -249,7 +309,7 @@ typedef enum { /*! @method rootExpression - @brief Returns the root expression from the receiver's expression tree. + @abstract Returns the root expression from the receiver's expression tree. @discussion The root expression is the ultimate parent of all expressions and functions in the expression tree. A root expression does not have @@ -262,7 +322,7 @@ typedef enum { /*! @method indexPath - @brief Returns the index path of the receiver in the expression tree. + @abstract Returns the index path of the receiver in the expression tree. @discussion The index path contains the indexes (starting from the root expression of the receiver's expression tree) that lead to the @@ -276,7 +336,7 @@ typedef enum { /*! @method countItemsInReferenceFrame: - @brief Returns the number of items in the receiver in the specified + @abstract Returns the number of items in the receiver in the specified referenceFrame. @param referenceFrame @@ -290,10 +350,11 @@ typedef enum { /*! @method itemAtIndex:referenceFrame: - @brief Returns the item at anIndex. + @abstract Returns the item at anIndex. @discussion The item is not copied before it is returned. So be aware that - if you mutate a MPFunction instance returned from + if you mutate a @link + //apple_ref/occ/cl/MPFunction@/link instance returned from this function the receiver's expression tree will be updated to reflect the change. @@ -314,7 +375,7 @@ typedef enum { /*! @method elementAtIndex:referenceFrame: - @brief Returns the element at the specified index. + @abstract Returns the element at the specified index. @discussion An element is either a string or a function. If anIndex identifies a position inside a string @@ -322,7 +383,7 @@ typedef enum { This method always returns elements. To query items in the specified reference frame use - -itemAtIndex:referenceFrame:. + @link itemAtIndex:referenceFrame:@/link. @param anIndex The index of the element. @@ -337,7 +398,7 @@ typedef enum { /*! @method indexOfElement: - @brief Returns the index of element or + @abstract Returns the index of element or NSNotFound if it was not found. @param element @@ -351,7 +412,7 @@ typedef enum { /*! @method itemsInRange:referenceFrame: - @brief Returns an array of the items that are located in the specified + @abstract Returns an array of the items that are located in the specified range. @discussion The objects in the returned array are copied before they are @@ -376,7 +437,7 @@ typedef enum { /*! @method allItemsInReferenceFrame: - @brief Returns an array of all items in the receiver for the specified + @abstract Returns an array of all items in the receiver for the specified reference frame. @discussion The elements in the returned array are not copied before they are @@ -391,15 +452,16 @@ typedef enum { /*! @method elementAtIndexPath: - @brief Returns the element at the specified index path. + @abstract Returns the element at the specified index path. @discussion This method finds the elements at the respective indexes starting at the root expression from the receiver's expression tree. The returned object can be a NSString, a - MPFunction or an MPExpression instance - depending on the specified indexPath. If any of the - indexes exceed the bounds of the respective receiver a - NSRangeException is raised. + @link //apple_ref/occ/cl/MPFunction@/link or a + MPExpression instance depending on the specified + indexPath. If any of the indexes exceed the bounds + of the respective receiver a NSRangeException is + raised. If the index path does not contain any indexes the receiver itself is returned. @@ -418,11 +480,12 @@ typedef enum { /*! @method convertIndex:fromReferenceFrame:toReferenceFrame: - @brief Converts an index from one reference frame to another. + @abstract Converts an index from one reference frame to another. @discussion This method ignores any offsets into items the conversion between reference frames can cause. If you are interested in the offset - use -convertIndex:fromReferenceFrame:toReferenceFrame:offset: + use @link + convertIndex:fromReferenceFrame:toReferenceFrame:offset:@/link instead. @param anIndex @@ -446,7 +509,7 @@ typedef enum { /*! @method convertIndex:fromReferenceFrame:toReferenceFrame:offset: - @brief Converts an index from one reference frame to another. + @abstract Converts an index from one reference frame to another. @discussion If anIndex identifies a location inside an item in the toReferenceFrame the index of the corresponding @@ -481,18 +544,20 @@ typedef enum { /*! @method convertRange:fromReferenceFrame:toReferenceFrame: - @brief Converts a range from one reference frame to another. + @abstract Converts a range from one reference frame to another. @discussion This method just converts the location and target of the range separately using - -convertIndex:fromReferenceFrame:toReferenceFrame:. + @link + convertIndex:fromReferenceFrame:toReferenceFrame:@/link. It ensures that the returned range definitely includes all items that were specified by aRange. The possibility that the returned range may include more symbols than aRange is ignored. If you need that information use - -convertRange:fromReferenceFrame:toReferenceFrame:leadingOffset:trailingOffset:. + @link + convertRange:fromReferenceFrame:toReferenceFrame:leadingOffset:trailingOffset:@/link. @param aRange The range to be converted. @@ -513,11 +578,12 @@ typedef enum { /*! @method convertRange:fromReferenceFrame:toReferenceFrame:leadingOffset:trailingOffset: - @brief Converts a range from one reference frame to another. + @abstract Converts a range from one reference frame to another. @discussion This method just converts the location and target of the range separately using - -convertIndex:fromReferenceFrame:toReferenceFrame:. + @link + convertIndex:fromReferenceFrame:toReferenceFrame:@/link. It ensures that the returned range definitely includes all items that were specified by aRange. @@ -538,8 +604,8 @@ typedef enum { The offset of the last index in the range in respect to the last index of aRange. - @return A range in the toReferenceFrame that includes the the items - specified by aRange. + @return A range in the toReferenceFrame that includes the + the items specified by aRange. */ - (NSRange)convertRange:(NSRange)aRange fromReferenceFrame:(MPReferenceFrame)fromReferenceFrame @@ -556,7 +622,7 @@ typedef enum { /*! @method replaceItemsInRange:referenceFrame:withElements: - @brief Replaces the elements in the specified range with the contents of + @abstract Replaces the elements in the specified range with the contents of the elements array. @discussion This is the most primitive mutation method of @@ -567,8 +633,9 @@ typedef enum { is restored. That basically means that subsequent strings are joined and empty strings removed. After restoring integrity the receiver sends a - -changedElementsInIndexedRangePath:replacementLength: - to itself. For more information see the documentation on that + @link + changedElementsInRangePath:replacementLength:@/link to + itself. For more information see the documentation on that method. @param aRange @@ -588,16 +655,16 @@ typedef enum { /*! @method changedElementsInRangePath:replacementLength: - @brief This is a notification message that is sent from the receiver to + @abstract This is a notification message that is sent from the receiver to itself after it has been mutated. @discussion This method does nothing more than notify it's parent that it has been mutated at the respective range path. If you want to get notified about changes in an expression you should override this - method instead of - -replaceSymbolsInRange:withElements: because this - method gives you information about the elements that changed - during the mutation. + method instead of @link + replaceItemsInRange:referenceFrame:withElements:@/link + because this method gives you information about the elements that + changed during the mutation. @param rangePath The range path at which the receiver was changed starting at the @@ -615,7 +682,7 @@ typedef enum { /*! @method subexpressionFromIndex:referenceFrame: - @brief Creates an expression from the items in the receiver from the + @abstract Creates an expression from the items in the receiver from the specified index to the end. @discussion The items from the receiver are copied. Mutations to the returned @@ -636,7 +703,7 @@ typedef enum { /*! @method subexpressionToIndex:referenceFrame: - @brief Creates an expression from the items in the receiver from the + @abstract Creates an expression from the items in the receiver from the first to the specified item. @discussion The items from the receiver are copied. Mutations to the returned @@ -658,7 +725,7 @@ typedef enum { /*! @method subexpressionWithRange:referenceFrame: - @brief Creates an expression from the items in the receiver within the + @abstract Creates an expression from the items in the receiver within the specified range. @discussion The items from the receiver are copied. Mutations to the returned @@ -685,10 +752,10 @@ typedef enum { /*! @method parse: - @brief Parses the receiver. + @abstract Parses the receiver. - @discussion This is a convenience method that calls - -parseExpectingVariable:errors: with NO + @discussion This is a convenience method that calls @link + parseExpectingVariable:errors:@/link with NO as the first argument. @param errors @@ -698,17 +765,18 @@ typedef enum { set to an empty array. Pass NULL if you are not interested in any errors that might occur. - @return A MPParsedExpression instance that represents the - receiver and can be evaluated or nil if an error - occurs. In that case the errors parameter is set to - an array containing at least one NSError instance. + @return A @link //apple_ref/occ/cl/MPParsedExpression@/link + instance that represents the receiver and can be evaluated or + nil if an error occurs. In that case the + errors parameter is set to an array containing at + least one NSError instance. */ - (MPParsedExpression *)parse:(NSArray *__autoreleasing *)errors; /*! @method parseExpectingVariable:errors: - @brief Parses the receiver. + @abstract Parses the receiver. @param flag If YES the receiver must (exept for whitespaces) @@ -723,10 +791,11 @@ typedef enum { set to an empty array. Pass NULL if you are not interested in any errors that might occur. - @return A MPParsedExpression instance that represents the - receiver and can be evaluated or nil if an error - occurs. In that case the errors parameter is set to - an array containing at least one NSError instance. + @return A @link //apple_ref/occ/cl/MPParsedExpression@/link + instance that represents the receiver and can be evaluated or + nil if an error occurs. In that case the + errors parameter is set to an array containing at + least one NSError instance. */ - (MPParsedExpression *)parseExpectingVariable:(BOOL)flag errors:(NSArray *__autoreleasing *)errors; @@ -737,7 +806,7 @@ typedef enum { /*! @category MPExpression (MPExpressionConvenience) - @brief This category defines convenience methods for the + @abstract This category defines convenience methods for the MPExpression class. @discussion All convenience methods are completely defined in terms of other @@ -753,7 +822,7 @@ typedef enum { /*! @method countElements - @brief Returns the number of elements in the receiver. + @abstract Returns the number of elements in the receiver. @return The number of elements in the receiver expressed in the element reference frame. @@ -763,7 +832,7 @@ typedef enum { /*! @method countSymbols - @brief Returns the number of symbols in the receiver. + @abstract Returns the number of symbols in the receiver. @return The number of symbols in the receiver expressed in the symbol reference frame. @@ -773,7 +842,7 @@ typedef enum { /*! @method countTokens - @brief Returns the number of tokens in the receiver. + @abstract Returns the number of tokens in the receiver. @return The number of tokens in the receiver expressed in the token reference frame. @@ -783,7 +852,7 @@ typedef enum { /*! @method elementAtIndex: - @brief Returns the element at the specified index. + @abstract Returns the element at the specified index. @param anIndex The index of the element specified in the element reference @@ -796,7 +865,7 @@ typedef enum { /*! @method symbolAtIndex: - @brief Returns the symbol at the specified index. + @abstract Returns the symbol at the specified index. @param anIndex The index of the symbol specified in the symbol reference frame. @@ -808,7 +877,7 @@ typedef enum { /*! @method tokenAtIndex: - @brief Returns the token at the specified index. + @abstract Returns the token at the specified index. @param anIndex The index of the token specified in the token reference frame. @@ -826,7 +895,7 @@ typedef enum { /*! @method appendElement: - @brief Appends anElement to the receiver. + @abstract Appends anElement to the receiver. @param anElement The element to append to the receiver. @@ -836,12 +905,12 @@ typedef enum { /*! @method appendElements: - @brief Appends the objects from elements to the receiver. + @abstract Appends the objects from elements to the receiver. @discussion All objects in the elements array must conform to - the MPExpressionElement protocol. If at least one - element does not conform to that protocol a - MPIllegalElementException is raised. + the @link MPExpressionElement@/link protocol. If at + least one element does not conform to that protocol a @link + MPIllegalElementException@/link is raised. @param elements The elements to append to the receiver. @@ -851,7 +920,7 @@ typedef enum { /*! @method insertElement:atIndex:referenceFrame: - @brief Inserts anElement at the specified index. + @abstract Inserts anElement at the specified index. @param anElement The element to be inserted. @@ -869,12 +938,12 @@ typedef enum { /*! @method insertElements:atIndex:referenceFrame: - @brief Inserts elements at the specified index. + @abstract Inserts elements at the specified index. @discussion All objects in the elements array must conform to - the MPExpressionElement protocol. If at least one - element does not conform to that protocol a - MPIllegalElementException is raised. + the @link MPExpressionElement@/link protocol. If at + least one element does not conform to that protocol a @link + MPIllegalElementException@/link is raised. @param elements The elements to be inserted. @@ -891,8 +960,8 @@ typedef enum { /*! - @method deleteElementsInRange: - @brief Removes the elements identified by range from the + @method deleteElementsInRange:referenceFrame: + @abstract Removes the elements identified by range from the receiver. @discussion If range exceeds the receiver's bounds a diff --git a/MathKit/MPExpression.m b/MathKit/MPExpression.m index e91f6a2..6d201a5 100644 --- a/MathKit/MPExpression.m +++ b/MathKit/MPExpression.m @@ -8,7 +8,7 @@ #import "MPExpression.h" -#import "MPExpressionElement.h" +#import "MPExpression.h" #import "MPFunction.h" #import "MPRangePath.h" @@ -32,7 +32,7 @@ NSString *const MPIllegalElementExceptionElementKey = @"MPIllegalElementExceptio /*! @method tokens - @brief Private method. Returns an array containing all tokens from the + @abstract Private method. Returns an array containing all tokens from the receiver. @return All items in the MPTokenReferenceFrame. @@ -42,7 +42,7 @@ NSString *const MPIllegalElementExceptionElementKey = @"MPIllegalElementExceptio /*! @method validateElements: - @brief Private method. Checks whether all objects in the specified array + @abstract Private method. Checks whether all objects in the specified array are valid expression elements. @discussion If an object is not valid a @@ -56,7 +56,7 @@ NSString *const MPIllegalElementExceptionElementKey = @"MPIllegalElementExceptio /*! @method fixElements - @brief Private method. Restores consistency in the receiver after a + @abstract Private method. Restores consistency in the receiver after a change was made. */ - (void)fixElements; @@ -64,7 +64,7 @@ NSString *const MPIllegalElementExceptionElementKey = @"MPIllegalElementExceptio /*! @method _replaceSymbolsInRange:withElements: - @brief Private method. Replaces the symbols in the specified range with + @abstract Private method. Replaces the symbols in the specified range with the elements from the elements array. @discussion This is the most primitive mutation method of the @c MPExpression @@ -85,7 +85,7 @@ NSString *const MPIllegalElementExceptionElementKey = @"MPIllegalElementExceptio /*! @method _splitElementsAtLocation:insertionIndex: - @brief Splits the receiver's elements at the specified + @abstract Splits the receiver's elements at the specified location. @discussion The split location can be inside a string element. In that case diff --git a/MathKit/MPExpressionElement.h b/MathKit/MPExpressionElement.h deleted file mode 100644 index 12f89d7..0000000 --- a/MathKit/MPExpressionElement.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// MPExpressionElement.h -// MathPad -// -// Created by Kim Wittenburg on 10.08.14. -// Copyright (c) 2014 Kim Wittenburg. All rights reserved. -// - - - -/*! - @protocol MPExpressionElement - @brief This protocol defines the functionality an element in an - expression must have. - */ -@protocol MPExpressionElement - - -/*! - @method isString - @brief Returns wether the receiver is a string. - - @discussion A string is defined by being an instance of @c NSString. If this - method returns @c YES you can be sure it is an @c NSString - instance. - - @return @c YES if the receiver is a string, @c NO otherwise. - */ -- (BOOL)isString; - - -/*! - @method isFunction - @brief Returns wether the receiver is a function. - - @discussion A function is defined by being an instance of @c MPFunction. If - this method returns @c YES you can be sure it is a @c MPFunction - instance. - - @return @c YES if the receiver is a function, @c NO otherwise. - */ -- (BOOL)isFunction; - - -/*! - @method length - @brief Calculates the length of the receiver. - - @discussion The length of a @c MPExpressionElement is the number of symbols - it consists of. For strings this is the number of characters in - it. Functions have a length of @c 1. - - @return The receiver's length. - */ -- (NSUInteger)length; - -@end diff --git a/MathKit/MPExpressionLayout.m b/MathKit/MPExpressionLayout.m index 325dfbf..30333fa 100644 --- a/MathKit/MPExpressionLayout.m +++ b/MathKit/MPExpressionLayout.m @@ -9,7 +9,7 @@ #import "MPExpressionLayout.h" #import "MPExpression.h" -#import "MPExpressionElement.h" +#import "MPExpression.h" #import "MPPowerFunction.h" #import "MPFunctionLayout.h" diff --git a/MathKit/MPExpressionParser.h b/MathKit/MPExpressionParser.h index 6fa89f6..217f5eb 100644 --- a/MathKit/MPExpressionParser.h +++ b/MathKit/MPExpressionParser.h @@ -7,17 +7,139 @@ // +/*! + @header + The MPExpressionParser converts a @link + MPExpression@/link instance into a @link + //apple_ref/occ/cl/MPParsedExpression@/link instance. The rules that are + used for parsing expressions are consistent with general math rules. For example + operator precedence and parenthesis are regarded. However there may still be + ambiguous input. The parser solves them by using the following rules: + + 1. Powers and factorials apply to the value that directly precedes them. + It is invalid if a power or factorial symbol is preceded by a space. + 2. Powers and factorials chained behind each other apply to the value before the + first power or factorial symbol in the chain (provided that rule 1 is + satisfied). All powers and factorials apply to that value in the order of + occurence. For example 2³! is valid and equal to + (2³)!. + 3. Elementary functions like sin, cos or + ln can be chained. sincos(2) is equal to + sin(cos(2)). + 4. Subsequent elementary functions with values are implicitly multiplied. + sin3cos2 is equal to sin(3)⋅cos(2). + 5. The value of an elementary function is either exactly one generic function + (instances of a @link MPFunction@/link subclass) or a group of + numbers and variables that does not contain a multiplication, plus or minus + sign. sin2a⋅3 is equal to (sin(2a))⋅3. + + Besides the rules above the parser accepts inputs containing the following + constructs: + + 1. Chained plus and minus signs (e.g. ++-+--3 is equal to + -3). + 2. Implicit multiplication. 2a3 is equal to 2⋅a⋅3. + */ + + @class MPExpressionParser, MPExpression, MPParsedExpression; +/*! + @class MPExpressionParser + @abstract An instance of this class can parse an expression. + + @discussion Parsing an expression means converting it into a @link + //apple_ref/occ/cl/MPParsedExpression@/link instance. One + parser can only process one expression. After the parser has been + constructed it should start processing the expression before it + is mutated. For the same reason parsers should not be recycled + but instead recreated when needed. + */ @interface MPExpressionParser : NSObject +/*! + @property expression + @abstract The receiver's expression. + */ @property (readonly, nonatomic, strong) MPExpression *expression; -- (instancetype)initWithExpression:(MPExpression *)expression; +/*! + @method initWithExpression: + @abstract Initializes a new MPExpressionParser. + + @discussion After this method returns the parser is ready to parse the given + expression. If the expression is mutated between the + creation of the parser and the actual parsing process unexpected + behaviour may occur. + + This is the designated initializer for the + MPExpressionParser class. + + @param expression + The expression that is supposed to be parsed. + + @return A newly initialized expression parser. + */ +- (instancetype)initWithExpression:(MPExpression *)expression; /* designated initializer */ + + +/*! + @method parse: + @abstract Parses the receiver's expression. + + @discussion If the expression contains any syntax errors they will be + returned indirectly through the errors parameter. In + that case nil is returned. If no errors occur it is + not modified. + + This is a convenience method that calls @link + parseExpectingVariableDefinition:errors:@/link with + NO as the first argument. + + @param errors + If the parsed expression contains syntax errors this parameter + will be set to an array containing at least one + NSError instance. This parameter is never set to an + empty array. + + If you are not interested in errors, pass NULL. + + @return The parsed expression or nil if the parsed + expression contains syntax errors. + */ - (MPParsedExpression *)parse:(NSArray *__autoreleasing *)errors; + + +/*! + @method parseExpectingVariableDefinition:errors: + @abstract Parses the receiver's expression. + + @discussion If the expression contains any syntax errors they will be + returned indirectly through the errors parameter. In + that case nil is returned. If no errors occur it is + not modified. + + @param flag + If set to YES the parser expects the expression to + begin with a variable definition, that is a single letter + followed by an equals sign (exept for spaces). If set to + NO there must not be a variable definition. + + @param errors + If the parsed expression contains syntax errors this parameter + will be set to an array containing at least one + NSError instance. This parameter is never set to an + empty array. + + If you are not interested in errors, pass NULL. + + @return The parsed expression or nil if the parsed + expression contains syntax errors. + */ + - (MPParsedExpression *)parseExpectingVariableDefinition:(BOOL)flag errors:(NSArray *__autoreleasing *)errors; diff --git a/MathKit/MPExpressionTokenizer.h b/MathKit/MPExpressionTokenizer.h index 035d504..1c6d7ae 100644 --- a/MathKit/MPExpressionTokenizer.h +++ b/MathKit/MPExpressionTokenizer.h @@ -13,24 +13,28 @@ /*! @class MPExpressionTokenizer - @brief The expression tokenizer class convers an @c MPExpression - instance into an array of tokens. + @abstract The expression tokenizer class convers an @link + MPExpression@/link instance into an array of tokens. */ @interface MPExpressionTokenizer : NSObject - /*! @method tokenizeExpression: - @brief Converts an @c MPExpression instance into an array of tokens. + @abstract Converts an @link MPExpression@/link instance into + an array of tokens. - @discussion The objects in the returned array all conform to the @c MPToken - protocol. Function tokens are not copied from the @c expression - so they can still be mutated. + @discussion The objects in the returned array all conform to the @link + //apple_ref/occ/intf/MPToken@/link protocol. Function + tokens are not copied from the expression so they + can still be mutated. + + This method can be safely called from multiple threads. @param expression The expression to be tokenized. - @return An array of objects that conform to the @c MPToken protocol. + @return An array of objects that conform to the @link + //apple_ref/occ/intf/MPToken@/link protocol. */ + (NSArray *)tokenizeExpression:(MPExpression *)expression; diff --git a/MathKit/MPExpressionTokenizer.m b/MathKit/MPExpressionTokenizer.m index dc89573..09914bd 100644 --- a/MathKit/MPExpressionTokenizer.m +++ b/MathKit/MPExpressionTokenizer.m @@ -9,7 +9,7 @@ #import "MPExpressionTokenizer.h" #import "MPExpression.h" -#import "MPExpressionElement.h" +#import "MPExpression.h" #import "MPToken.h" diff --git a/MathKit/MPFactorialTerm.h b/MathKit/MPFactorialTerm.h index 3e4f304..ec2450c 100644 --- a/MathKit/MPFactorialTerm.h +++ b/MathKit/MPFactorialTerm.h @@ -13,10 +13,35 @@ @class MPFactorialTerm; +/*! + @class MPFactorialTerm + @abstract A factorial term implements the factorial function. + + @discussion Because the factorial function is only defined for whole numbers, + actually the gamma function is used. The gamma function is + defined for all real numbers. + */ @interface MPFactorialTerm : MPTerm +/*! + @method initWithTerm: + @abstract Initializes the receiver with the specified term. + + @discussion The term is not copied. + + @param term + The term to initialize the receiver. Must not be + nil. + + @return A newly initialized factorial term. + */ - (instancetype)initWithTerm:(MPTerm *)term; /* designated initializer */ + +/*! + @property term + @abstract The receiver's term. + */ @property (readonly, nonatomic, strong) MPTerm *term; @end diff --git a/MathKit/MPFractionFunction.h b/MathKit/MPFractionFunction.h index 5667b6c..83a71b8 100644 --- a/MathKit/MPFractionFunction.h +++ b/MathKit/MPFractionFunction.h @@ -15,28 +15,31 @@ /*! @class MPFractionFunction - @brief This class represents a fraction. + @abstract This class represents a fraction. - @discussion When a fraction is evaluated the nominator is divided by the - denominator. + @discussion A fraction has two children: the nominator and the denominator. + Typically it is displayed with a horizontal bar between the two + child expressions which are on top and below the bar + respectively. When a fraction is evaluated the nominator is + divided by the denominator. */ @interface MPFractionFunction : MPFunction /*! @property nominatorExpression - @brief The receiver's nominator. + @abstract The receiver's nominator. @discussion The nominator must not define a variable. */ -@property (nonatomic, strong) MPExpression *nominatorExpression; +@property (nonatomic, strong) MPExpression *nominatorExpression; /* Index 0 */ /*! @property denominatorExpression - @brief The receiver's denominator. + @abstract The receiver's denominator. @discussion The denominator must not define a variable. */ -@property (nonatomic, strong) MPExpression *denominatorExpression; +@property (nonatomic, strong) MPExpression *denominatorExpression; /* Index 1 */ @end diff --git a/MathKit/MPFunction+MPToken.h b/MathKit/MPFunction+MPToken.h index 864957a..d567982 100644 --- a/MathKit/MPFunction+MPToken.h +++ b/MathKit/MPFunction+MPToken.h @@ -13,8 +13,9 @@ /*! @category MPFunction (MPToken) - @brief This category adds @c MPToken protocol conformance to the @c - MPFunction class. + @abstract This category adds @link + //apple_ref/occ/intf/MPToken@/link protocol conformance to + the @link MPFunction@/link class. */ @interface MPFunction (MPToken) diff --git a/MathKit/MPFunction.h b/MathKit/MPFunction.h index 6285397..3bd420f 100644 --- a/MathKit/MPFunction.h +++ b/MathKit/MPFunction.h @@ -6,14 +6,62 @@ // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // -#import "MPExpressionElement.h" +#import "MPExpression.h" + + +/*! + @header + MPFunction is a half abstract class that is designed to be + subclassed. Subclasses of the MPFunction class (subsequently called + functions) need to regard the following guidelines: + + 1. In their header file functions should declare readwrite, + nonatomic properties for every child (subexpression) they have. + 2. For every public child accessor there should be one use of the + @link MPFunctionAccessorImplementation@/link macro in the + implementation file. See the documentation on the macro for details. + 3. Functions must override the @link childrenAccessors@/link method + returning the KVC compatible names of the publicly declared property accessors + 4. Functions must also override the @link functionTermClass@/link + method returning a Class that can evaluate the function. See the + documentation on that method for details. + 5. Optionally functions can implement + @link expectsVariableDefinitionInChildAtIndex:@/link if one of + its children is supposed to contain a variable definition. + 6. Functions should also override the NSObject method + description. Although this is not a requirement it + is strongly recommended. + + Functions play an important role in the expression tree. For details on + the that subject see the documentation for @link + MPExpression@/link. + + @note + None of the children of a function may be nil at any time. + */ -/* Use this macro to implement a custom setter for children of custom MPFunction - * subclasses. This is necessary to maintain the consistency of the expression - * tree. Not implementing a custom setter using this macro or a similar custom - * method will lead to unexpected behaviour. +/*! + @define MPFunctionAccessorImplementation + @abstract This macro implements the setter of a previously declared + property of a MPFunction subclass. + + @discussion Overriding the default setter implementation is necessary to + maintain the consistency of the expression tree. Not implementing + a custom setter using this macro or a similar custom method will + lead to unexpected behaviour. If you need to implement additional + custom behaviour in a property setter it is recommended that you + copy the content of the macro. + + @param Accessor + The capitalized name of the property to be implemented. This is + used for the name of the method: set.... + + @param variableName + The name of the instance variable that backs the property. + Normally this is the same as the name of the property prefixed + with an underscore. */ #define MPFunctionAccessorImplementation(Accessor, variableName) \ - (void)set##Accessor:(MPExpression *)value \ @@ -32,25 +80,15 @@ /*! @class MPFunction - @brief The @c MPFunction class represents a mathematical function. + @abstract The MPFunction class represents a mathematical function. @discussion A mathematical function can be anything that exceeds the - graphical capability of text. + graphical capability of text. Functions like sin, + cos or ln are not considered functions + in this context because they can be represented by text. */ @interface MPFunction : NSObject -#pragma mark Properties -/* Subclasses should define readwrite properties for all child expressions they - * can have. In the implementation file the property setter should be overridden - * using the @c MPFunctionAccessorImplementation macro. The macro takes two - * parameters: The capitalized name of the property and the name of the - * property's backing variable (usually the property's name prefixed with an - * underscore. - * - * Note that none of the children may be nil at any time. - */ - - #pragma mark Working With the Expression Tree /*! @methodgroup Working With the Expression Tree @@ -59,86 +97,85 @@ /*! @property parent - @brief The receiver's parent. + @abstract The receiver's parent. @discussion Expressions and functions are organized in a tree-like structure. Through this property a function's containing expression can be accessed. @warning Do not set this property manually. It will automatically be set - when the function is added to an expression. + when the function is added to or removed from an expression. @note If you need to know when a function is added to or removed from - an expression you can observe this property. + an expression you can observe this property using KVO. - @return The parent of the receiver or @c nil if the receiver does not - have a parent. + @return The parent of the receiver or nil if the receiver + does not have a parent. */ @property (nonatomic, weak) MPExpression *parent; /*! @method rootExpression - @brief Returns the root expression from the receiver's expression tree. + @abstract Returns the root expression from the receiver's expression tree. @discussion The root expression is the ultimate parent of all expressions and functions in the expression tree. A root expression does not have a parent. - @return The root expression from the receiver's expression tree or @c nil - if this function does not have a parent. + @return The root expression from the receiver's expression tree or + nil if this function does not have a parent. */ - (MPExpression *)rootExpression; /*! @method indexPath - @brief Returns the index path of the receiver in the expression tree. + @abstract Returns the index path of the receiver in the expression tree. - @discussion The index path is calculated by going up the expression tree - collecting the respective index of the receiver. The indexes are - expressed in the element reference frame. If any of the indexes - exceed the respective receiver's bounds a @c NSRangeException is - raised. + @discussion The index path contains the indexes (starting from the root + expression of the receiver's expression tree) that lead to the + receiver. The indexes are expressed in the element reference + frame. - @return The index path of the receiver in the expression tree or @c nil - if this function does not have a parent. + @return The index path of the receiver in the expression tree or + nil if this function does not have a parent. */ - (NSIndexPath *)indexPath; /*! @method numberOfChildren - @brief Returns the number of children the receiver has. + @abstract Returns the number of children the receiver has. - @discussion The number of children must be equal to the number of child - accessors as determined by the @c -childrenAccessors method. - - @return The number of children of the receiving function. + @return The number of children the receiving function has. */ - (NSUInteger)numberOfChildren; /*! @method childAtIndex: - @brief Returns the child at the specified index. + @abstract Returns the child at the specified index. @discussion The ordering of children is determined by the order of the - children returned from the @c -childrenAccessors method. + child accessors as returned from the + @link childrenAccessors@/link method. @param index The index of the requested child. - @return The expression that corresponds to the child at @c index. + @return The expression that corresponds to the child at + index. */ - (MPExpression *)childAtIndex:(NSUInteger)index; /*! @method setChild:atIndex: - @brief Sets the child at the specified index. + @abstract Sets the child at the specified index. - @discussion Although this method does @b not call the respective accessor + @discussion Although this method does not call the respective accessor methods it behaves exactly as the setter method implemented using - the @c MPFunctionAccessorImplementation macro. + the @link MPFunctionAccessorImplementation@/link + macro. @param child The child that should replace the previous one. @@ -152,10 +189,10 @@ /*! @method children - @brief Returns the receiver's children. + @abstract Returns the receiver's children. @discussion The ordering of the children is the same as in the array returned - from @c -childrenAccessors. + from @link childrenAccessors@/link. @return An array containing all the function's children. */ @@ -164,27 +201,29 @@ /*! @method indexOfChild: - @brief Returns the index of @c child in the receiver. + @abstract Returns the index of child in the receiver. @param child The child to be searched. - @return The index of @c child or @c NSNotFound if none of the receiver's - children is equal to @c child. + @return The index of child or NSNotFound if + none of the receiver's children is equal to child. */ - (NSUInteger)indexOfChild:(MPExpression *)child; /*! @method elementAtIndexPath: - @brief Returns the element at the specified index path. + @abstract Returns the element at the specified index path. - @discussion This method @em walks down the expression tree (including other - functions) using the specified index path and finds the - corresponding element. The returned object can be an @c NSString, - a @c MPFunction or an @c MPExpression depending on the element @c - indexPath points to. If any of the indexes exceed the bounds of - the respective receiver an @c NSRangeException is raised. + @discussion This method finds the elements at the respective indexes starting + at the root expression from the receiver's expression tree. + The returned object can be a NSString, a + MPFunction or a @link + MPExpression@/link instance depending on the specified + indexPath. If any of the indexes exceed the bounds + of the respective receiver a NSRangeException is + raised. If the index path does not contain any indexes the receiver itself is returned. @@ -193,9 +232,10 @@ The index path the required object is located at. The indexes are expressed in the element reference frame. - @return The element located at @c indexPath. The element is not copied - before it is returned. Be aware of the fact that any mutations - made to the returned object are reflected in the receiver. + @return The element located at indexPath. The element is not + copied before it is returned. Be aware of the fact that any + mutations made to the returned object will update the receiver's + expression tree to reflect the change. */ - (id)elementAtIndexPath:(NSIndexPath *)indexPath; @@ -208,11 +248,11 @@ /*! @method didChangeElementsInRangePath:replacementLength: - @brief Notification method that is called if one of the children was - mutated. + @abstract This Notification message is sent automatically from the receiver + to itself if one of its children was mutated or changed. - @discussion This method is also called when one of the children is changed - via one of the accessor methods. + @discussion This method should also be called when one of the children is + changed via one of the accessor methods. @param rangePath The location of the change that happened. Because it may have @@ -229,12 +269,13 @@ /*! @method didChangeChildAtIndex: - @brief Convenience method that calls @c - -didChangeElementsInRangePath:replacementLength: + @abstract Convenience method that calls + @link + didChangeElementsInRangePath:replacementLength:@/link @discussion This method is automatically called when one of the children is - changed using one of the accessor methods or @c - -setChild:atIndex:. + changed using one of the accessor methods or + @link setChild:atIndex:@/link. @param index The index of the child that was changed. @@ -250,20 +291,21 @@ /*! @method expectsVariableDefinitionInChildAtIndex: - @brief Returns whether the child at @c anIndex is supposed to contain a - variable definition. + @abstract Returns whether the child at anIndex is supposed to + contain a variable definition. - @discussion This method is automatically called during expression parsing. + @discussion This method is automatically called during the parsing process. You can override this method to opt into the default behaviour. If you override this method you do not need to call super. - The default implementation just returns @c NO for every index. + The default implementation just returns NO for every + index. @param anIndex The index of the child to check. - @return @c YES if the child at @c anIndex is supposed to contain a - variable definition, @c NO otherwise. + @return YES if the child at anIndex is supposed + to contain a variable definition, NO otherwise. */ - (BOOL)expectsVariableDefinitionInChildAtIndex:(NSUInteger)anIndex; @@ -272,22 +314,16 @@ /*! - @category MPFunction (MPSubcalssOverride) - @brief The methods in this category must be implemented by any concrete - subclasses of @c MPFunction. + @category MPFunction (MPSubclassOverride) + @abstract The methods in this category must be implemented by any concrete + subclasses of MPFunction. - @discussion @c MPFunction does not implement the functions itself but calls + @discussion MPFunction does not implement the functions itself but calls them at various points. If a subclass does not provide implementations your app will most likely crash. */ @interface MPFunction (MPSubclassOverride) -/* In Addition to the methods listed below MPFunction subclasses should also - * override the NSObject method -description. - * Also -expectsVariabledefinitionInChildAtIndex: can be overridden if one of the - * children should contain a variable definition. - */ - #pragma mark Working With the Expression Tree /*! @methodgroup Working With the Expression Tree @@ -296,11 +332,9 @@ /*! @method childrenAccessors - @brief Returns the names of the children properties. + @abstract Returns the names of the children properties as strings. - @discussion A @c MPFunction subclass should declare a public propertiy for - every child it can have. This method should return the names as - they would be used for key-value-coding. + @discussion All objects in the returned array must be strings. @return An array of strings describing the names of children a function has. @@ -316,14 +350,18 @@ /*! @method functionTermClass - @brief Returns the class that represents the receiver's evaluation + @abstract Returns the class that represents the receiver's evaluation behaviour. - @discussion The class returned must be a subclass of @c MPFunctionTerm. That - class must not implement a custom initializer. + @discussion Subclasses of MPFunction can (like + @link MPExpression@/link) not evaluate themselves. + Instead this method is called on every function. The returned + class must be a valid subclass of @link + //apple_ref/occ/cl/MPFunctionTerm@/link. It will be + instanciated using the init method. - @return The @c MPFunctionTerm subclass that can evaluate instances of the - receiver's class. + @return The @link //apple_ref/occ/cl/MPFunctionTerm@/link + subclass that can evaluate instances of the receiver's class. */ - (Class)functionTermClass; diff --git a/MathKit/MPNegatedTerm.h b/MathKit/MPNegatedTerm.h index 49ec16c..7c4b305 100644 --- a/MathKit/MPNegatedTerm.h +++ b/MathKit/MPNegatedTerm.h @@ -13,10 +13,30 @@ @class MPNegatedTerm; +/*! + @class MPNegatedTerm + @abstract A negated term is a term whose value is multiplied by + -1. + */ @interface MPNegatedTerm : MPTerm + +/*! + @method initWithTerm: + @abstract Initializes a new negated term. + + @param term + The term the receiver is to be initialized with. + + @return A new negated term. + */ - (instancetype)initWithTerm:(MPTerm *)term; /* designated initializer */ + +/*! + @property term + @abstract The receiver's term. + */ @property (readonly, nonatomic, strong) MPTerm *term; @end diff --git a/MathKit/MPParenthesisFunction.h b/MathKit/MPParenthesisFunction.h index 128ae70..813847b 100644 --- a/MathKit/MPParenthesisFunction.h +++ b/MathKit/MPParenthesisFunction.h @@ -15,21 +15,21 @@ /*! @class MPParenthesisFunction - @brief A parenthesis function encapsulates a single expression and thus + @abstract A parenthesis function encapsulates a single expression and thus prioritizes it in evaluation. @discussion Prioritizing the expression means that the complete expression - must be evaluated 'as is'. No part of it can be 'used' elsewhere - before the parenthesis function has been evaluated. + must be evaluated as is. No part of it can be used + elsewhere before the parenthesis function has been evaluated. */ @interface MPParenthesisFunction : MPFunction /*! @property expression - @brief The expression encapsulated by the parenthesis. + @abstract The expression encapsulated by the parenthesis. @discussion The expression must not define a variable. */ -@property (nonatomic, strong) MPExpression *expression; +@property (nonatomic, strong) MPExpression *expression; /* Index 0 */ @end diff --git a/MathKit/MPParsedExpression.h b/MathKit/MPParsedExpression.h index 283d826..273a4b0 100644 --- a/MathKit/MPParsedExpression.h +++ b/MathKit/MPParsedExpression.h @@ -13,24 +13,97 @@ /*! @const MPMathKitErrorDomain - @brief Predefined error domain for errors from the MathKit framework. + @abstract Predefined error domain for errors from the MathKit framework. - @discussion Errors in MathKit can occur during parsing of expressions or - during evaluation of expressions. These two can be distinguished - by the error code. Parsing errors have lower error codes. - Evaluation errors (math errors) have error codes from @c 100 upwards. + @discussion Errors in MathKit can occur during parsing or evaluation of + expressions. These two can be distinguished by their respective + error codes. Parsing errors have error codes below + 100. Evaluation errors (math errors) on the other + hand have error codes from 100 upwards. */ FOUNDATION_EXPORT NSString *const MPMathKitErrorDomain; + +/*! + @const MPPathToExpressionKey + @abstract Predefined key for the path to the expression that caused an error. + + @discussion Parsing errors in the MPMathKitErrorDomain have a + value for this key in their userInfo dictionary. The + value is of type NSIndexPath. The root of that path + is also the root expression of the expression tree of the + expression that was parsed (which in turn caused an error). + */ FOUNDATION_EXPORT NSString *const MPPathToExpressionKey; + + +/*! + @const MPErrorRangeKey + @abstract Predefined key for the range inside an expression that caused a + parsing error. + + @discussion Parsing errors in the MPMathKitErrorDomain have a + value for this key in their userInfo dictionary. The + value is a NSRange value wrapped in a + NSValue object. + */ FOUNDATION_EXPORT NSString *const MPErrorRangeKey; +/*! + @class MPParsedExpression + @abstract A parsed expression represents an expression whose syntax is + mathematically valid and thus can be evaluated. + + @discussion This class should not be instanciated directly. Instead you + should use the parse... methods from the @link + //apple_ref/occ/cl/MPExpression@/link class. A + successfully parsed expression can still fail to be evaluated if + it contains mathematically undefined expressions. + */ @interface MPParsedExpression : NSObject +/*! + @property definedVariable + @abstract The variable defined by the expression, if any. + + @discussion If a variable was defined this property is a string of length + 1 containing the name of that variable. If no + variable was defined this property is nil. + + This property should not be set manually. + */ @property (nonatomic, strong) NSString *definedVariable; + + +/*! + @property term + @abstract The receiver's evaluatable term. + + @discussion The term may still contain mathematicall undefined expressions. + + This property should not be set manually. + */ @property (nonatomic, strong) MPTerm *term; + +/*! + @method evaluate: + @abstract Evaluates the receiver. + + @discussion This method is a convenience method for evaluating the receiver's + @link + //apple_ref/occ/intfp/MPParsedExpression/term@/link. + + @param error + If an error occured during evaluation it will be returned + indirectly through this parameter. If you are not interested in + errors pass NULL. + + @return A NSDecimalNumber containing the result of the + evaluation. Depending on the evaluated expression the result may + only be of double precision. + */ - (NSDecimalNumber *)evaluate:(NSError *__autoreleasing *)error; @end diff --git a/MathKit/MPPowerFunction.h b/MathKit/MPPowerFunction.h index 38c68fc..846269b 100644 --- a/MathKit/MPPowerFunction.h +++ b/MathKit/MPPowerFunction.h @@ -15,18 +15,18 @@ /*! @class MPPowerFunction - @brief This class represents a power. + @abstract This class represents a power. */ @interface MPPowerFunction : MPFunction /*! @property exponentExpression - @brief The receiver's exponent. + @abstract The receiver's exponent. @discussion The base of the power can only be set during evaluation because it is not actually part of the function element. The exponent must not define a variable. */ -@property (nonatomic, strong) MPExpression *exponentExpression; +@property (nonatomic, strong) MPExpression *exponentExpression; /* Index 0 */ @end diff --git a/MathKit/MPProductTerm.h b/MathKit/MPProductTerm.h index 6dbb2ba..4445a9a 100644 --- a/MathKit/MPProductTerm.h +++ b/MathKit/MPProductTerm.h @@ -13,10 +13,45 @@ @class MPProductTerm; +/*! + @class MPProductTerm + @abstract A product term consists of n terms that are multiplied together. + + @discussion Although they are mutliplied in order of occurrence the child + terms should be considered having equal priority. + */ @interface MPProductTerm : MPTerm + +/*! + @method initWithFactors: + @abstract Initializes a new product term with the specified + factors. + + @discussion There is very little checking performed during initialization. + All objects in the specified array must be valid instances of + subclasses of @link //apple_ref/occ/cl/MPTerm@/link. + The array must contain at least one object. + + @param factors + The factors the product term should be initialized with. The + array must not be nil and must contain at least one + object. The contents of the array are not copied, the array + itself however is. + + @return A new sum term. + */ - (instancetype)initWithFactors:(NSArray *)factors; /* designated initializer */ + +/*! + @property factors + @abstract The receiver's factors. + + @discussion This property is guaranteed to be non nil. The + contents of the array are specified during initialization of the + receiver. + */ @property (readonly, nonatomic, strong) NSArray *factors; @end diff --git a/MathKit/MPProductTerm.m b/MathKit/MPProductTerm.m index 3590fd9..c0002f7 100644 --- a/MathKit/MPProductTerm.m +++ b/MathKit/MPProductTerm.m @@ -28,7 +28,7 @@ if (self) { NSAssert(factors != nil, @"factors must not be nil."); NSAssert(factors.count > 0, @"factors must not be empty."); - _factors = factors; + _factors = factors.copy; } return self; } diff --git a/MathKit/MPRangePath.h b/MathKit/MPRangePath.h index 1ee1de6..3ceecde 100644 --- a/MathKit/MPRangePath.h +++ b/MathKit/MPRangePath.h @@ -9,8 +9,30 @@ #import "MPExpression.h" +/*! + @header + The MPRangePath combines an NSIndexPath with a + NSRange. A range path is used in a tree structure to identify a + number of subsequent nodes. This is achieved by combining a range path that + stores the location of the first node in the tree with an integer that stores + the number of nodes that should be included in the range path. + */ -/// Convenience Constructor Macro + +/*! + @define MPMakeRangePath + @abstract Creates a new NSRangePath instance with the given + location and length. + + @param loc + The location of the first included item. This must be an + NSIndexPath instance. + + @param len + The number of nodes to include in the range path. + + @return A new range path. + */ #define MPMakeRangePath(loc, len) [MPRangePath rangePathWithLocation:(loc) length:(len)] @@ -19,19 +41,13 @@ /*! @class MPRangePath - @brief @c MPRangePath is like @c NSRange but with an @c NSIndexPath as - location. + @abstract A MPRangePath instance identifies a range of + subsequent nodes in a tree structure. - @discussion Range paths are intended to address a range (as defined by @c - NSRange) that resides in a tree structure. Thus the @c location - property of a range path is a @c NSIndexPath. - - - @c MPRangePath instances are immutable. + @discussion MPRangePath instances are immutable. */ @interface MPRangePath : NSObject - #pragma mark Creation Methods /*! @methodgroup Creation Methods @@ -40,39 +56,40 @@ /*! @method init - @brief Initializes an empty range path. + @abstract Initializes an empty range path. - @discussion This method is a convenience initializer to create a range path with - an empty location and a length of @c 0. + @discussion This method is a convenience initializer to create a range path + with an empty location and a length of 0. - @return A @c MPRangePath instance. + @return A new MPRangePath instance. */ - (instancetype)init; /*! @method initWithRange: - @brief Initializes a newly created range path with the specified range. + @abstract Initializes a newly created range path with the specified range. - @discussion This method is a convenience initializer to convert from a @c - NSRange to a @c MPRangePath. The location of @c aRange is - translated into a location for the range path. + @discussion This method is a convenience initializer to convert from a + NSRange struct to a MPRangePath + instance. The location of the created range path is an index path + of length 1. @param aRange - The range to be converted into a @c MPRangePath. + The range to be converted into a MPRangePath. - @return A @c MPRangePath instance. + @return A MPRangePath instance. */ - (instancetype)initWithRange:(NSRange)aRange; /*! @method initWithLocation:lenght: - @brief Initializes a newly created range path with the specified location + @abstract Initializes a newly created range path with the specified location and length. - @discussion The last index in the @c location should address the first item - that is actually selected. + @discussion The last index in the location addresses the first + item that is actually selected. @param location The location of the first element that should be addressed by @@ -81,7 +98,7 @@ @param length The number of elements to be addressed by this range path. - @return A @c MPRangePath instance. + @return A MPRangePath instance. */ - (instancetype)initWithLocation:(NSIndexPath *)location length:(NSUInteger)length; /* designated initializer */ @@ -89,36 +106,37 @@ /*! @method rangePath - @brief Allocates and initializes an empty @c NSRangePath instance. + @abstract Allocates and initializes an empty NSRangePath + instance. - @discussion An empty range path's location has @c 0 indexes and a length of - @c 0. + @discussion An empty range path's location has 0 indexes and a + length of 0. - @return A newly created @c MPRangePath instance. + @return A newly created MPRangePath instance. */ + (instancetype)rangePath; /*! @method rangePathWithRange: - @brief Allocates a new @c MPRangePath instance and initializes it with - the specified location and length. + @abstract Allocates a new MPRangePath instance and initializes + it with the specified location and length. - @discussion The location of @c aRange is translated into an index path for - the range path. + @discussion The location of aRange is translated into an index + path for the range path. @param aRange The range to be converted into a range path. - @return A newly created @c MPRangePath instance. + @return A newly created MPRangePath instance. */ + (instancetype)rangePathWithRange:(NSRange)aRange; /*! @method rangePathWithLocation:length: - @brief Allocates a new @c MPRangePath instance and initializes it with - the specified location and length. + @abstract Allocates a new MPRangePath instance and initializes + it with the specified location and length. @param location The location of the first element that should be addressed by the @@ -128,7 +146,7 @@ The number of elements that should be addressed by the range path. - @return A newly created @c MPRangePath instance. + @return A newly created MPRangePath instance. */ + (instancetype)rangePathWithLocation:(NSIndexPath *)location length:(NSUInteger)length; @@ -142,35 +160,36 @@ /*! @property location - @brief The location of the first element addressed by the receiver. + @abstract The location of the first element addressed by the receiver. */ @property (readonly, nonatomic, strong) NSIndexPath *location; /*! @property length - @brief The number of elements addressed by the receiver. The element + @abstract The number of elements addressed by the receiver. The element addressed by the last index of the location property plus the - length of the receiver is NOT considered inside of the range - path. + length of the receiver is not considered inside of the + range path. */ @property (readonly, nonatomic) NSUInteger length; /*! @method maxRangePath - @brief Similar to the @c NSRange method @c NSMaxRange this method - returns the first index after the receiving @c NSRangePath. + @abstract Similar to the NSRange function + NSMaxRange this method returns the first index after + the receiving NSRangePath. - @return The first index after the receiving @c NSRangePath. + @return The first index after the receiving NSRangePath. */ - (NSIndexPath *)maxRangePath; /*! @method rangeAtLastIndex - @brief Returns a @c NSRange constructed from the last index of the - receiver's location and the receiver's length. + @abstract Returns a NSRange constructed from the last index of + the receiver's location and the receiver's length. @return The range identifying the elements at the last index in the receiver's index path. @@ -186,57 +205,60 @@ /*! @method containsLocation: - @brief Checks wether the range path addressed by the receiver includes - @c location. + @abstract Checks wether the range path addressed by the receiver includes + location. @discussion The index path is considered inside the receiver if the indexes - in the receiver's @c location property are equal to the - respective indexes index in @c location. For the last position of - the last index of the receiver's @c location it is also valid if - the respective index is inside the range at the last index. + in the receiver's location property are equal to the + respective indexes index in location. For the last + position of the last index of the receiver's + location it is also valid if the respective index is + inside the range at the last index. @param location The index path to check wether it is contained in the receiver. - @return @c YES if the range path addressed by the receiver also contains - @c location, @c NO otherwise. + @return YES if the range path addressed by the receiver also + contains location, NO otherwise. */ - (BOOL)containsLocation:(NSIndexPath *)location; /*! @method containsRangePath: - @brief Checks wether the receiver completely contains @c aRangePath. + @abstract Checks wether the receiver completely contains + aRangePath. @discussion A range path is contained by another range path if either the receiver's range at its last index contains the index at the - respective location of the location path of @c aRangePath or (if - the locations are of the same length) the receiver's range at its - last index contains the last index's range of @c aRangePath. + respective location of the location path of + aRangePath or (if the locations are of the same + length) the receiver's range at its last index contains the last + index's range of aRangePath. @param aRangePath The range path to check wether it is contained in the receiver. - @return @c YES if the range path addressed by the receiver also includes - @c aRangePath, @c NO otherwise. + @return YES if the range path addressed by the receiver also + includes aRangePath, NO otherwise. */ - (BOOL)containsRangePath:(MPRangePath *)aRangePath; /*! @method isEqualToRangePath: - @brief Checks wether the receiver and @c aRangePath are equal. + @abstract Checks wether the receiver and aRangePath are equal. @discussion If you know that you are comparing two range paths (that are not - @c nil) you should use this method over @c -isEqual: because it - is more performant. + nil) you should prefer this method over + isEqual: because it is more performant. @param aRangePath - The range path to check for equality. If this parameter is @c nil - this method may raise an exception. + The range path to check for equality. If this parameter is + nil this method may raise an exception. - @return @c YES if the receiver is equal to @c aRangePath, @c NO - otherwise. + @return YES if the receiver is equal to + aRangePath, NO otherwise. */ - (BOOL)isEqualToRangePath:(MPRangePath *)aRangePath; @@ -249,15 +271,15 @@ /*! @method subexpressionWithRangePath: - @brief Creates a new expression with the symbols in the specified range + @abstract Creates a new expression with the symbols in the specified range path. @discussion The elements in the newly created expression are copied to the new exoression. The range path is specified in the length reference frame. - If the specified range exceeds the receiver's bounds a @c - NSRangeException is raised. + If the specified range exceeds the receiver's bounds a + NSRangeException is raised. @param aRangePath The range path from which to create the new expression. @@ -270,23 +292,30 @@ /*! @method replaceItemsInRangePath:referenceFrame:withElements: - @brief Replaces the items in the specified range path with the contents - of @c elements. + @abstract Replaces the items in the specified range path with the contents + of elements. - @discussion All objects in the @c elements array must conform to the @c - MPExpressionElement protocol. If one or more objects do not - conform to the protocol a @c MPIllegalElementException will be + @discussion All objects in the elements array must conform to + the @link + //apple_ref/occ/intf/MPExpressionElement@/link protocol. + If one or more objects do not conform to the protocol a + @link + //apple_ref/c/data/MPIllegalElementException@/link is raised. @param rangePath - The range path to be replaced. The path of the range path is - expressed in the element reference frame. The range of the range - path is expressed in the specified @c referenceFrame. + The range path to be replaced. The location of the range path + (except for the last index) is expressed in the element reference + frame. The range of the range path is expressed in the specified + referenceFrame. @param referenceFrame The reference frame to use. This only applies to the range at the last index of the range path. The path of the range path is always expressed in the element reference frame. + + @param elements + The elements replacing the ones in the specified range path. */ - (void)replaceItemsInRangePath:(MPRangePath *)rangePath referenceFrame:(MPReferenceFrame)referenceFrame diff --git a/MathKit/MPSumFunction.h b/MathKit/MPSumFunction.h index 7f88369..ef0b7f0 100644 --- a/MathKit/MPSumFunction.h +++ b/MathKit/MPSumFunction.h @@ -6,13 +6,6 @@ // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // -/*! - @header - This is a description of the MPFunction class. - - It has multiple lines. - */ - #import "MPFunction.h" @@ -22,7 +15,7 @@ /*! @class MPSumFunction - @brief This class represents a sum function (generally noted using a + @abstract This class represents a sum function (generally noted using a capital sigma). @discussion A sum function has a start and a target expression indicating how @@ -30,28 +23,26 @@ the start expression and the target expressions are included in the iterations. - Each iteration the sum value is incremented by @c 1. If the start - and target expression evaluate to the same value the sum is - evaluated once. + Each iteration the sum value is incremented by 1. If + the start and target expression evaluate to the same value the + sum is evaluated once. */ @interface MPSumFunction : MPFunction - /*! @property startExpression - @brief The value of the first iteration. + @abstract The value of the first iteration. @discussion The start expression must define a variable that may be used in the sum expression. If the start expression does not define a variable the sum function will fail on validation. - @code Some samples */ @property (nonatomic, strong) MPExpression *startExpression; /* Index 0 */ /*! @property targetExpression - @brief The value if the last iteration. + @abstract The value if the last iteration. @discussion The target expression must not define a variable. */ @@ -60,7 +51,7 @@ /*! @property sumExpression - @brief The sum expression evaluated multiple times. + @abstract The sum expression evaluated multiple times. @discussion During evaluation of the sum expression the variable defined in the start expression is available. That variable always contains diff --git a/MathKit/MPSumTerm.h b/MathKit/MPSumTerm.h index e6b79ce..d99737e 100644 --- a/MathKit/MPSumTerm.h +++ b/MathKit/MPSumTerm.h @@ -13,11 +13,44 @@ @class MPSumTerm; +/*! + @class MPSumTerm + @abstract A sum term consists of n terms that are added together. + + @discussion Although they are added in order of occurrence the child terms + should be considered having equal priority. + */ @interface MPSumTerm : MPTerm +/*! + @method initWithSummands: + @abstract Initializes a new sum term with the specified summands. + + @discussion There is very little checking performed during initialization. + All objects in the specified array must be valid instances of + subclasses of @link //apple_ref/occ/cl/MPTerm@/link. + The array must contain at least one object. + + @param summands + The summands the sum term should be initialized with. The array + must not be nil and must contain at least one + object. The contents of the array are not copied, the array + itself however is. + + @return A new sum term. + */ - (instancetype)initWithSummands:(NSArray *)summands; /* designated initializer */ -@property (readonly, nonatomic, strong) NSArray *summands; + +/*! + @property summands + @abstract The receiver's summands. + + @discussion This property is guaranteed to be non nil. The + contents of the array are specified during initialization of the + receiver. + */ +@property (readonly, nonatomic, copy) NSArray *summands; @end diff --git a/MathKit/MPSumTerm.m b/MathKit/MPSumTerm.m index 5ba87e0..25e16b6 100644 --- a/MathKit/MPSumTerm.m +++ b/MathKit/MPSumTerm.m @@ -21,7 +21,7 @@ if (self) { NSAssert(summands != nil, @"summands must not be nil."); NSAssert(summands.count > 0, @"summands must not be empty."); - _summands = summands; + _summands = summands.copy; } return self; } diff --git a/MathKit/MPTerm.h b/MathKit/MPTerm.h index 3beadba..45accb8 100644 --- a/MathKit/MPTerm.h +++ b/MathKit/MPTerm.h @@ -6,23 +6,194 @@ // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // + +/*! + @header + The MPTerm class is used to evaluate a mathematical expression. A + term is a purely mathematical representation of a part of an expression. A term + can be defined with three rules: + + 1. A number is a term. + 2. A variable is a term. + 3. A connection of terms with zero or more symbols is also a term. + + Every mathematical operation (term) is defined in terms of a concrete subclass + of MPTerm and sub-terms (children). For example the expression + 2+3⋅4 would be a @link //apple_ref/occ/cl/MPSumTerm sum term@/link + with two children: A @link //apple_ref/occ/cl/MPNumber number@/link and a @link + //apple_ref/occ/cl/MPProductTerm product term@/link. The product term in turn + has two children which are both numbers. + + Subclasses should do the following: + 1. Subclasses must implement the @link doEvaluation:@/link method. + 2. Subclasses should be immutable and thus define readonly + accessors for any children as well as an init method that + supplies the necessary values. + + If a term has children that define variables to be used in one or more of the + other children MPTerm offers methods for defining, accessing and + undefining variable values. Because a term can not define variables that are + accessible in any of its sibling or parent terms all variables defined in a term + are automatically undefined when the term is finished evaluating. + */ + + +/*! + @define ReturnIfNil + @abstract This macro returns a value if a test + object is nil. + + @param test + The object to be tested. If this parameter is nil + the macro returns value. + + @param value + The value to be returned if test is + nil. + */ #define ReturnIfNil(test, value) if (test == nil) return value + + +/*! + @define ReturnNilIfNil + @abstract This macro returns nil if a test object + is nil. + + @param test + The object to be tested. If this parameter is nil + the macro returns nil. + */ #define ReturnNilIfNil(test) if (test == nil) return nil @class MPTerm; +/*! + @class MPTerm + @abstract MPTerm is a half abstract class that is the base + class for representing an evaluatable mathematical expression. + + @discussion MPTerm should not be instanciated directly. Instead + one of the concrete subclasses should be used. + */ @interface MPTerm : NSObject +/*! + @method evaluate: + @abstract Evaluates the receiver. + + @discussion The result of the evaluation is up to the concrete subclass of + MPTerm. Note however that subclasses should + not override this method. To implement the custom + evaluation behaviour implement the @link + doEvaluation:@/link method. To evaluate a term (including + children of terms) do use this method. + + @param error + If an error occurs during evaluation it is indirecly returned + through this parameter. If you are not interested in errors, pass + NULL. + + @return A NSDecimalNumber containing the result of the + evaluation. Depending on the term this should be double precision + or higher. + */ - (NSDecimalNumber *)evaluate:(NSError *__autoreleasing *)error; + + +/*! + @method doEvaluation: + @abstract Performs the actual evaluation of the receiver. + + @discussion This method must be implemented by subclasses but should never be + called directly. Call @link evaluate:@/link instead. + + @param error + If an error occurs during evaluation it is indirecly returned + through this parameter. If you are not interested in errors, pass + NULL. + + @return A NSDecimalNumber containing the result of the + evaluation. Depending on the term this should be double precision + or higher. + */ - (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error; + +/*! + @method defineVariable:value:error: + @abstract Defines a variable in the shared evaluation context. + + @discussion A defined variable is available until it is either undefined or + the end of the @link doEvaluation:@/link method is + reached at which point all variables defined in that method are + undefined automatically. If the variableName has + already been defined in the same method this method overwrites + the value for the variable. If it has been defined in the + evaluation method of a parent term this method fails and returns + NO. + + @param variableName + The variable to be defined. + + @param value + The value for the variable. + + @param error + If variableName has already been defined in a parent + term this parameter is set to an error object that informs the + user about a variable redefinition. If you are not interested in + errors, pass NULL. + + @return YES if the variable could be defined, + NO if it has previously been declared in a parent + term of the currently evaluated one. + */ - (BOOL)defineVariable:(NSString *)variableName value:(NSDecimalNumber *)value error:(NSError *__autoreleasing *)error; + + +/*! + @method valueForVariable: + @abstract Returns the value for a variable from the shared evaluation + context. + + @discussion If variableName is not defined this method returns + nil. Normally you do not need to call this method + yourself. + + @param variableName + The variable whose value is requested. + + @param error + If variableName is not defined this parameter is set + to an error object that informs the user about an undefined + variable. If you are not interested in errors, pass + NULL. + + @return The value associated with variableName or + nil if it is undefined. + */ - (NSDecimalNumber *)valueForVariable:(NSString *)variableName error:(NSError *__autoreleasing *)error; -- (void)undefineVariable:(NSString *)variableName; // Should rarely be needed, defined variables are automatically undefined at the end of evaluation. + + +/*! + @method undefineVariable: + @abstract Removes variableName from the shared evaluation + context. + + @discussion The variable is only removed if it exists and was defined in the + same evaluation method. Variables defined by parent terms can not + be undefined. Normally you do not need to call this method + yourself since all variables defined during the evaluation of a + term are automatically undefined afterwards. + + @param variableName + The name of the variable to be undefined. + */ +- (void)undefineVariable:(NSString *)variableName; @end \ No newline at end of file diff --git a/MathKit/MPTerm.m b/MathKit/MPTerm.m index 01ad332..af567fd 100644 --- a/MathKit/MPTerm.m +++ b/MathKit/MPTerm.m @@ -22,12 +22,6 @@ return result; } -- (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error -{ - NSLog(@"%@", self.class); - return nil; -} - - (BOOL)defineVariable:(NSString *)variableName value:(NSDecimalNumber *)value error:(NSError *__autoreleasing *)error diff --git a/MathKit/MPToken.h b/MathKit/MPToken.h index 952ae65..6a8365b 100644 --- a/MathKit/MPToken.h +++ b/MathKit/MPToken.h @@ -7,6 +7,28 @@ // +/*! + @header + One way to represent a mathematical expression using the @link + MPExpression@/link class is a sequence of tokens. A token is a logical + unit of input. The different types of units are identified by a @link + MPTokenType token type@/link. In the context of mathematical expressions this + can be for example numbers, variables or parenthesis. + + A special token type is the @link MPEOFToken@/link. This is not an + actual token that can be found in an expression. It is used to simplify working + with tokens. If a token is nil you can still query its @link + tokenType@/link and compare it against this special token type. For + example: +
+ @textblock
+while ((token = [self nextToken]).tokenType != MPEOFToken) {
+    // ...
+}
+ @/textblock
+ 
+ */ + @class MPToken; @protocol MPToken; @@ -14,15 +36,14 @@ /*! @typedef MPTokenType - @brief The type of a token identifies its behaviour in a mathematical + @abstract The type of a token identifies its behaviour in a mathematical context. @constant MPEOFToken A token that represents the end of the input. This token should - not be used to create a @c MPToken instance. It exists so that - you can safely send a @c tokenType message to @c nil without - getting confusing results. A token with this token type should be - interpreted as 'no token'. + not be used to create an instance of the @link + //apple_ref/occ/cl/MPToken@/link class. A token with this + token type should be interpreted as no token. @constant MPMultiplicationSymbolToken A multiplication symbol. @@ -31,35 +52,39 @@ A list of operators (+ and - symbols). The token may be longer than the number of operators if there are spaces between them. - @constant MPElementaryFunction - @em Most elementary functions are represented by this token type. - Elementary functions not categorized as such are those that can - not be represented as text (e.g. roots and powers). + @constant MPElementaryFunctionToken + Most elementary functions are represented by this token + type. Elementary functions not categorized as such are those that + can not be represented as text (e.g. roots and powers). @constant MPNumberToken A number. This may be an integer or a floating point number. - Floating point numbers contain a @c NSLocaleDecimalSeparator. + Floating point numbers contain a + NSLocaleDecimalSeparator. @constant MPVariableToken A variable. A variable is exactly one character long. @constant MPFactorialToken - The factorial symbol (!). + The factorial symbol (an exclamation mark). @constant MPEqualsToken The equals sign. @constant MPGenericFunctionToken - A function represented by the @c MPFunction class. A token with - this token type is guaranteed to be a @c MPFunction instance. + A function represented by the @link MPFunction@/link + class. A token with this token type is guaranteed to be an + instance of the @link MPFunction@/link class. @constant MPWhitespaceToken A whitespace. This token can typically be ignored. @constant MPUnidentifiedToken - Any symbol that does not match any other token. + Any symbol that does not match any other token. If this token is + found inside an expression the expression should be considered + invalid. */ -typedef NS_ENUM(NSUInteger, MPTokenType) { +typedef enum { MPEOFToken = 0, MPMultiplicationSymbolToken, MPOperatorListToken, @@ -74,24 +99,23 @@ typedef NS_ENUM(NSUInteger, MPTokenType) { MPWhitespaceToken, MPUnidentifiedToken, -}; +} MPTokenType; /*! @protocol MPToken - @brief Tokens represent logical units in an expresion. + @abstract Tokens represent logical units in an expresion. */ @protocol MPToken - /*! @method tokenType - @brief Returns the receiver's token type. + @abstract Returns the receiver's token type. - @discussion The token type identifies what kind of token the receiver is. For - more information see the documentation on the MPTokenType - enum. + @discussion The token type identifies what kind of token the receiver is. + Possible values are described in the @link + MPTokenType@/link enumeration. @return The receiver's token type. */ @@ -100,7 +124,7 @@ typedef NS_ENUM(NSUInteger, MPTokenType) { /*! @method range - @brief Returns the receiver's range. + @abstract Returns the receiver's range. @discussion The range identifies where the token is in the expression. It is specified in the symbol reference frame. @@ -113,12 +137,12 @@ typedef NS_ENUM(NSUInteger, MPTokenType) { /*! @method stringValue - @brief The string that caused the token to be parsed. + @abstract The string that caused the token to be parsed. @discussion Depending on the type of the token the string value can have a fixed or variable length. For example the equals token always has - a length of @c 1 whereas a number or whitespace token can be much - longer. + a length of 1 whereas a number or whitespace token + can be much longer. @return The receiver's string value. */ @@ -130,16 +154,16 @@ typedef NS_ENUM(NSUInteger, MPTokenType) { /*! @class MPToken - @brief The @c MPToken class implements the functionality of the @c - MPToken protocol. Most tokens are instances of the @c MPToken + @abstract The MPToken class implements the functionality of + the @link //apple_ref/occ/intf/MPToken@/link + protocol. Most tokens are instances of the MPToken class. */ @interface MPToken : NSObject - /*! @method initWithTokenType:range:stringValue: - @brief Creates a new @c MPToken instance. + @abstract Creates a new MPToken instance. @param tokenType The type of the token. diff --git a/MathKit/MathKit.h b/MathKit/MathKit.h index 8af35b7..b650f34 100644 --- a/MathKit/MathKit.h +++ b/MathKit/MathKit.h @@ -7,7 +7,7 @@ // #import "MPExpression.h" -#import "MPExpressionElement.h" +#import "MPExpression.h" #import "NSString+MPExpressionElement.h" #import "MPFunction.h" diff --git a/MathKit/NSIndexPath+MPAdditions.h b/MathKit/NSIndexPath+MPAdditions.h index 157c203..93b9000 100644 --- a/MathKit/NSIndexPath+MPAdditions.h +++ b/MathKit/NSIndexPath+MPAdditions.h @@ -8,48 +8,53 @@ +/*! + @category NSIndexPath (MPAdditions) + @abstract This category adds some methods for working with index paths to + the NSIndexPath class. + */ @interface NSIndexPath (MPAdditions) /*! @property firstIndex - @brief The first index from the index path. + @abstract The first index from the receiver. - @discussion If the index path is empty @c NSNotFound is returned. + @discussion If the receiver is empty NSNotFound is returned. */ @property (readonly, nonatomic) NSUInteger firstIndex; /*! @property lastIndex - @brief The last index from the index path. + @abstract The last index from the receiver. - @discussion If the index path is empty @c NSNotFound is returned. + @discussion If the receiver is empty NSNotFound is returned. */ @property (readonly, nonatomic) NSUInteger lastIndex; /*! @method indexPathByReplacingLastIndexWithIndex: - @brief Provides an index path with the index in the receiving index path - where the last one is replaced by @c index. + @abstract Provides an index path with the indexes of the receiver where the + last one is replaced by anIndex. - @discussion If the receiving index path is empty an index path of length @c 1 - is returned. The last index in the returned index path is @c - index. + @discussion If the receiver is empty an index path of length 1 + is returned. The last index in the returned index path is + anIndex. - @param index + @param anIndex The index with which to replace the last index in the receiving index path. - @return A new index path with @c index as its last index. + @return A new index path with anIndex as its last index. */ -- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)index; +- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)anIndex; /*! @method indexPathByRemovingFirstIndex - @brief Provides an index path with the indexes in the receiving index + @abstract Provides an index path with the indexes in the receiving index path, excluding the first one. @discussion Returns an empty NSIndexPath instance if the receiving index @@ -63,90 +68,90 @@ /*! @method indexPathByPreceedingIndex: - @brief Provides an index path with the specified index followed by the + @abstract Provides an index path with the specified index followed by the indexes of the receiver. @discussion If the receiver does not contain any indexes the specified index is the only index contained in the returned index path. - @param index + @param anIndex The index new index preceeding all others - @return A new index path with all the receiver's indexes preceeded by @c - index. + @return A new index path with all the receiver's indexes preceeded by + anIndex */ -- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)index; +- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)anIndex; /*! @method indexPathByIncrementingLastIndex - @brief Provides an index path with the indexes in the receiving index - path where the last one is incremented by @c 1. + @abstract Provides an index path with the indexes in the receiving index + path where the last one is incremented by 1. @discussion If the receiver does not contain any indexes an empty index path is returned. @return A new index path with all the receiver's indexes and the last one - incremented by @c 1. + incremented by 1. */ - (NSIndexPath *)indexPathByIncrementingLastIndex; /*! @method indexPathByDecrementingLastIndex - @brief Provides an index path with the indexes in the receiving index - path where the last one is decremented by @c 1. + @abstract Provides an index path with the indexes in the receiving index + path where the last one is decremented by 1. @discussion If the receiver does not contain any indexes an empty index path is returned. @return A new index path with all the receiver's indexes and the last one - decremented by @c 1. + decremented by 1. */ - (NSIndexPath *)indexPathByDecrementingLastIndex; /*! @method indexPathByRemovingIndexesFrom: - @brief Provides an index path with the indexes in the recieving index + @abstract Provides an index path with the indexes in the recieving index path up to the index at the specified position. - @discussion If @c from is greater or equal to the number of indexes in the - receiving index path only the indexes to the end of the receiver - are removed. + @discussion If from is greater or equal to the number of indexes + in the receiving index path only the indexes to the end of the + receiver are removed. @param from The position of the first index to be excluded in the returned index path. @return An index path with all indexes from the receiver up to position - @c from. + from. */ - (NSIndexPath *)indexPathByRemovingIndexesFrom:(NSUInteger)from; /*! @method indexPathByRemovingIndexesTo: - @brief Provides an index path with the indexes in the receiving index + @abstract Provides an index path with the indexes in the receiving index path where the first indexes are removed. - @discussion @c to specifies the number of indexes to be removed from the - front. Thus the index at position @c to will be included in the - returned index path. + @discussion to specifies the number of indexes to be removed + from the front. Thus the index at position to will + be included in the returned index path. @param to The number of indexes to remove from the front. @return A new index path with all the receiver's indexes exept the first - @c to ones. + to ones. */ - (NSIndexPath *)indexPathByRemovingIndexesTo:(NSUInteger)to; /*! @method commonIndexPathWith: - @brief Provides an index path that contains the first indexes of the + @abstract Provides an index path that contains the first indexes of the receiver that are equal to the specified index path. @discussion If one index path is completely included in the other a new index @@ -156,7 +161,7 @@ The index path to compare the receiver against. @return A new index path with the first indexes of the receiver that are - also present in @c indexPath. + also present in indexPath. */ - (NSIndexPath *)commonIndexPathWith:(NSIndexPath *)indexPath; diff --git a/MathKit/NSIndexPath+MPAdditions.m b/MathKit/NSIndexPath+MPAdditions.m index 56607a7..032f1ed 100644 --- a/MathKit/NSIndexPath+MPAdditions.m +++ b/MathKit/NSIndexPath+MPAdditions.m @@ -25,9 +25,9 @@ } -- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)index +- (NSIndexPath *)indexPathByReplacingLastIndexWithIndex:(NSUInteger)anIndex { - return [[self indexPathByRemovingLastIndex] indexPathByAddingIndex:index]; + return [[self indexPathByRemovingLastIndex] indexPathByAddingIndex:anIndex]; } @@ -46,10 +46,10 @@ } -- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)index +- (NSIndexPath *)indexPathByPreceedingIndex:(NSUInteger)anIndex { NSUInteger newIndexes[self.length+1]; - newIndexes[0] = index; + newIndexes[0] = anIndex; for (NSUInteger i = 0; i < self.length; i++) { newIndexes[i+1] = [self indexAtPosition:i]; } diff --git a/MathKit/NSRegularExpression+MPParsingAdditions.h b/MathKit/NSRegularExpression+MPParsingAdditions.h index c6ad829..351a127 100644 --- a/MathKit/NSRegularExpression+MPParsingAdditions.h +++ b/MathKit/NSRegularExpression+MPParsingAdditions.h @@ -8,16 +8,21 @@ +/*! + @category NSRegularExpression (MPParsingAdditions) + @abstract This category adds convenience methods for typical calls to + firstMatchInString:options:range:. + */ @interface NSRegularExpression (MPParsingAdditions) /*! @method firstMathInString: - @brief Returns the first match of the regular expression within the + @abstract Returns the first match of the regular expression within the specified string. - @discussion This is a convenience method that calls @c - -firstMatchInString:options:range: + @discussion This is a convenience method that calls + firstMatchInString:options:range:. @param string The string to search. @@ -25,19 +30,19 @@ @return An NSTextCheckingResult object. This result gives the overall matched range via its range property, and the range of each individual capture group via its rangeAtIndex: method. The range - @c {NSNotFound, 0} is returned if one of the capture groups did - not participate in this particular match. + {NSNotFound, 0} is returned if one of the capture + groups did not participate in this particular match. */ - (NSTextCheckingResult *)firstMatchInString:(NSString *)string; /*! @method firstMathInString:fromIndex - @brief Returns the first match of the regular expression from the + @abstract Returns the first match of the regular expression from the specified index in the string. - @discussion This is a convenience method that calls @c - -firstMatchInString:options:range: + @discussion This is a convenience method that calls + firstMatchInString:options:range:. @param string The string to search. @@ -48,50 +53,50 @@ @return An NSTextCheckingResult object. This result gives the overall matched range via its range property, and the range of each individual capture group via its rangeAtIndex: method. The range - @c {NSNotFound, 0} is returned if one of the capture groups did - not participate in this particular match. + {NSNotFound, 0} is returned if one of the capture + groups did not participate in this particular match. */ - (NSTextCheckingResult *)firstMatchInString:(NSString *)string fromIndex:(NSUInteger)start; /*! @method firstMathInString:options: - @brief Returns the first match of the regular expression within the + @abstract Returns the first match of the regular expression within the specified string. - @discussion This is a convenience method that calls @c - -firstMatchInString:options:range: + @discussion This is a convenience method that calls + firstMatchInString:options:range:. @param string The string to search. @param options - The matching options to use. See @c NSMatchingOptions for - possible values. + The matching options to use. See NSMatchingOptions + for possible values. @return An NSTextCheckingResult object. This result gives the overall matched range via its range property, and the range of each individual capture group via its rangeAtIndex: method. The range - @c {NSNotFound, 0} is returned if one of the capture groups did - not participate in this particular match. + {NSNotFound, 0} is returned if one of the capture + groups did not participate in this particular match. */ - (NSTextCheckingResult *)firstMatchInString:(NSString *)string options:(NSMatchingOptions)options; /*! - @method firstMathInString:fromIndex - @brief Returns the first match of the regular expression from the + @method firstMathInString:options:fromIndex + @abstract Returns the first match of the regular expression from the specified index in the string. - @discussion This is a convenience method that calls @c - -firstMatchInString:options:range: + @discussion This is a convenience method that calls + firstMatchInString:options:range:. @param string The string to search. @param options - The matching options to use. See @c NSMatchingOptions for - possible values. + The matching options to use. See NSMatchingOptions + for possible values. @param start The index from which to start searching. @@ -99,8 +104,8 @@ @return An NSTextCheckingResult object. This result gives the overall matched range via its range property, and the range of each individual capture group via its rangeAtIndex: method. The range - @c {NSNotFound, 0} is returned if one of the capture groups did - not participate in this particular match. + {NSNotFound, 0} is returned if one of the capture + groups did not participate in this particular match. */ - (NSTextCheckingResult *)firstMatchInString:(NSString *)string options:(NSMatchingOptions)options fromIndex:(NSUInteger)start; diff --git a/MathKit/NSString+MPExpressionElement.h b/MathKit/NSString+MPExpressionElement.h index a19f440..be63994 100644 --- a/MathKit/NSString+MPExpressionElement.h +++ b/MathKit/NSString+MPExpressionElement.h @@ -6,14 +6,14 @@ // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // -#import "MPExpressionElement.h" +#import "MPExpression.h" /*! @category NSString (MPExpressionElement) - @brief This category adds @c MPExpressionElement protocol conformance to - the @c NSString class. + @abstract This category adds @link MPExpressionElement@/link + protocol conformance to the NSString class. */ @interface NSString (MPExpressionElement) diff --git a/MathPad.xcodeproj/project.pbxproj b/MathPad.xcodeproj/project.pbxproj index d544b93..f6f3823 100644 --- a/MathPad.xcodeproj/project.pbxproj +++ b/MathPad.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 3B52CEC119BB9FA900CEDCFC /* MathKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B85830D19BB5E5500D76A8D /* MathKit.framework */; }; 3B6338351A3A4B5800698BFB /* MPExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6338321A3A4B5800698BFB /* MPExpression.h */; }; 3B6338361A3A4B5800698BFB /* MPExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B6338331A3A4B5800698BFB /* MPExpression.m */; }; - 3B6338371A3A4B5800698BFB /* MPExpressionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6338341A3A4B5800698BFB /* MPExpressionElement.h */; }; 3B63383A1A3A4B7600698BFB /* NSString+MPExpressionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6338381A3A4B7600698BFB /* NSString+MPExpressionElement.h */; }; 3B63383B1A3A4B7600698BFB /* NSString+MPExpressionElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B6338391A3A4B7600698BFB /* NSString+MPExpressionElement.m */; }; 3B63383E1A3A4B8500698BFB /* MPToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B63383C1A3A4B8500698BFB /* MPToken.h */; }; @@ -159,25 +158,24 @@ /* Begin PBXFileReference section */ 3B0F69AB1902A82C00817707 /* MPExpressionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPExpressionTests.m; path = ../MathPadTests/MPExpressionTests.m; sourceTree = ""; }; 3B6338321A3A4B5800698BFB /* MPExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPExpression.h; path = MathKit/MPExpression.h; sourceTree = SOURCE_ROOT; }; - 3B6338331A3A4B5800698BFB /* MPExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPExpression.m; path = MathKit/MPExpression.m; sourceTree = SOURCE_ROOT; }; - 3B6338341A3A4B5800698BFB /* MPExpressionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPExpressionElement.h; path = MathKit/MPExpressionElement.h; sourceTree = SOURCE_ROOT; }; + 3B6338331A3A4B5800698BFB /* MPExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = MPExpression.m; path = MathKit/MPExpression.m; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 3B6338381A3A4B7600698BFB /* NSString+MPExpressionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+MPExpressionElement.h"; path = "MathKit/NSString+MPExpressionElement.h"; sourceTree = SOURCE_ROOT; }; 3B6338391A3A4B7600698BFB /* NSString+MPExpressionElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+MPExpressionElement.m"; path = "MathKit/NSString+MPExpressionElement.m"; sourceTree = SOURCE_ROOT; }; 3B63383C1A3A4B8500698BFB /* MPToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPToken.h; path = MathKit/MPToken.h; sourceTree = SOURCE_ROOT; }; 3B63383D1A3A4B8500698BFB /* MPToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPToken.m; path = MathKit/MPToken.m; sourceTree = SOURCE_ROOT; }; - 3B6338401A3A4B9500698BFB /* MPFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPFunction.h; path = MathKit/MPFunction.h; sourceTree = SOURCE_ROOT; }; + 3B6338401A3A4B9500698BFB /* MPFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPFunction.h; path = MathKit/MPFunction.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338411A3A4B9500698BFB /* MPFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPFunction.m; path = MathKit/MPFunction.m; sourceTree = SOURCE_ROOT; }; - 3B6338441A3A4BA500698BFB /* MPExpressionTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPExpressionTokenizer.h; path = MathKit/MPExpressionTokenizer.h; sourceTree = SOURCE_ROOT; }; + 3B6338441A3A4BA500698BFB /* MPExpressionTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPExpressionTokenizer.h; path = MathKit/MPExpressionTokenizer.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338451A3A4BA500698BFB /* MPExpressionTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPExpressionTokenizer.m; path = MathKit/MPExpressionTokenizer.m; sourceTree = SOURCE_ROOT; }; - 3B6338481A3A4BB300698BFB /* MPFunction+MPToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "MPFunction+MPToken.h"; path = "MathKit/MPFunction+MPToken.h"; sourceTree = SOURCE_ROOT; }; + 3B6338481A3A4BB300698BFB /* MPFunction+MPToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = "MPFunction+MPToken.h"; path = "MathKit/MPFunction+MPToken.h"; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338491A3A4BB300698BFB /* MPFunction+MPToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "MPFunction+MPToken.m"; path = "MathKit/MPFunction+MPToken.m"; sourceTree = SOURCE_ROOT; }; - 3B63384C1A3A4BD100698BFB /* MPParenthesisFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPParenthesisFunction.h; path = MathKit/MPParenthesisFunction.h; sourceTree = SOURCE_ROOT; }; + 3B63384C1A3A4BD100698BFB /* MPParenthesisFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPParenthesisFunction.h; path = MathKit/MPParenthesisFunction.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B63384D1A3A4BD100698BFB /* MPParenthesisFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPParenthesisFunction.m; path = MathKit/MPParenthesisFunction.m; sourceTree = SOURCE_ROOT; }; 3B63384E1A3A4BD100698BFB /* MPSumFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPSumFunction.h; path = MathKit/MPSumFunction.h; sourceTree = SOURCE_ROOT; }; 3B63384F1A3A4BD100698BFB /* MPSumFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPSumFunction.m; path = MathKit/MPSumFunction.m; sourceTree = SOURCE_ROOT; }; - 3B6338541A3A4BE800698BFB /* MPFractionFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPFractionFunction.h; path = MathKit/MPFractionFunction.h; sourceTree = SOURCE_ROOT; }; + 3B6338541A3A4BE800698BFB /* MPFractionFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPFractionFunction.h; path = MathKit/MPFractionFunction.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338551A3A4BE800698BFB /* MPFractionFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPFractionFunction.m; path = MathKit/MPFractionFunction.m; sourceTree = SOURCE_ROOT; }; - 3B6338561A3A4BE800698BFB /* MPPowerFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPPowerFunction.h; path = MathKit/MPPowerFunction.h; sourceTree = SOURCE_ROOT; }; + 3B6338561A3A4BE800698BFB /* MPPowerFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPPowerFunction.h; path = MathKit/MPPowerFunction.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338571A3A4BE800698BFB /* MPPowerFunction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPowerFunction.m; path = MathKit/MPPowerFunction.m; sourceTree = SOURCE_ROOT; }; 3B63385C1A3A4C0700698BFB /* MPExpressionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPExpressionParser.h; path = MathKit/MPExpressionParser.h; sourceTree = SOURCE_ROOT; }; 3B63385D1A3A4C0700698BFB /* MPExpressionParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPExpressionParser.m; path = MathKit/MPExpressionParser.m; sourceTree = SOURCE_ROOT; }; @@ -187,7 +185,7 @@ 3B6338631A3A4C2B00698BFB /* MPNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPNumber.m; path = MathKit/MPNumber.m; sourceTree = SOURCE_ROOT; }; 3B6338641A3A4C2B00698BFB /* MPParenthesisTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPParenthesisTerm.h; path = MathKit/MPParenthesisTerm.h; sourceTree = SOURCE_ROOT; }; 3B6338651A3A4C2B00698BFB /* MPParenthesisTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPParenthesisTerm.m; path = MathKit/MPParenthesisTerm.m; sourceTree = SOURCE_ROOT; }; - 3B6338661A3A4C2B00698BFB /* MPParsedExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPParsedExpression.h; path = MathKit/MPParsedExpression.h; sourceTree = SOURCE_ROOT; }; + 3B6338661A3A4C2B00698BFB /* MPParsedExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPParsedExpression.h; path = MathKit/MPParsedExpression.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338671A3A4C2B00698BFB /* MPParsedExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPParsedExpression.m; path = MathKit/MPParsedExpression.m; sourceTree = SOURCE_ROOT; }; 3B6338681A3A4C2B00698BFB /* MPPowerTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPPowerTerm.h; path = MathKit/MPPowerTerm.h; sourceTree = SOURCE_ROOT; }; 3B6338691A3A4C2B00698BFB /* MPPowerTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPowerTerm.m; path = MathKit/MPPowerTerm.m; sourceTree = SOURCE_ROOT; }; @@ -213,7 +211,7 @@ 3B6338991A3A4CE100698BFB /* MPSumFunctionTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPSumFunctionTerm.m; path = MathKit/MPSumFunctionTerm.m; sourceTree = SOURCE_ROOT; }; 3B63389C1A3A4CEF00698BFB /* MPFractionTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPFractionTerm.h; path = MathKit/MPFractionTerm.h; sourceTree = SOURCE_ROOT; }; 3B63389D1A3A4CEF00698BFB /* MPFractionTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPFractionTerm.m; path = MathKit/MPFractionTerm.m; sourceTree = SOURCE_ROOT; }; - 3B6338A01A3A4CFC00698BFB /* MPRangePath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPRangePath.h; path = MathKit/MPRangePath.h; sourceTree = SOURCE_ROOT; }; + 3B6338A01A3A4CFC00698BFB /* MPRangePath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = MPRangePath.h; path = MathKit/MPRangePath.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3B6338A11A3A4CFC00698BFB /* MPRangePath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPRangePath.m; path = MathKit/MPRangePath.m; sourceTree = SOURCE_ROOT; }; 3B6338A41A3A4D1200698BFB /* Fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fonts; sourceTree = ""; }; 3B6338A61A3A4D2600698BFB /* NSIndexPath+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSIndexPath+MPAdditions.h"; path = "MathKit/NSIndexPath+MPAdditions.h"; sourceTree = SOURCE_ROOT; }; @@ -319,6 +317,18 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3B4EC2AC1A3F1400009ADA5E /* MPExpressionView Internal */ = { + isa = PBXGroup; + children = ( + 3B6338B61A3A4D9400698BFB /* MPFunctionsViewController.h */, + 3B6338B71A3A4D9400698BFB /* MPFunctionsViewController.m */, + 3B6338B81A3A4D9400698BFB /* MPFunctionsViewController.xib */, + 3B6338B91A3A4D9400698BFB /* MPWhiteView.h */, + 3B6338BA1A3A4D9400698BFB /* MPWhiteView.m */, + ); + name = "MPExpressionView Internal"; + sourceTree = ""; + }; 3B7172E519C7112C00FEAA5B /* Resources */ = { isa = PBXGroup; children = ( @@ -373,11 +383,12 @@ 3B85833119BB5EC800D76A8D /* View */ = { isa = PBXGroup; children = ( - 3B6338AE1A3A4D6A00698BFB /* MPExpressionView.h */, - 3B6338AF1A3A4D6A00698BFB /* MPExpressionView.m */, 3B6338B21A3A4D7900698BFB /* MPExpressionStorage.h */, 3B6338B31A3A4D7900698BFB /* MPExpressionStorage.m */, - 3BB09ED819071C270080A5ED /* Private */, + 3B6338AE1A3A4D6A00698BFB /* MPExpressionView.h */, + 3B6338AF1A3A4D6A00698BFB /* MPExpressionView.m */, + 3B4EC2AC1A3F1400009ADA5E /* MPExpressionView Internal */, + 3BB09ED819071C270080A5ED /* Layout System */, ); name = View; sourceTree = ""; @@ -419,14 +430,9 @@ name = Functions; sourceTree = ""; }; - 3BB09ED819071C270080A5ED /* Private */ = { + 3BB09ED819071C270080A5ED /* Layout System */ = { isa = PBXGroup; children = ( - 3B6338B61A3A4D9400698BFB /* MPFunctionsViewController.h */, - 3B6338B71A3A4D9400698BFB /* MPFunctionsViewController.m */, - 3B6338B81A3A4D9400698BFB /* MPFunctionsViewController.xib */, - 3B6338B91A3A4D9400698BFB /* MPWhiteView.h */, - 3B6338BA1A3A4D9400698BFB /* MPWhiteView.m */, 3B6338C01A3A4DA500698BFB /* MPLayout.h */, 3B6338C11A3A4DA500698BFB /* MPLayout.m */, 3B6338C41A3A4DB600698BFB /* MPExpressionLayout.h */, @@ -435,7 +441,7 @@ 3B6338C91A3A4DC400698BFB /* MPFunctionLayout.m */, 3BB09EE21907361C0080A5ED /* Function Layouts */, ); - name = Private; + name = "Layout System"; path = ../MathPad; sourceTree = ""; }; @@ -468,7 +474,6 @@ children = ( 3B6338321A3A4B5800698BFB /* MPExpression.h */, 3B6338331A3A4B5800698BFB /* MPExpression.m */, - 3B6338341A3A4B5800698BFB /* MPExpressionElement.h */, 3B6338381A3A4B7600698BFB /* NSString+MPExpressionElement.h */, 3B6338391A3A4B7600698BFB /* NSString+MPExpressionElement.m */, 3B6338401A3A4B9500698BFB /* MPFunction.h */, @@ -659,7 +664,6 @@ 3B63388E1A3A4CBE00698BFB /* MPFunctionTerm.h in Headers */, 3B6338D41A3A4DE100698BFB /* MPFractionFunctionLayout.h in Headers */, 3B6338741A3A4C2B00698BFB /* MPPowerTerm.h in Headers */, - 3B6338371A3A4B5800698BFB /* MPExpressionElement.h in Headers */, 3B6338BE1A3A4D9400698BFB /* MPWhiteView.h in Headers */, 3B6338A21A3A4CFC00698BFB /* MPRangePath.h in Headers */, 3B63386E1A3A4C2B00698BFB /* MPNumber.h in Headers */, diff --git a/MathPad/Base.lproj/MainMenu.xib b/MathPad/Base.lproj/MainMenu.xib index dabd55e..e539853 100644 --- a/MathPad/Base.lproj/MainMenu.xib +++ b/MathPad/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -338,6 +338,25 @@ + + + + + + + + + + + + + + + + + + +