Latest 1.5
Homepage https://github.com/jrosen081/MathParser
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

What it is:

MathParser is a library written in swift that will allow a user to parse a String.

What you can do with it:

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Exponents
  • Overload the operators.

How to use:

Here is an example of how to use the library.

let expr = Parser.parse(string: "1 + 2") // Will return an expression that can be evaluated.
let exprValue = expr?.evaluate() // Evaluates the expression (will be 3 in this example)

To overload operators (this can be done if wanted):

Operators.addOp = ">"
let ans = Parser.parse(string: "1 > 2")?.evaluate() // This will evaluate to 3 with the new operator

Public methods:

  • Parser.parse
    • This returns an Optional Expression. This will return nil if the String is unparseable.
  • Expression.evaluate
    • This returns an Optional Decimal. This will only return nil if there is a division by 0.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

MathParser is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'MathParser'

Author

jrosen081, [email protected]

License

MathParser is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MathParser",
    "version": "1.5",
    "summary": "A simple parser for Mathematical Expressions.",
    "description": "MathParser is a pod that parses strings to decimal values. It allows addition, subtraction, multiplication, division, and exponent algebra.",
    "homepage": "https://github.com/jrosen081/MathParser",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "jrosen081": "[email protected]"
    },
    "source": {
        "git": "https://github.com/jrosen081/MathParser.git",
        "tag": "1.5"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MathParser/Classes/**/*",
    "swift_version": "5"
}

Pin It on Pinterest

Share This