Skip to content

Commit

Permalink
Updated for 0.8.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Aug 23, 2017
1 parent 73e5340 commit 1e2aac1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [0.8.4](/~https://github.com/nicklockwood/Expression/releases/tag/0.8.4) (2017-08-22)

- Fixed spurious parsing errors when expressions have leading whitespace
- The `parse(_: String.UnicodeScalarView)` method now accepts an optional list of terminating delimiters

## [0.8.3](/~https://github.com/nicklockwood/Expression/releases/tag/0.8.3) (2017-08-16)

- Fixed crash when parsing a malformed expression that contains just a single operator
Expand Down
4 changes: 2 additions & 2 deletions Expression.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Expression",
"version": "0.8.3",
"version": "0.8.4",
"license": {
"type": "zlib",
"file": "LICENCE.md"
Expand All @@ -10,7 +10,7 @@
"authors": "Nick Lockwood",
"source": {
"git": "/~https://github.com/nicklockwood/Expression.git",
"tag": "0.8.3"
"tag": "0.8.4"
},
"source_files": "Sources",
"requires_arc": true,
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ let expression = Expression(parsedExpression, constants: ["foo": 4, "bar": 5])

By setting the `usingCache` argument to `false` in the code above, we avoid adding the expression to the global cache. You are also free to implement your own caching by storing the parsed expression and re-using it, which may be more efficient than the built-in cache in some cases (e.g. by avoiding thread management if your code is single-threaded).

A second variant of the `Expression.parse()` method accepts a `String.UnicodeScalarView.SubSequence` and optional list of terminating delimiter strings. This can be used to match an expression embedded inside a longer string, and leaves the `startIndex` of the character sequence in the right place to continue parsing once the delimiter is reached:

```swift
let expressionString = "lorem ipsum {foo + bar} dolor sit"
var characters = String.UnicodeScalarView.SubSequence(expression.unicodeScalars)
while characters.popFirst() != "{" {} // Read up to start of expression
let parsedExpression = Expression.parse(&characters, upTo: "}")
let expression = Expression(parsedExpression, constants: ["foo": 4, "bar": 5])
```
## Optimization
By default, expressions are optimized where possible to make evaluation more efficient. Common optimizations include replacing constants with their literal values, and replacing pure functions or operators with their result when all arguments are constant.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Expression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Expression.swift
// Expression
//
// Version 0.8.3
// Version 0.8.4
//
// Created by Nick Lockwood on 15/09/2016.
// Copyright © 2016 Nick Lockwood. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.3</string>
<string>0.8.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand Down

0 comments on commit 1e2aac1

Please sign in to comment.