Skip to content

Commit 2de9af5

Browse files
committed
Merge pull request #164 from rust-lang-nursery/dfa-pr
Add a lazy DFA.
2 parents 7120b80 + 2aa1727 commit 2de9af5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+19475
-1957
lines changed

.travis.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ script:
1313
- cargo test --verbose --manifest-path=regex-syntax/Cargo.toml
1414
- cargo doc --verbose --manifest-path=regex-syntax/Cargo.toml
1515
- if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
16-
cargo test --verbose --features pattern;
17-
cargo bench --verbose;
16+
travis_wait cargo test --verbose --features pattern;
17+
travis_wait cargo bench --verbose --bench dynamic;
18+
travis_wait cargo bench --manifest-path=regex-pcre-benchmark/Cargo.toml --verbose
1819
travis_wait cargo test --verbose --manifest-path=regex_macros/Cargo.toml;
19-
travis_wait cargo bench --verbose --manifest-path=regex_macros/Cargo.toml;
20+
travis_wait cargo bench --manifest-path=regex_macros/Cargo.toml --verbose --bench native bench::;
2021
fi
21-
# - |
22-
# [ $TRAVIS_RUST_VERSION != nightly ] || (
23-
# cargo test --verbose --features pattern &&
24-
# cargo bench --verbose &&
25-
# travis_wait cargo test --verbose --manifest-path=regex_macros/Cargo.toml &&
26-
# travis_wait cargo bench --verbose --manifest-path=regex_macros/Cargo.toml
27-
# )
2822
after_success: |
2923
[ $TRAVIS_BRANCH = master ] &&
3024
[ $TRAVIS_PULL_REQUEST = false ] &&

Cargo.toml

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,86 @@ repository = "https://github.com/rust-lang/regex"
88
documentation = "https://doc.rust-lang.org/regex"
99
homepage = "https://github.com/rust-lang/regex"
1010
description = """
11-
An implementation of regular expressions for Rust.
11+
An implementation of regular expressions for Rust. This implementation uses
12+
finite automata and guarantees linear time matching on all inputs.
1213
"""
1314

15+
[dependencies]
16+
# For very fast prefix literal matching.
17+
aho-corasick = "0.5"
18+
# For skipping along search text quickly when a leading byte is known.
19+
memchr = "0.1"
20+
# For parsing regular expressions.
21+
regex-syntax = { path = "regex-syntax", version = "0.2" }
22+
# For compiling UTF-8 decoding into automata.
23+
utf8-ranges = "0.1"
24+
25+
[dev-dependencies]
26+
# To prevent the benchmarking harness from running setup code more than once.
27+
# Why? Because it takes too long.
28+
lazy_static = "0.1"
29+
# For generating random text to test/benchmark with.
30+
rand = "0.3"
31+
32+
[features]
33+
# Enable to use the unstable pattern traits defined in std.
34+
pattern = []
35+
36+
# Runs unit tests defined inside the regex package.
37+
# Generally these tests specific pieces of the regex implementation.
1438
[[test]]
1539
path = "src/lib.rs"
1640
name = "regex"
1741

42+
# Run the test suite on the default behavior of Regex::new.
43+
# This includes a mish mash of NFAs and DFAs, which are chosen automatically
44+
# based on the regex. We test both of the NFA implementations by forcing their
45+
# usage with the test definitions below. (We can't test the DFA implementations
46+
# in the same way since they can't be used for every regex tested.)
1847
[[test]]
19-
path = "regex_macros/tests/test_dynamic.rs"
48+
path = "tests/test_dynamic.rs"
2049
name = "dynamic"
2150

51+
# Run the test suite on the NFA algorithm over Unicode codepoints.
52+
[[test]]
53+
path = "tests/test_dynamic_nfa.rs"
54+
name = "dynamic-nfa"
55+
56+
# Run the test suite on the NFA algorithm over bytes.
57+
[[test]]
58+
path = "tests/test_dynamic_nfa_bytes.rs"
59+
name = "dynamic-nfa-bytes"
60+
61+
# Run the test suite on the backtracking engine over Unicode codepoints.
2262
[[test]]
23-
path = "regex_macros/tests/test_dynamic_nfa.rs"
24-
name = "dynamic_nfa"
63+
path = "tests/test_dynamic_backtrack.rs"
64+
name = "dynamic-backtrack"
2565

66+
# Run the test suite on the backtracking engine over bytes.
2667
[[test]]
27-
path = "regex_macros/tests/test_dynamic_backtrack.rs"
28-
name = "dynamic_backtrack"
68+
path = "tests/test_dynamic_backtrack_bytes.rs"
69+
name = "dynamic-backtrack-bytes"
2970

71+
# Run the benchmarks on the default behavior of Regex::new.
72+
#
73+
# N.B. These benchmarks were originally taken from Russ Cox.
3074
[[bench]]
31-
name = "all"
32-
path = "regex_macros/benches/bench_dynamic.rs"
75+
name = "dynamic"
76+
path = "benches/bench_dynamic.rs"
3377
test = false
3478
bench = true
3579

36-
[dependencies]
37-
aho-corasick = "0.4"
38-
memchr = "0.1"
39-
regex-syntax = { path = "regex-syntax", version = "0.2" }
40-
41-
[dev-dependencies]
42-
rand = "0.3"
43-
44-
[features]
45-
pattern = []
80+
# Run the benchmarks on the NFA algorithm. We avoid chasing other permutations.
81+
#
82+
# N.B. These can take a *loong* time to run.
83+
[[bench]]
84+
name = "dynamic-nfa"
85+
path = "benches/bench_dynamic_nfa.rs"
86+
test = false
87+
bench = true
4688

4789
[profile.bench]
48-
lto = true
90+
debug = true
91+
92+
[profile.test]
93+
debug = true

0 commit comments

Comments
 (0)