Skip to content

Commit

Permalink
Merge pull request #258 from jneen/DELETE_ME
Browse files Browse the repository at this point in the history
quick updates waiting for travis
  • Loading branch information
Brian Mock committed Jun 16, 2018
2 parents 11fb182 + 6de0949 commit 0d34bd7
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 107 deletions.
183 changes: 102 additions & 81 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,189 +1,210 @@
## version 1.9.0 (2018-06-15)

- Adds `parser.desc(array)` signature and `Parsimmon.makeFailure(index, array)`
signature to support starting with an array of expectations

## version 1.8.0 (2018-06-04)

* Adds `parser.tieWith(separator)`, a generalized version of `parser.tie()`
- Adds `parser.tieWith(separator)`, a generalized version of `parser.tie()`

## version 1.7.3 (2018-04-22)

* Shrinks UMD build from ~33 kb to ~11 kb
- Shrinks UMD build from ~33 kb to ~11 kb

## version 1.7.2 (2018-04-05)

* Fixes a bug where `seqObj` and `bitSeqObj` wouldn't work with keys that were already part of `Object.prototype`
- Fixes a bug where `seqObj` and `bitSeqObj` wouldn't work with keys that were
already part of `Object.prototype`

## version 1.7.1 (2018-03-22)

* Fixes a bug where `bitSeq` consumed the wrong input
- Fixes a bug where `bitSeq` consumed the wrong input

## version 1.7.0 (2018-03-10)

* Adds support for binary parsing using Node.js Buffers
* Adds `Parsimmon.Binary.bitSeq`
* Adds `Parsimmon.Binary.bitSeqObj`
* Adds `Parsimmon.Binary.byte`
- Adds support for binary parsing using Node.js Buffers
- Adds `Parsimmon.Binary.bitSeq`
- Adds `Parsimmon.Binary.bitSeqObj`
- Adds `Parsimmon.Binary.byte`

## version 1.6.4 (2018-01-01)

* Fixes `parser.many()` to throw an error if it detects an infinite parse loop.
- Fixes `parser.many()` to throw an error if it detects an infinite parse loop.

## version 1.6.3 (2018-01-01)

* Unpublished due to a Travis CI build issues.
- Unpublished due to a Travis CI build issues.

## version 1.6.2 (2017-07-08)

* Fixes another bug with match groups outside the correct range in `Parsimmon.regexp(regexp, group)`.
- Fixes another bug with match groups outside the correct range in
`Parsimmon.regexp(regexp, group)`.

## version 1.6.1 (2017-07-01)

* **100% unit test coverage!** This does not mean bugs won't exist, but it keeps us much safer against regressions in the future.
* **BUGFIX:** `Parsimmon.regexp(regexp, group)` will now correctly fail to parse if the `group` number is out of range for the `regexp` number of groups. This worked correctly in the past, but was broken during a minor code clean up due to missing tests.
- **100% unit test coverage!** This does not mean bugs won't exist, but it keeps
us much safer against regressions in the future.
- **BUGFIX:** `Parsimmon.regexp(regexp, group)` will now correctly fail to parse
if the `group` number is out of range for the `regexp` number of groups. This
worked correctly in the past, but was broken during a minor code clean up due
to missing tests.

## version 1.6.0 (2017-06-26)

* Adds `Parsimmon.seqObj(...args)`
- Adds `Parsimmon.seqObj(...args)`

## version 1.5.0 (2017-06-17)

NOTE: Code was completed on 2017-06-17, but due to human error, was not published on npm until 2017-06-26.
NOTE: Code was completed on 2017-06-17, but due to human error, was not
published on npm until 2017-06-26.

