From 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 Mon Sep 17 00:00:00 2001 From: Date: Mon, 29 Jun 2015 20:16:15 +0000 Subject: Update documentation --- regex_syntax/index.html | 223 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 regex_syntax/index.html (limited to 'regex_syntax/index.html') diff --git a/regex_syntax/index.html b/regex_syntax/index.html new file mode 100644 index 0000000..2c4ad5c --- /dev/null +++ b/regex_syntax/index.html @@ -0,0 +1,223 @@ + + + + + + + + + + regex_syntax - Rust + + + + + + + + + + + + + + + +
+

Crate regex_syntax + + [] + + [src]

+

This crate provides a regular expression parser and an abstract syntax for +regular expressions. The abstract syntax is defined by the Expr type. The +concrete syntax is enumerated in the +regex +crate documentation.

+ +

Note that since this crate is first and foremost an implementation detail for +the regex crate, it may experience more frequent breaking changes. It is +exposed as a separate crate so that others may use it to do analysis on regular +expressions or even build their own matching engine.

+ +

Example: parsing an expression

+

Parsing a regular expression can be done with the Expr::parse function.

+
+use regex_syntax::Expr;
+
+assert_eq!(Expr::parse(r"ab|yz").unwrap(), Expr::Alternate(vec![
+    Expr::Literal { chars: vec!['a', 'b'], casei: false },
+    Expr::Literal { chars: vec!['y', 'z'], casei: false },
+]));
+
+ +

Example: inspecting an error

+

The parser in this crate provides very detailed error values. For example, +if an invalid character class range is given:

+
+use regex_syntax::{Expr, ErrorKind};
+
+let err = Expr::parse(r"[z-a]").unwrap_err();
+assert_eq!(err.position(), 4);
+assert_eq!(err.kind(), &ErrorKind::InvalidClassRange {
+    start: 'z',
+    end: 'a',
+});
+
+ +

Or unbalanced parentheses:

+
+use regex_syntax::{Expr, ErrorKind};
+
+let err = Expr::parse(r"ab(cd").unwrap_err();
+assert_eq!(err.position(), 2);
+assert_eq!(err.kind(), &ErrorKind::UnclosedParen);
+
+

Structs

+ + + + + + + + + + + + + + + +
CharClass +

A character class.

+ +
ClassRange +

A single inclusive range in a character class.

+ +
Error +

A parse error.

+ +

Enums

+ + + + + + + + + + + + + + + +
ErrorKind +

The specific type of parse error that can occur.

+ +
Expr +

A regular expression abstract syntax tree.

+ +
Repeater +

The type of a repeat operator expression.

+ +

Functions

+ + + + + +
quote +

Escapes all regular expression meta characters in text.

+ +

Type Definitions

+ + + + + +
Result +

An alias for computations that can return a Error.

+ +
+ + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3