An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.
This commit is contained in:
Andrew Gallant
2014-06-03 23:04:59 -04:00
parent f5ead0dd66
commit 9d39178f2f
2 changed files with 17 additions and 0 deletions

View File

@@ -201,6 +201,9 @@ pub fn parse(s: &str) -> Result<Ast, Error> {
impl<'a> Parser<'a> {
fn parse(&mut self) -> Result<Ast, Error> {
if self.chars.len() == 0 {
return Ok(Nothing);
}
loop {
let c = self.cur();
match c {