* Adds `parser.sepBy(separator)` alias for `Parsimmon.sepBy(parser, separator)`
* Adds `parser.sepBy1(separator)` alias for `Parsimmon.sepBy1(parser, separator)`
* Adds `Parsimmon.range(begin, end)`
* Adds `parser.wrap(before, after)`
* Adds `parser.trim(anotherParser)`
* Adds `parser.tie()`
- Adds `parser.sepBy(separator)` alias for `Parsimmon.sepBy(parser, separator)`
- Adds `parser.sepBy1(separator)` alias for `Parsimmon.sepBy1(parser, separator)`
- Adds `Parsimmon.range(begin, end)`
- Adds `parser.wrap(before, after)`
- Adds `parser.trim(anotherParser)`
- Adds `parser.tie()`

## version 1.4.0 (2017-06-05)

* Adds `Parsimmon.createLanguage(parsers)`
* Adds `parser.thru(wrapper)`
* Adds `parser.node(name)`
- Adds `Parsimmon.createLanguage(parsers)`
- Adds `parser.thru(wrapper)`
- Adds `parser.node(name)`

## version 1.3.0 (2017-05-28)

* Adds `Parsimmon.notFollowedBy(parser)`
* Adds `parser.notFollowedBy(anotherParser)`
- Adds `Parsimmon.notFollowedBy(parser)`
- Adds `parser.notFollowedBy(anotherParser)`

## version 1.2.0 (2016-12-22)

* Adds `Parsimmon.lookahead(parser)`
* Adds `parser.lookahead(anotherParser)`
- Adds `Parsimmon.lookahead(parser)`
- Adds `parser.lookahead(anotherParser)`

## version 1.1.0 (2016-12-21)

* Adds `Parsimmon.lookahead(string)`
* Adds `Parsimmon.lookahead(regexp)`
* Adds `parser.lookahead(string)`
* Adds `parser.lookahead(regexp)`
- Adds `Parsimmon.lookahead(string)`
- Adds `Parsimmon.lookahead(regexp)`
- Adds `parser.lookahead(string)`
- Adds `parser.lookahead(regexp)`

## version 1.0.0 (2016-11-02)

* **BREAKING:** `parser.empty` is now a function (`parser.empty()`).
* **BREAKING:** `f.ap(x)` is now `x.ap(f)`.
* Adds `parser.tryParse(str)` which either returns the parsed value or throws an exception.
* Adds support for `fantasy-land/*` prefixed versions of methods.
* `Parsimmon.empty()` is a copy of `parser.empty()`.
* Adds `.desc` descriptions for `digits`, `letters`, `optWhitespace`.
* Adds `Parsimmon.isParser`.
* Adds `parser.fallback(value)`.
* Parsimmon now only has one namespace. `Parsimmon.Parser` is equal to `Parsimmon` itself for backwards compatibility purposes.
* Exposes `Parsimmon.makeSuccess` and `Parsimmon.makeFailure`.
* Documentation for `Parsimmon.formatError`, `Parsimmon.parse`, `Parsimmon.Parser`, `Parsimmon.makeSuccess`, `Parsimmon.makeFailure`, `Parsimmon.isParser`, `parser.fallback`.
- **BREAKING:** `parser.empty` is now a function (`parser.empty()`).
- **BREAKING:** `f.ap(x)` is now `x.ap(f)`.
- Adds `parser.tryParse(str)` which either returns the parsed value or throws an
exception.
- Adds support for `fantasy-land/*` prefixed versions of methods.
- `Parsimmon.empty()` is a copy of `parser.empty()`.
- Adds `.desc` descriptions for `digits`, `letters`, `optWhitespace`.
- Adds `Parsimmon.isParser`.
- Adds `parser.fallback(value)`.
- Parsimmon now only has one namespace. `Parsimmon.Parser` is equal to
`Parsimmon` itself for backwards compatibility purposes.
- Exposes `Parsimmon.makeSuccess` and `Parsimmon.makeFailure`.
- Documentation for `Parsimmon.formatError`, `Parsimmon.parse`,
`Parsimmon.Parser`, `Parsimmon.makeSuccess`, `Parsimmon.makeFailure`,
`Parsimmon.isParser`, `parser.fallback`.

