-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
73 lines (71 loc) · 1.97 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! regex - Regular expression pattern matching and replacement
//!
//! ## Usage
//! see regex.rs test mod
//!
//!
//! ## Regular Expressions:
//!
//! char match itself, emit code 'EXACTLY char'
//!
//! . match any character. emit code 'ANY'
//!
//! \ matches the character following it. emit code 'EXACTLY char'
//!
//! [set] matches one of the characters in the set.
//! If the first character in the set is "^",
//! it matches a character NOT in the set,
//! emit code 'ANYOF set' or "ANYBUT set"
//!
//! * any regular expression followed by closure char (*) matches
//! zero or more matches of that form.
//! emit code "STAR char" for simple case or 'TODO:'
//!
//! + same as '*', except it matches one or more.
//! emit code "PLUS char" for simple case or 'TODO:'
//!
//! ? zero or one. emit code 'TODO: '
//!
//! ^ match the beginning of the line. emit code "BOL"
//!
//! $ match the end of line. emit code "EOL"
//!
//! ## Details
//!
//! ## Code emit example
//! '()' contain the position of next node
//! ```plain
//! regex_compile("a")
//! result :
//! BEGIN
//! 1:BRANCH(15)
//! 4:EXACTLY(15)a
//! 15:END(0)
//!
//! regex_compile("a*")
//! result :
//! BEGIN
//! 1:BRANCH(18)
//! 4:STAR(18)
//! 7:EXACTLY(0)a
//! 18:END(0)
//!
//!
//! regex_compile("a?")
//! result :
//! BEGIN
//! 1:BRANCH(24)
//! 4:BRANCH(18)
//! 7:EXACTLY(21)a
//! 18:BRANCH(21)
//! 21:NOTHING(24)
//! 24:END(0)
//!
//! ```
//!
//!
#![feature(iter_advance_by)]
#[macro_use]
extern crate enum_display_derive;
mod regex;
pub use regex::Regex;