Skip to content

Commit

Permalink
Merge branch 'zero-copy'
Browse files Browse the repository at this point in the history
  • Loading branch information
zesterer committed Mar 2, 2023
2 parents e656589 + a911c9e commit 954bf29
Show file tree
Hide file tree
Showing 33 changed files with 7,741 additions and 4,748 deletions.
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 @@ -32,5 +32,5 @@ jobs:
with:
toolchain: nightly
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.9.2"
description = "A parser library for humans with powerful error recovery"
authors = ["Joshua Barretto <[email protected]>"]
authors = ["Joshua Barretto <[email protected]>", "Elijah Hartvigsen <[email protected]", "Jakob Wiesmore <[email protected]>"]
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.12.3"
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 @@ -56,7 +56,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 @@ -66,7 +66,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

0 comments on commit 954bf29

Please sign in to comment.