Compile a regular expression given its AST. The compiler is guaranteed to succeed unless the program exceeds the specified size limit. If the size limit is exceeded, then compilation stops and returns an error.
(
mut self,
exprs: &[Hir],
)
| 120 | /// specified size limit. If the size limit is exceeded, then compilation |
| 121 | /// stops and returns an error. |
| 122 | pub fn compile( |
| 123 | mut self, |
| 124 | exprs: &[Hir], |
| 125 | ) -> result::Result<Program, Error> { |
| 126 | debug_assert!(exprs.len() >= 1); |
| 127 | self.num_exprs = exprs.len(); |
| 128 | if exprs.len() == 1 { |
| 129 | self.compile_one(&exprs[0]) |
| 130 | } else { |
| 131 | self.compile_many(exprs) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | fn compile_one(mut self, expr: &Hir) -> result::Result<Program, Error> { |
| 136 | // If we're compiling a forward DFA and we aren't anchored, then |