|
11 | 11 | // Enable this to squash warnings due to exporting pieces of the representation |
12 | 12 | // for use with the regex! macro. See lib.rs for explanation. |
13 | 13 |
|
14 | | -pub use self::Inst::*; |
| 14 | +use self::Inst::*; |
15 | 15 |
|
16 | 16 | use std::cmp; |
17 | 17 | use parse; |
18 | | -use parse::{ |
19 | | - Flags, FLAG_EMPTY, |
20 | | - Nothing, Literal, Dot, AstClass, Begin, End, WordBoundary, Capture, Cat, Alt, |
21 | | - Rep, |
22 | | - ZeroOne, ZeroMore, OneMore, |
23 | | -}; |
| 18 | +use parse::{Flags, FLAG_EMPTY}; |
| 19 | +use parse::Ast::{Nothing, Literal, Dot, AstClass, Begin, End, WordBoundary, Capture, Cat, Alt, |
| 20 | + Rep}; |
| 21 | +use parse::Repeater::{ZeroOne, ZeroMore, OneMore}; |
24 | 22 |
|
25 | | -type InstIdx = uint; |
| 23 | +pub type InstIdx = uint; |
26 | 24 |
|
| 25 | +/// An instruction, the underlying unit of a compiled regular expression |
27 | 26 | #[deriving(Show, Clone)] |
28 | 27 | pub enum Inst { |
29 | | - // When a Match instruction is executed, the current thread is successful. |
| 28 | + /// When a Match instruction is executed, the current thread is successful. |
30 | 29 | Match, |
31 | 30 |
|
32 | | - // The OneChar instruction matches a literal character. |
33 | | - // The flags indicate whether to do a case insensitive match. |
| 31 | + /// The OneChar instruction matches a literal character. |
| 32 | + /// The flags indicate whether to do a case insensitive match. |
34 | 33 | OneChar(char, Flags), |
35 | 34 |
|
36 | | - // The CharClass instruction tries to match one input character against |
37 | | - // the range of characters given. |
38 | | - // The flags indicate whether to do a case insensitive match and whether |
39 | | - // the character class is negated or not. |
| 35 | + /// The CharClass instruction tries to match one input character against |
| 36 | + /// the range of characters given. |
| 37 | + /// The flags indicate whether to do a case insensitive match and whether |
| 38 | + /// the character class is negated or not. |
40 | 39 | CharClass(Vec<(char, char)>, Flags), |
41 | 40 |
|
42 | | - // Matches any character except new lines. |
43 | | - // The flags indicate whether to include the '\n' character. |
| 41 | + /// Matches any character except new lines. |
| 42 | + /// The flags indicate whether to include the '\n' character. |
44 | 43 | Any(Flags), |
45 | 44 |
|
46 | | - // Matches the beginning of the string, consumes no characters. |
47 | | - // The flags indicate whether it matches if the preceding character |
48 | | - // is a new line. |
| 45 | + /// Matches the beginning of the string, consumes no characters. |
| 46 | + /// The flags indicate whether it matches if the preceding character |
| 47 | + /// is a new line. |
49 | 48 | EmptyBegin(Flags), |
50 | 49 |
|
51 | | - // Matches the end of the string, consumes no characters. |
52 | | - // The flags indicate whether it matches if the proceeding character |
53 | | - // is a new line. |
| 50 | + /// Matches the end of the string, consumes no characters. |
| 51 | + /// The flags indicate whether it matches if the proceeding character |
| 52 | + /// is a new line. |
54 | 53 | EmptyEnd(Flags), |
55 | 54 |
|
56 | | - // Matches a word boundary (\w on one side and \W \A or \z on the other), |
57 | | - // and consumes no character. |
58 | | - // The flags indicate whether this matches a word boundary or something |
59 | | - // that isn't a word boundary. |
| 55 | + /// Matches a word boundary (\w on one side and \W \A or \z on the other), |
| 56 | + /// and consumes no character. |
| 57 | + /// The flags indicate whether this matches a word boundary or something |
| 58 | + /// that isn't a word boundary. |
60 | 59 | EmptyWordBoundary(Flags), |
61 | 60 |
|
62 | | - // Saves the current position in the input string to the Nth save slot. |
| 61 | + /// Saves the current position in the input string to the Nth save slot. |
63 | 62 | Save(uint), |
64 | 63 |
|
65 | | - // Jumps to the instruction at the index given. |
| 64 | + /// Jumps to the instruction at the index given. |
66 | 65 | Jump(InstIdx), |
67 | 66 |
|
68 | | - // Jumps to the instruction at the first index given. If that leads to |
69 | | - // a panic state, then the instruction at the second index given is |
70 | | - // tried. |
| 67 | + /// Jumps to the instruction at the first index given. If that leads to |
| 68 | + /// a panic state, then the instruction at the second index given is |
| 69 | + /// tried. |
71 | 70 | Split(InstIdx, InstIdx), |
72 | 71 | } |
73 | 72 |
|
|
0 commit comments