## version 0.9.2 (2016-08-07)

* Adds `browser` field to `package.json` so unpkg serves the correct file.
* Documentation overhaul in `README.md`.
* Examples overhaul.
- Adds `browser` field to `package.json` so unpkg serves the correct file.
- Documentation overhaul in `README.md`.
- Examples overhaul.

## version 0.9.1 (2016-07-08)

* **BREAKING:** `P.seqMap` now throws when passed zero arguments, or when the final argument is not a function.
* `P.regex` is now an alias for `P.regexp`.
- **BREAKING:** `P.seqMap` now throws when passed zero arguments, or when the
final argument is not a function.
- `P.regex` is now an alias for `P.regexp`.

## version 0.9.0 (2016-07-07)

* **BREAKING:** `P.regex` throws on regexps with flags other than `imu` now.
- **BREAKING:** `P.regex` throws on regexps with flags other than `imu` now.

## version 0.8.1 (2016-06-30)

* Optimizes internal set union function, which should result in slightly faster parsing
- Optimizes internal set union function, which should result in slightly faster
parsing

## version 0.8.0 (2016-06-28)

* The `.expected` array on parse results is now unique and sorted
* Updated Mocha and Chai versions
* Updated README a bit (mostly line wrapping stuff)
- The `.expected` array on parse results is now unique and sorted
- Updated Mocha and Chai versions
- Updated README a bit (mostly line wrapping stuff)

## version 0.7.2 (2016-06-26)

* No API changes
* Switches to npm-based task running
* Switches to UMD-based code
- No API changes
- Switches to npm-based task running
- Switches to UMD-based code

## version 0.7.1 (2016-06-04)

* Documentation updates
* Adds line/column information to `P.index` and `.mark()`
* Adds additional type assertions
- Documentation updates
- Adds line/column information to `P.index` and `.mark()`
- Adds additional type assertions

## version 0.7.0 (???)

This release may have been unpublished or something, I'm not exactly sure.

## version 0.6.0 (2015-02-24)

* add a second optional argument to `regex()` indicating group selection
* eliminates pjs dependency
* add seqMap, oneOf, and noneOf
- add a second optional argument to `regex()` indicating group selection
- eliminates pjs dependency
- add seqMap, oneOf, and noneOf

## version 0.5.1 (2014-06-25)

* Added .custom, .test, and .takeWhile for folks who don't like to use regexes.
- Added .custom, .test, and .takeWhile for folks who don't like to use regexes.

## version 0.5.0 (2014-06-15)

* Added `.desc()` for custom parse error messages
- Added `.desc()` for custom parse error messages

## version 0.4.0 (2014-04-18)

* **BREAKING:** deprecated use of `.then(function(result) { ... })`. Use `chain` instead.
* **BREAKING:** errors are no longer thrown on invalid parses. Instead, `.parse(str)` returns
an object with a `status` tag, indicating whether the parse was successful.
- **BREAKING:** deprecated use of `.then(function(result) { ... })`. Use `chain`
instead.
- **BREAKING:** errors are no longer thrown on invalid parses. Instead,
`.parse(str)` returns an object with a `status` tag, indicating whether the
parse was successful.

## version 0.3.2 (2014-04-18)

* never throw strings, always throw error objects
* add the MIT license
- never throw strings, always throw error objects
- add the MIT license

## version 0.3.1 (2014-03-12)

* add browser files to the npm package
- add browser files to the npm package

## version 0.3.0 (2014-03-12)

* started updating the changelog again :x
* **BREAKING:** `seq` and `alt` now take varargs instead of a single list argument.
- started updating the changelog again :x
- **BREAKING:** `seq` and `alt` now take varargs instead of a single list
argument.

## version 0.1.0 (2014-01-09)

* Uses less stack space with a non-cps implementation
* Added `Parsimmon.index` and `Parser::mark()`
* fantasyland compatibility
- Uses less stack space with a non-cps implementation
- Added `Parsimmon.index` and `Parser::mark()`
- fantasyland compatibility

