diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-06-24 16:43:42 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-06-24 16:43:42 +0200 |
commit | 367347debb68da0e4b67c0e7a24b741a3259ae87 (patch) | |
tree | 1fa9ed8005fdf2e501a918e90f42d9a763b21181 /Visitor | |
parent | 68c1f0d5f25f75d052320a8acf07e934fca3fcf1 (diff) | |
download | Praspel-367347debb68da0e4b67c0e7a24b741a3259ae87.zip Praspel-367347debb68da0e4b67c0e7a24b741a3259ae87.tar.gz Praspel-367347debb68da0e4b67c0e7a24b741a3259ae87.tar.bz2 |
Add the regex syntactic sugar: /r/m:s.
/r/[m][:s] where r is a regex, m is a modifier and s the maximum size.
It is strictly equivalent to regex('/r/[m]', s).
Diffstat (limited to 'Visitor')
-rw-r--r-- | Visitor/Interpreter.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Visitor/Interpreter.php b/Visitor/Interpreter.php index d396e04..26c1b50 100644 --- a/Visitor/Interpreter.php +++ b/Visitor/Interpreter.php @@ -429,6 +429,16 @@ class Interpreter implements \Hoa\Visitor\Visit { return $element->getChild(1)->accept($this, $handle, $eldnah); break; + case '#regex': + $regex = $element->getChild(0)->accept($this, $handle, $eldnah); + $length = 12; + + if(true === $element->childExists(1)) + $length = $element->getChild(1)->accept($this, $handle, $eldnah); + + return realdom()->regex($regex, $length); + break; + case 'token': $tId = $element->getValueToken(); $value = $element->getValueValue(); @@ -522,6 +532,7 @@ class Interpreter implements \Hoa\Visitor\Visit { case 'accepted': case 'string': + case 'regex'; return $value; default: |