]> git.lizzy.rs Git - rust.git/blob - src/libregex/lib.rs
Merge pull request #20510 from tshepang/patch-6
[rust.git] / src / libregex / lib.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10 //
11 // ignore-lexer-test FIXME #15679
12
13 //! Regular expressions implemented in Rust
14 //!
15 //! For official documentation, see the rust-lang/regex crate
16
17 #![crate_name = "regex"]
18 #![crate_type = "rlib"]
19 #![crate_type = "dylib"]
20 #![experimental = "use the crates.io `regex` library instead"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23        html_root_url = "http://doc.rust-lang.org/nightly/",
24        html_playground_url = "http://play.rust-lang.org/")]
25
26 #![allow(unknown_features)]
27 #![feature(macro_rules, phase, slicing_syntax, globs)]
28 #![feature(unboxed_closures)]
29 #![feature(associated_types)]
30 #![deny(missing_docs)]
31
32 #[cfg(test)]
33 extern crate "test" as stdtest;
34 #[cfg(test)]
35 extern crate rand;
36
37 // During tests, this links with the `regex` crate so that the `regex!` macro
38 // can be tested.
39 #[cfg(test)]
40 extern crate regex;
41
42 // Unicode tables for character classes are defined in libunicode
43 extern crate unicode;
44
45 pub use parse::Error;
46 pub use re::{Regex, Captures, SubCaptures, SubCapturesPos};
47 pub use re::{FindCaptures, FindMatches};
48 pub use re::{Replacer, NoExpand, RegexSplits, RegexSplitsN};
49 pub use re::{quote, is_match};
50
51 mod compile;
52 mod parse;
53 mod re;
54 mod vm;
55
56 #[cfg(test)]
57 mod test;
58
59 /// The `native` module exists to support the `regex!` macro. Do not use.
60 #[doc(hidden)]
61 pub mod native {
62     // Exporting this stuff is bad form, but it's necessary for two reasons.
63     // Firstly, the `regex!` syntax extension is in a different crate and
64     // requires access to the representation of a regex (particularly the
65     // instruction set) in order to compile to native Rust. This could be
66     // mitigated if `regex!` was defined in the same crate, but this has
67     // undesirable consequences (such as requiring a dependency on
68     // `libsyntax`).
69     //
70     // Secondly, the code generated by `regex!` must *also* be able
71     // to access various functions in this crate to reduce code duplication
72     // and to provide a value with precisely the same `Regex` type in this
73     // crate. This, AFAIK, is impossible to mitigate.
74     //
75     // On the bright side, `rustdoc` lets us hide this from the public API
76     // documentation.
77     pub use compile::{
78         Program,
79         OneChar, CharClass, Any, Save, Jump, Split,
80         Match, EmptyBegin, EmptyEnd, EmptyWordBoundary,
81     };
82     pub use parse::{
83         FLAG_EMPTY, FLAG_NOCASE, FLAG_MULTI, FLAG_DOTNL,
84         FLAG_SWAP_GREED, FLAG_NEGATED,
85     };
86     pub use re::{Dynamic, ExDynamic, Native, ExNative};
87     pub use vm::{
88         MatchKind, Exists, Location, Submatches,
89         StepState, StepMatchEarlyReturn, StepMatch, StepContinue,
90         CharReader, find_prefix,
91     };
92 }