## version 0.0.6 (2013-12-02)

* Better error messages: use the message from the furthest backtrack.
- Better error messages: use the message from the furthest backtrack.

## version 0.0.5 (2013-04-10)

* Fix a "build directory nonexistent" bug :\
- Fix a "build directory nonexistent" bug :\

## version 0.0.4 (2013-04-09)

* Started a CHANGELOG
* Specify pjs 3.x
* added "use strict"
* Stopped trying to subclass Error (was silencing all parse errors :\ )
- Started a CHANGELOG
- Specify pjs 3.x
- added "use strict"
- Stopped trying to subclass Error (was silencing all parse errors :\ )

(Note: v0.0.3 is completely b0rken, and was unpublished from npm)
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ A Parsimmon parser is an object that represents an action on a stream of text, a
The method `.map` is used to transform the yielded value. For example,

```javascript
Parsimmon.string('foo')
.map(function(x) { return x + 'bar'; })
Parsimmon.string("foo").map(function(x) {
return x + "bar";
});
```

will yield `'foobar'` if the stream starts with `'foo'`. The parser

```javascript
Parsimmon.regexp(/[0-9]+/)
.map(function(x) { return Number(x) * 2; })
Parsimmon.regexp(/[0-9]+/).map(function(x) {
return Number(x) * 2;
});
```

will yield the number `24` when it encounters the string `'12'`.
Expand Down Expand Up @@ -89,7 +91,7 @@ Feel free to ask a question by filing a GitHub Issue. I'm happy to help point yo

## Contributing

Contributions are *not* just pull requests.
Contributions are _not_ just pull requests.

Issues clearly describing bugs or confusing parts of Parsimmon are welcome! Also, documentation enhancements and examples are very desirable.

Expand All @@ -109,10 +111,8 @@ Parsimmon is also compatible with [fantasyland][]. It implements Semigroup, Appl
[@laughinghan]: https://github.com/laughinghan
[@jneen]: https://github.com/jneen
[@wavebeem]: https://github.com/wavebeem

[api]: https://github.com/jneen/parsimmon/blob/master/API.md
[examples]: https://github.com/jneen/parsimmon/tree/master/examples

[unpkg homepage]: https://unpkg.com/#/
[unpkg version]: https://unpkg.com/parsimmon
[npm]: https://www.npmjs.com/
Expand Down
25 changes: 6 additions & 19 deletions src/parsimmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function mergeReplies(result, last) {
}
var expected =
result.furthest === last.furthest
? unsafeUnion(result.expected, last.expected)
? union(result.expected, last.expected)
: last.expected;
return {
status: result.status,
Expand Down Expand Up @@ -291,31 +291,18 @@ function makeLineColumnIndex(input, i) {
};
}

// Returns the sorted set union of two arrays of strings. Note that if both
// arrays are empty, it simply returns the first array, and if exactly one
// array is empty, it returns the other one unsorted. This is safe because
// expectation arrays always start as [] or [x], so as long as we merge with
// this function, we know they stay in sorted order.
function unsafeUnion(xs, ys) {
// Exit early if either array is empty (common case)
var xn = xs.length;
var yn = ys.length;
if (xn === 0) {
return ys;
} else if (yn === 0) {
return xs;
}
// Two non-empty arrays: do the full algorithm
// Returns the sorted set union of two arrays of strings
function union(xs, ys) {
var obj = {};
for (var i = 0; i < xn; i++) {
for (var i = 0; i < xs.length; i++) {
obj[xs[i]] = true;
}
for (var j = 0; j < yn; j++) {
for (var j = 0; j < ys.length; j++) {
obj[ys[j]] = true;
}
var keys = [];
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
if ({}.hasOwnProperty.call(obj, k)) {
keys.push(k);
}
}
Expand Down

0 comments on commit 0d34bd7

Please sign in to comment.