Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for zero-copy parsing #82

Merged
merged 259 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
259 commits
Select commit Hold shift + click to select a range
65bccf7
Fix extra lifetime for reference
CraftSpider Feb 25, 2022
c1143bf
Fix self-referential recursive
CraftSpider Feb 25, 2022
483a1fb
Add nom benchmark
wackbyte Feb 28, 2022
b2a5f20
Fix duplicate inline attributes and a doc warning
wackbyte Feb 27, 2022
44d0f5b
Added side errors and side error rewinding
zesterer Mar 12, 2022
96248fe
Reworked file structure
zesterer Mar 12, 2022
2160d58
implement at_most for Repeated and add PaddedBy and SeparatedBy
wackbyte Mar 13, 2022
febd6f6
Merge pull request #103 from wackbyte/zc-rep
zesterer Mar 13, 2022
6e34737
add the separated_by_exactly combinator and the any, empty, and one_o…
wackbyte Mar 13, 2022
c66687a
support no_std again
wackbyte Mar 13, 2022
0d3d4f6
use separated_by for the zero-copy json benchmark
wackbyte Mar 13, 2022
83ebdb6
Merge pull request #104 from wackbyte/zero-copy-more
zesterer Mar 13, 2022
60727f6
Removed redundant pieces from benchmark parser
zesterer Mar 13, 2022
1d6f631
Added container parameter to RepeatedExactly and SeparatedByExactly
zesterer Mar 14, 2022
eab69bd
Hide implementation details
zesterer Mar 14, 2022
d7b0523
Don't inline so eagerly
zesterer Mar 15, 2022
889c4b0
add `then_with` to zero-copy
wackbyte Mar 14, 2022
7956fa4
add `rewind` to zero-copy
wackbyte Mar 15, 2022
0f691e0
Merge pull request #106 from wackbyte/zero-copy-more-again
zesterer Mar 15, 2022
cae386e
Add String, HashSet, and BTree{Map, Set} to Container implementations
CraftSpider Mar 16, 2022
c1c841f
Merge pull request #108 from CraftSpider/craft-zero-copy
zesterer Mar 16, 2022
217699f
Implement missing primitives (TakeUntil is under-tested)
CraftSpider Mar 18, 2022
da2b14a
Make take_until pub
CraftSpider Mar 18, 2022
a10b382
match -> if let
CraftSpider Mar 18, 2022
083568c
Add new primitives to prelude
CraftSpider Mar 22, 2022
6a82f90
Merge pull request #110 from CraftSpider/zero-copy-completion
zesterer Mar 22, 2022
7c23e6b
Made Error trait more useful
zesterer May 13, 2022
4765582
Added basic error prioritisation
zesterer May 13, 2022
c1827ed
Fix Copy/Clone impls + where clause location
CraftSpider May 13, 2022
5612c21
Add missing bounds
CraftSpider May 13, 2022
8125854
Add flatten combinator
CraftSpider May 14, 2022
7ecc252
Merge pull request #138 from CraftSpider/zero-copy-fix
zesterer May 14, 2022
c008035
Add some state combinators
CraftSpider May 14, 2022
5830353
Add filter_map_state to prelude
CraftSpider May 14, 2022
97c3313
Switch to criterion for benchmarks
zesterer May 14, 2022
4beb5e7
Fixed regex tests
zesterer May 14, 2022
1732ee6
Span in filter_map_state
CraftSpider May 14, 2022
614aea9
No more filter primitives
CraftSpider May 16, 2022
e8a578e
Merge pull request #140 from CraftSpider/zero-copy-state
zesterer May 16, 2022
68e4e15
Clean up warnings/require nightly for zero_copy
CraftSpider May 16, 2022
14e785c
Merge pull request #142 from CraftSpider/zero-copy-warnings
zesterer May 16, 2022
d6ee333
Fix typo in try_map_with_state, import issues in tests
CraftSpider May 17, 2022
27c95e3
Merge pull request #143 from CraftSpider/zero-copy-typo
zesterer May 17, 2022
5f070c3
Implement remaining combinators except validate
CraftSpider May 31, 2022
c9ac7d7
Merge pull request #149 from CraftSpider/zero-copy-completion
zesterer Jun 1, 2022
33f49e7
Fix benchmark
zesterer Jun 3, 2022
f2d0b74
Make map_with_state vs try_map_with_state match map vs try_map
CraftSpider Jun 6, 2022
6db320b
Don't elide, keep signature change
CraftSpider Jun 7, 2022
35270f4
Merge pull request #152 from CraftSpider/zero-copy-elide-map-with-state
zesterer Jun 8, 2022
52fd2eb
fix: change core::lazy::OnceCell to core::cell::OnceCell
dawnofmidnight Aug 10, 2022
63b08a8
Merge pull request #183 from dawnofmidnight/zero-copy
zesterer Aug 10, 2022
78f7c99
ZeroCopyCleanup: Simplify <str as Input>::next
Zij-IT Aug 13, 2022
c5abf58
ZeroCopyCleanup: Use Option::filter to simplify InputRef::skip_while
Zij-IT Aug 13, 2022
6052638
ZeroCopyCleanup: Simplify append_to for Option<T>
Zij-IT Aug 13, 2022
d2bdda4
ZeroCopyCleanup: Replace match with ?
Zij-IT Aug 13, 2022
58d3e0c
ZeroCopyCleanup: Call rfold instead of .rev().fold() on DoubleEndedIt…
Zij-IT Aug 13, 2022
b192316
ZeroCopyCleanup: Run cargo fmt
Zij-IT Aug 13, 2022
2f70742
ZeroCopyClean: Add hybrid variant instead of previous
Zij-IT Aug 15, 2022
2f2a4d2
Merge pull request #190 from Zij-IT/zero-copy-cleanup
zesterer Aug 15, 2022
104157e
Added optimisation for inline recursive declarations
zesterer Aug 17, 2022
60b58b8
ZeroCopySeparatedBy: Add tests from `master` used for testing the non…
Zij-IT Aug 26, 2022
8b71975
ZeroCopySeparatedBy: Add reworked version that passes tests
Zij-IT Aug 26, 2022
88f3b04
Merge pull request #197 from Zij-IT/zero-copy-separatedby
zesterer Aug 26, 2022
570e1d1
ZeroCopyFixes: Fix parser implementation which had two bugs:
Zij-IT Aug 27, 2022
7d20f84
ZeroCopyFixes: Undo change to `<str as Input>::next` which I broke...
Zij-IT Aug 27, 2022
0ebd9e5
ZeroCopyFixes: Add myself as author :D
Zij-IT Aug 27, 2022
7733322
Merge pull request #198 from Zij-IT/zero-copy-fixes
zesterer Aug 28, 2022
1edd06b
remove #![feature(generic_associated_types)]
wackbyte Sep 23, 2022
f859f2b
constify primitive creation functions
wackbyte Sep 23, 2022
2d7e477
add group primitive
wackbyte Sep 23, 2022
8a74093
bump dependencies
wackbyte Sep 23, 2022
159e97c
add group to prelude
wackbyte Sep 23, 2022
5d07059
add a newline :)
wackbyte Sep 23, 2022
bd268c6
test group
wackbyte Sep 23, 2022
94a4d86
don't rewind on failure in group
wackbyte Sep 24, 2022
26b9a96
Merge pull request #203 from wackbyte/zero-copy-stuff
zesterer Sep 26, 2022
7872fa8
add `and_is` and `not` combinators
wackbyte Sep 29, 2022
73f8364
`not` does not consume any input on success
wackbyte Oct 28, 2022
1d5f110
Merge pull request #211 from wackbyte/zero-copy-and-is-not
zesterer Oct 28, 2022
39c1c96
Prepare Output migration: Parser accept both trait type and type param
bew Nov 12, 2022
0a5d5b0
Rename type param `O` for functions that already had an 'O'
bew Nov 13, 2022
c4fd846
Fix trait bounds in file src/zero_copy/mod.rs \o/
bew Nov 13, 2022
334b27f
Fix trait bounds for file src/zero_copy/blanket.rs
bew Nov 13, 2022
e1491f6
Fix trait bounds for combinators, before Map
bew Nov 13, 2022
a8328ea
(not sure..) Try fix trait bound for Map-related types
bew Nov 13, 2022
5f4f036
(not sure) Try fix trait bound for many combinators (not all)
bew Nov 13, 2022
8e5c8f4
(not sure) Fix trait bound for remaining combinators
bew Nov 13, 2022
703443f
Fix almost all trait bound for file src/zero_copy/primitive.rs
bew Nov 13, 2022
aa1a397
Fix trait bounds for file src/zero_copy/recursive.rs
bew Nov 13, 2022
f4a2f1e
Fix trait bounds for file src/zero_copy/text.rs
bew Nov 13, 2022
8c0b8fd
More trait bound fixes (still not compiling), fix go_extra! macro
bew Nov 13, 2022
db91a99
Fix more! Remove 'Output' from Parser. It builds!!
bew Nov 13, 2022
fc7d862
Fix trait bound for file src/zero_copy/regex.rs
bew Nov 13, 2022
80e649a
Simplify `or` type params
bew Nov 13, 2022
62e7a1b
Remove use of 'Output' in tests (don't compile tho, I don't understand)
bew Nov 13, 2022
e488f51
Remove useless feature (added to be able to compile previously)
bew Nov 15, 2022
f489c0a
Fix macro impl_group_for_tuple (thanks @wackbyte)
bew Nov 15, 2022
15a8102
Fix MapSlice
Jan 1, 2023
1e85f6d
Fix recursive example
Jan 1, 2023
9965a0d
Port semantic identiation parser
Jan 1, 2023
716884e
Change Ingored to less superfluous type
Jan 2, 2023
853e770
Fix json benchmark
Jan 2, 2023
1926608
Port text parsers
Jan 2, 2023
1cee650
Add Seq implementation for slice
Jan 2, 2023
c3abfad
Fix pythonic example
Jan 2, 2023
90934cf
Port FilterMap
Jan 2, 2023
adb6218
Fix text parsers to make their implementation match their documentation
Jan 2, 2023
6972693
Add text::inline_whitespace
Jan 2, 2023
25a9c68
Remove PhantomData FIXMEs
Jan 2, 2023
eabca7e
Remove FilterMap/filter_map in favor of TryMap/try_map
Jan 2, 2023
44147ad
Remove unnecessary lifetime bounds
Jan 4, 2023
95c4776
Merge pull request #240 from herkhinah/shekhinah/cherry-pick
zesterer Jan 4, 2023
5028009
Add state type parameter to text functions
Jan 4, 2023
ebd84bc
Remove unnecessary trait bounds in text::semantic_indentations
Jan 4, 2023
019bdc1
Merge pull request #245 from herkhinah/shekhinah/text-fixes
zesterer Jan 4, 2023
5fd3493
Start adding documentation to most zero-copy items
CraftSpider Jan 7, 2023
5d70419
All but map_slice and group
CraftSpider Jan 7, 2023
4e4a3f7
Make all zero_copy docs use zero_copy prelude, and fix combinators, r…
CraftSpider Jan 8, 2023
868d160
Fix primitive doc-tests
CraftSpider Jan 8, 2023
382174d
Everything but recover_with
CraftSpider Jan 8, 2023
bd17e99
Fix recover_with, error due to implementation change
CraftSpider Jan 8, 2023
f4ad5cd
Add basic docs to group and map_slice
CraftSpider Jan 9, 2023
b524a69
Merge pull request #247 from CraftSpider/zero-copy-doc
zesterer Jan 9, 2023
5b75c58
make zero_copy work on stable
CraftSpider Jan 9, 2023
1cfa3d4
Merge pull request #251 from CraftSpider/feature-fix
zesterer Jan 9, 2023
e3e13ff
Fix recover_with doctest and error emission
CraftSpider Jan 9, 2023
8918b72
Merge pull request #252 from CraftSpider/fix-recover
CraftSpider Jan 9, 2023
ce645b0
Make parse return a custom type
CraftSpider Jan 9, 2023
7aaa1ad
Make `ParseResult` a struct, update tests, add documentation about wh…
CraftSpider Jan 9, 2023
09a3b86
Merge pull request #253 from CraftSpider/parse-enum
zesterer Jan 9, 2023
7d812c3
errors as iterator, and import vec macro on no_std
CraftSpider Jan 9, 2023
7dd6fc9
Minor cleanups
CraftSpider Jan 9, 2023
5a2aea6
Improve skip_while speed significantly
CraftSpider Jan 9, 2023
aff9b11
Merge pull request #254 from CraftSpider/minor-fixed
zesterer Jan 10, 2023
70dc23e
Implement validate on zero_copy, expand `Rich` with kinds and custom …
CraftSpider Jan 11, 2023
0979fbb
Fix validate doctest
CraftSpider Jan 11, 2023
b066025
Add reason gettre
CraftSpider Jan 11, 2023
743c172
Emitter instead of trait object
CraftSpider Jan 11, 2023
7984649
Add `slice` combinator
CraftSpider Jan 12, 2023
045b031
Fix typo
CraftSpider Jan 12, 2023
6b12d98
Merge pull request #258 from CraftSpider/zero-copy-slice
zesterer Jan 12, 2023
ef0aaaf
Change default span type to `SimpleSpan`
CraftSpider Jan 13, 2023
7814887
Make default error `EmptyErr` not `()`
CraftSpider Jan 13, 2023
01df512
Fix typo
CraftSpider Jan 13, 2023
774b29d
Span display fix
CraftSpider Jan 14, 2023
69e3c79
Merge pull request #256 from CraftSpider/expand-errors
zesterer Jan 15, 2023
154f553
Move container traits into module + add more impls
CraftSpider Jan 15, 2023
2489832
Fix bounds
CraftSpider Jan 15, 2023
1c63d74
Contains, also allow RangeInclusive
CraftSpider Jan 16, 2023
1b5100e
Better range impls
CraftSpider Jan 16, 2023
135b577
Merge pull request #259 from CraftSpider/improve-container
zesterer Jan 16, 2023
6a7a26c
Stabilize minimal interface for custom parsers
CraftSpider Jan 20, 2023
910b47d
Add docs and change `Located::at`
CraftSpider Jan 20, 2023
31153df
Merge pull request #260 from CraftSpider/zc-stabilize-input
zesterer Jan 20, 2023
7271b79
Add self to `Cargo.toml`
CraftSpider Jan 24, 2023
0648a0f
Merge pull request #264 from zesterer/zc-author
CraftSpider Jan 24, 2023
c658f0b
impl `Container` for usize, add `count` methods to `Repeated` and `Se…
wackbyte Feb 3, 2023
c4ddece
Tiny consistency fixes between `Repeated` and `SeparatedBy`
wackbyte Feb 3, 2023
eddbd59
Consistent punctuation in `container`
wackbyte Feb 3, 2023
1b60bf9
impl `IntoIterator` into `Range` for `SimpleSpan`
wackbyte Feb 3, 2023
10b2bcf
Fix no_std compilation
wackbyte Feb 3, 2023
a326a15
Add really basic tests/examples to `{Repeated,SeparatedBy}::count`
wackbyte Feb 3, 2023
a7c5a14
Update dependencies
wackbyte Feb 3, 2023
15fd338
Merge pull request #266 from wackbyte/container-usize
zesterer Feb 3, 2023
3cfb9a3
Merge pull request #267 from wackbyte/bump-deps
zesterer Feb 6, 2023
1ed5392
Change how parser generic works
CraftSpider Jan 20, 2023
d1e55d8
Make everything wrappers over `Full`
CraftSpider Feb 7, 2023
47489ee
Merge pull request #262 from CraftSpider/zc-parser-extra
zesterer Feb 7, 2023
901f0b0
Added support for iterable parsers
zesterer Feb 8, 2023
5c3c830
Switched 'collect' to being a method on IterParser, new zero-copy exa…
zesterer Feb 8, 2023
2fe0fe5
Addressed review comments
zesterer Feb 8, 2023
3698843
Merge pull request #270 from zesterer/parse-iter
zesterer Feb 8, 2023
2f462f8
Summon `Context` from the void, configuration a priori
CraftSpider Feb 8, 2023
fedfd5e
Update by review
CraftSpider Feb 8, 2023
b429a3c
Added indent example
zesterer Feb 8, 2023
1868d44
Use new combinators, reverse &mut Cfg change
zesterer Feb 8, 2023
f637c5d
Configure as a trait, and make it work for IterParsers
CraftSpider Feb 12, 2023
071efb2
Format
CraftSpider Feb 12, 2023
50aba26
Merge pull request #269 from CraftSpider/zc-context
zesterer Feb 13, 2023
00de90d
Began adding recovery parsers, fixed derived Copy/Clone
zesterer Feb 8, 2023
0b26351
Fixed JSON example
zesterer Feb 8, 2023
e34e64d
Added nested_delimiters recovery parser
zesterer Feb 9, 2023
1434b81
Merge pull request #271 from zesterer/fix-examples
zesterer Feb 13, 2023
b567ee7
Fix foo example, various API improvements
zesterer Feb 13, 2023
8454777
Merge pull request #275 from zesterer/fix-examples
zesterer Feb 13, 2023
4bc36de
Make SeparatedBy implement IterParser
CraftSpider Feb 13, 2023
1c9a3f7
Merge pull request #277 from CraftSpider/zc-separated-iter
zesterer Feb 14, 2023
bd32a45
Start running CI on zero-copy
CraftSpider Feb 16, 2023
19f0c68
Fix regex compile
CraftSpider Feb 16, 2023
c9b5bed
Fix regex tests
CraftSpider Feb 16, 2023
79c4816
Fix typo
CraftSpider Feb 16, 2023
e6cf173
Substantial performance improvements by dropping a usize from Marker
zesterer Feb 16, 2023
fbc862d
Added pest benchmark
zesterer Feb 16, 2023
2eafb2c
Merge pull request #281 from CraftSpider/zc-ci
zesterer Feb 16, 2023
85851d9
Merge pull request #282 from zesterer/perf
zesterer Feb 16, 2023
2b77004
Fix regex compile
CraftSpider Feb 16, 2023
7e5f334
Add logos benchmark
CraftSpider Feb 16, 2023
12a66b9
Add at least basic docs to all TODO doc items, fix up ctx and add doc…
CraftSpider Feb 16, 2023
9f58c0d
Add inline after rebase
CraftSpider Feb 16, 2023
f87b4e3
Merge pull request #284 from CraftSpider/zc-logos
zesterer Feb 16, 2023
7373b7c
Merge pull request #283 from CraftSpider/zc-cleanup
zesterer Feb 16, 2023
651d823
Reduced use of Marker for more performance wins
zesterer Feb 16, 2023
7aa32b7
Merge pull request #285 from zesterer/perf
zesterer Feb 16, 2023
a343723
Update choice impl a little, add array impl from master
CraftSpider Feb 17, 2023
a1bbe4e
Merge pull request #287 from CraftSpider/zc-choice-experiment
zesterer Feb 18, 2023
67d9b45
Perf improvements and minor tweaks
zesterer Feb 18, 2023
cf7b266
Merge pull request #289 from zesterer/perf
zesterer Feb 18, 2023
b2581c8
Added memoised parser
zesterer Feb 18, 2023
8ceebd6
Don't create memoisation structures when we don't need it
zesterer Feb 19, 2023
66234d0
impl Parser for !
wackbyte Feb 21, 2023
faab2ea
Merge pull request #294 from wackbyte/never-parser
zesterer Feb 21, 2023
af0e279
Switched to US spelling
zesterer Feb 22, 2023
8d0a5e3
Merge pull request #290 from zesterer/memoisation
zesterer Feb 22, 2023
c348981
Switched back to next from peek due to negligible performance impact
zesterer Feb 22, 2023
d2e3f42
Added select! to zero-copy, added initial support for nested inputs
zesterer Feb 22, 2023
c6580a7
Fixed select doc test
zesterer Feb 22, 2023
50e19b8
Switched to input-by-reference to get around nested lifetime issue
zesterer Feb 23, 2023
cf98b6b
Simplified nested example
zesterer Feb 23, 2023
0e8039e
Don't break no_std targets
zesterer Feb 23, 2023
b65ab78
Make non-standard feature tests work again
zesterer Feb 23, 2023
72aab5c
Merge pull request #296 from zesterer/nested
zesterer Feb 23, 2023
017fd26
Switch foldl/foldr to use IterParser
zesterer Feb 23, 2023
3b1aa5c
Merge pull request #297 from zesterer/iter-fold
zesterer Feb 23, 2023
438fc21
Make parses no longer lazy by default
zesterer Feb 23, 2023
caaf680
Removed then_with
zesterer Feb 23, 2023
59b114c
Merge pull request #299 from zesterer/not-lazy
zesterer Feb 23, 2023
6b684a0
Added `Stream` input
zesterer Feb 24, 2023
0e92038
Added sn benchmark as a standard candle for a zero-copy hand written …
zesterer Feb 24, 2023
ae5ac1f
Added way to create streams
zesterer Feb 24, 2023
c22c204
Removed superfluous comment
zesterer Feb 27, 2023
ece643c
Merge pull request #300 from zesterer/stream
zesterer Feb 27, 2023
f5cbbc9
Simplified make_iter
zesterer Feb 27, 2023
2a2a84e
Reimplemented alt error prioritisation, added more recovery strategies
zesterer Feb 28, 2023
f2b2d09
Made expect_end add secondary error, not primary error
zesterer Feb 28, 2023
b0b9dc7
Fixed tests
zesterer Feb 28, 2023
4324d7c
Merge pull request #304 from zesterer/error-prio
zesterer Feb 28, 2023
88c8c83
Added select_ref
zesterer Mar 1, 2023
3a8cee2
Merge pull request #306 from zesterer/select_ref
zesterer Mar 1, 2023
bbf2675
Added support for spanned streams
zesterer Mar 1, 2023
3255493
Revert Stream constructor name
zesterer Mar 1, 2023
53f5e20
Improved docs
zesterer Mar 1, 2023
a47b774
Implemented BorrowInput for Spanned
zesterer Mar 1, 2023
c968afc
Relaxed Offset = usize requirement on Input for Spanned
zesterer Mar 1, 2023
73c5972
Cleaned up API
zesterer Mar 1, 2023
b71ef8a
Doc improvements
zesterer Mar 1, 2023
1867d2e
Merge pull request #307 from zesterer/complex-streams
zesterer Mar 1, 2023
b38db3e
Removed old chumsky code
zesterer Mar 1, 2023
6ff8680
Fixed tests, temporarily commented out nano_rust
zesterer Mar 1, 2023
ff32978
Simplified Input impl for Stream, better nested_in impl
zesterer Mar 2, 2023
a911c9e
Merge pull request #311 from zesterer/prepare-for-alpha
zesterer Mar 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Rust

on:
push:
branches: [ master ]
branches: [ master, zero-copy ]
pull_request:
branches: [ master ]
branches: [ master, zero-copy ]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -34,5 +34,5 @@ jobs:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Run cargo check
- name: Run cargo test
run: cargo test --verbose --all-features
41 changes: 29 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "chumsky"
version = "0.8.0"
description = "A parser library for humans with powerful error recovery"
authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>"]
authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>", "Elijah Hartvigsen <elijah.reed@hartvigsen.xyz", "Jakob Wiesmore <runetynan@gmail.com>"]
repository = "https://github.com/zesterer/chumsky"
license = "MIT"
keywords = ["parser", "combinator", "token", "language", "syntax"]
Expand All @@ -14,24 +14,41 @@ exclude = [
]

[features]
default = ["ahash", "std", "spill-stack"]
# Use `ahash` instead of the standard hasher for maintaining sets of expected inputs
# (Also used if `std` is disabled)
ahash = []
default = ["std", "spill-stack", "memoization"]
# Integrate with the standard library
std = []
# Enable nightly-only features like better compiler diagnostics
# Enable nightly-only features like better compiler diagnostics and a Parser impl for ! (the never type)
nightly = []
# Allows deeper recursion by dynamically spilling stack state on to the heap
spill-stack = ["stacker", "std"]
# Allows parser memoisation, speeding up heavily back-tracking parsers and allowing left recursion
memoization = []

[dependencies]
# Used if `std` is disabled.
# Provides `ahash` for the corresponding feature as it uses it by default.
# Due to https://github.com/rust-lang/cargo/issues/1839, this can't be optional
hashbrown = "0.11"
hashbrown = "0.13"
stacker = { version = "0.1", optional = true }
# Enables regex combinators
regex = { version = "1.7", optional = true }

[dev-dependencies]
ariadne = "0.1.2"
pom = "3.0"
ariadne = "0.1.5"
pom = "3.2"
nom = "7.1"
serde_json = { version = "1.0", features = ["preserve_order"] }
criterion = "0.4.0"
pest = "2.5"
pest_derive = "2.5"
sn = "0.1"
logos = "0.12"

[[bench]]
name = "json"
harness = false

[[bench]]
name = "lex"
harness = false

[[bench]]
name = "parser"
harness = false
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum Instr {
Loop(Vec<Self>),
}

fn parser() -> impl Parser<char, Vec<Instr>, Error = Simple<char>> {
fn parser<'a>() -> impl Parser<'a, &'a str, Vec<Instr>> {
recursive(|bf| choice((
just('<').to(Instr::Left),
just('>').to(Instr::Right),
Expand All @@ -51,7 +51,8 @@ fn parser() -> impl Parser<char, Vec<Instr>, Error = Simple<char>> {
just('.').to(Instr::Write),
bf.delimited_by(just('['), just(']')).map(Instr::Loop),
))
.repeated())
.repeated()
.collect())
}
```

Expand Down
35 changes: 35 additions & 0 deletions benches/json.pest
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
WHITESPACE = _{ " " | "\t" | "\r" | "\n" }

object = {
"{" ~ "}" |
"{" ~ pair ~ ("," ~ pair)* ~ "}"
}
pair = { string ~ ":" ~ value }

array = {
"[" ~ "]" |
"[" ~ value ~ ("," ~ value)* ~ "]"
}

value = _{ object | array | string | number | boolean | null }

boolean = { "true" | "false" }

null = { "null" }

string = ${ "\"" ~ inner ~ "\"" }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}

number = @{
"-"?
~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)
~ ("." ~ ASCII_DIGIT*)?
~ (^"e" ~ ("+" | "-")? ~ ASCII_DIGIT+)?
}

json = _{ SOI ~ (object | array) ~ EOI }
Loading