Algebra - Advanced
-
The
Parser
converts a mathematical expression to a tree.As humans, we read and write math as a line of text. If you were to type a math expression, it would probably look something like this:
(1+2)-\left|-3\right|\times x^2You could also just look at that math expression and use your intuition to prioritize where to start simplifying. But a computer will understand the expression best when it’s stored in a tree. These trees can be surprisingly complicated — even a short expression like (1+2)-\left|-3\right|\times x^2 becomes this tree:
See more(-) / \ ( ) (*) / / \ (+) abs (^) / \ | / \ 1 2 -3 x 2
Declaration
Swift
public class Parser
-
The
See moreLexer
is converting a sequence of characters (mathematical expression) into a sequence ofToken
Declaration
Swift
public class Lexer
-
A
See moreGroup
is a intermediate representation object for representing a mathematical expression. This is the object that allows the tokens to be grouped together to convert them into nodes. In particular, it is in charge of recognizing parentheses and preanalysing them before passing the expression toParser
.Declaration
Swift
public class Group : NSObject
-
An entity that helps build a tree when parsing math expressions
See moreDeclaration
Swift
public protocol Node : NSObject
-
Declaration
Swift
public class CellAddressNode : NSObject, Node
-
A ParenthesisNode is an ExpressionNode used to treat parenthesis
See moreDeclaration
Swift
public class ParenthesisNode : ExpressionNode
-
Declaration
Swift
public class SymbolNode : NSObject, Node
-
Declaration
Swift
public class StringNode : NSObject, Node
-
Declaration
Swift
public class OperatorNode : NSObject, Node