Archived
1

Added Documentation

This commit is contained in:
Kim Wittenburg
2014-12-17 22:04:49 +01:00
parent 8f1f730358
commit 7f6ee6e118
31 changed files with 1141 additions and 533 deletions

View File

@@ -7,6 +7,28 @@
//
/*!
@header
One way to represent a mathematical expression using the <code>@link
MPExpression@/link</code> 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 <code>@link MPEOFToken@/link</code>. 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 <code>nil</code> you can still query its <code>@link
tokenType@/link</code> and compare it against this special token type. For
example:
<pre>
@textblock
while ((token = [self nextToken]).tokenType != MPEOFToken) {
// ...
}
@/textblock
</pre>
*/
@class MPToken;
@protocol MPToken;
@@ -14,15 +36,14 @@
/*!
@typedef MPTokenType
@brief The type of a <code>token</code> 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 <code>@link
//apple_ref/occ/cl/MPToken@/link</code> class. A token with this
token type should be interpreted as <i>no token</i>.
@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
<i>Most</i> 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
<code>NSLocaleDecimalSeparator</code>.
@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 <code>@link MPFunction@/link</code>
class. A token with this token type is guaranteed to be an
instance of the <code>@link MPFunction@/link</code> 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 <NSObject>
/*!
@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 <code>MPTokenType
</code> enum.
@discussion The token type identifies what kind of token the receiver is.
Possible values are described in the <code>@link
MPTokenType@/link</code> 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 <code>1</code> 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 <code>MPToken</code> class implements the functionality of
the <code>@link //apple_ref/occ/intf/MPToken@/link</code>
protocol. Most tokens are instances of the <code>MPToken</code>
class.
*/
@interface MPToken : NSObject <MPToken>
/*!
@method initWithTokenType:range:stringValue:
@brief Creates a new @c MPToken instance.
@abstract Creates a new <code>MPToken</code> instance.
@param tokenType
The type of the token.